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:
		@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -28,5 +28,6 @@ public class ArticleOffer {
 | 
			
		||||
 | 
			
		||||
    public boolean shouldBeAdvertised;
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    @ManyToOne(optional = true)
 | 
			
		||||
    public Supplier cheapestSupplier;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user