Merge pull request 'Store the cheapest supplier for each offered article in the database' (#41) from feature/reorder_cronjob into master

Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
This commit is contained in:
Jannik 2020-06-01 16:53:58 +02:00
commit b14c565e81
2 changed files with 7 additions and 2 deletions

View File

@ -30,9 +30,10 @@ public class UpdateOffersAction {
public List<ArticleOffer> finish() {
HashMap<ArticleIdentifier, ArticleOffer> availableOffers = mapOffers();
// Reset all advertise-flags first. They are set again below.
// Reset all advertise-flags and supplier relations first. They are set again below.
for (ArticleOffer offer : availableOffers.values()) {
offer.shouldBeAdvertised = false;
offer.cheapestSupplier = null;
}
for (Entry<ArticleIdentifier, Offer> cheapestOffer : cheapestOffer.entrySet()) {
@ -47,7 +48,10 @@ public class UpdateOffersAction {
}
Article currentOfferedArticle = cheapestOffer.getValue().apiSupplier.findArticle(manufacturer,
articleNumber);
currentOffer.title = currentOfferedArticle.title;
currentOffer.vatPercent = currentOfferedArticle.vatPercent;
currentOffer.cheapestSupplier = cheapestOffer.getValue().dbSupplier;
currentOffer.pricePerUnitNet = currentOfferedArticle.pricePerUnitNet;
// Set advertise-flag if any supplier wants it to be set
if (currentOfferedArticle.shouldBeAdvertised) {

View File

@ -28,5 +28,6 @@ public class ArticleOffer {
public boolean shouldBeAdvertised;
@ManyToOne(optional = true)
public Supplier cheapestSupplier;
}