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...

View file

@ -1,11 +1,10 @@
class ConfigSerializer < ActiveModel::Serializer
# details
attributes :name, :homepage, :contact
# settings
attributes :currency_unit, :currency_space, :default_locale, :price_markup,
:tolerance_is_costly, :use_apple_points, :use_tolerance
:tolerance_is_costly, :distribution_strategy, :use_apple_points, :use_tolerance
# layout
attributes :page_footer_html, :webstats_tracking_code_html

View file

@ -1,5 +1,8 @@
= config_input form, :use_nick, as: :boolean
= config_input form, :tolerance_is_costly, as: :boolean
- distribution_strategy_options = FoodsoftConfig::DistributionStrategy.constants.map { |c| FoodsoftConfig::DistributionStrategy.const_get(c) }
= config_input form, :distribution_strategy, as: :select, collection: distribution_strategy_options,
include_blank: false, input_html: {class: 'input-xxlarge'}, label_method: ->(s){ t("config.keys.distribution_strategy_options.#{s}") }
= config_input form, :disable_invite, as: :boolean
= config_input form, :help_url, as: :url, input_html: {class: 'input-xlarge'}
= config_input form, :webstats_tracking_code, as: :text, input_html: {class: 'input-xxlarge', rows: 3}