Add option to ignore delivered amounts in order group distribution (#765)

This commit is contained in:
lentschi 2021-02-05 16:19:05 +01:00 committed by GitHub
parent ecda1c1478
commit 45a8911ca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 69 additions and 4 deletions

View file

@ -128,15 +128,18 @@ class GroupOrderArticle < ApplicationRecord
order_quantities = GroupOrderArticleQuantity.where(group_order_article_id: order_article.group_order_article_ids).order('created_on')
logger.debug "GroupOrderArticleQuantity records found: #{order_quantities.size}"
first_order_first_serve = (FoodsoftConfig[:distribution_strategy] == FoodsoftConfig::DistributionStrategy::FIRST_ORDER_FIRST_SERVE)
# Determine quantities to be ordered...
order_quantities.each do |goaq|
q = [goaq.quantity, total - total_quantity].min
q = goaq.quantity
q = [q, total - total_quantity].min if first_order_first_serve
total_quantity += q
if goaq.group_order_article_id == self.id
logger.debug "increasing quantity by #{q}"
quantity += q
end
break if total_quantity >= total
break if total_quantity >= total && first_order_first_serve
end
# Determine tolerance to be ordered...