Store the cheapest supplier for each offered article in the database

This commit is contained in:
Lukas Fürderer 2020-05-30 18:25:23 +02:00
parent d5540c1979
commit e7e3864b4c
Signed by: Lukas
GPG Key ID: B0AFA46F94103349
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;
}