Add option to ignore delivered amounts in order group distribution (#765)
This commit is contained in:
parent
ecda1c1478
commit
45a8911ca6
11 changed files with 69 additions and 4 deletions
9
spec/factories/group_order_article_quantity.rb
Normal file
9
spec/factories/group_order_article_quantity.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
require 'factory_bot'
|
||||
|
||||
FactoryBot.define do
|
||||
|
||||
# requires order_article
|
||||
factory :group_order_article_quantity do
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -42,4 +42,23 @@ describe GroupOrderArticle do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'distribution strategy' do
|
||||
let(:article) { create :article, supplier: order.supplier, unit_quantity: 1 }
|
||||
let(:oa) { order.order_articles.create(:article => article) }
|
||||
let(:goa) { create :group_order_article, group_order: go, order_article: oa }
|
||||
let!(:goaq) { create :group_order_article_quantity, group_order_article: goa, quantity: 4 }
|
||||
|
||||
it 'can calculate the result for the distribution strategy "first order first serve"' do
|
||||
res = goa.calculate_result(2)
|
||||
expect(res).to eq(quantity: 2, tolerance: 0, total: 2)
|
||||
end
|
||||
|
||||
it 'can calculate the result for the distribution strategy "no automatic distribution"' do
|
||||
FoodsoftConfig[:distribution_strategy] = FoodsoftConfig::DistributionStrategy::NO_AUTOMATIC_DISTRIBUTION
|
||||
|
||||
res = goa.calculate_result(2)
|
||||
expect(res).to eq(quantity: 4, tolerance: 0, total: 4)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue