diff --git a/lib/open_food_network/enterprise_fee_calculator.rb b/lib/open_food_network/enterprise_fee_calculator.rb index 2d76d8d280..c8070f2ab2 100644 --- a/lib/open_food_network/enterprise_fee_calculator.rb +++ b/lib/open_food_network/enterprise_fee_calculator.rb @@ -19,7 +19,7 @@ module OpenFoodNetwork fees[applicator.enterprise_fee.fee_type.to_sym] ||= 0 fees[applicator.enterprise_fee.fee_type.to_sym] += calculate_fee_for variant, applicator fees - end + end.select { |fee_type, amount| amount > 0 } end diff --git a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb index 21c4848fda..0ca7da4999 100644 --- a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb +++ b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb @@ -45,6 +45,12 @@ module OpenFoodNetwork it "returns a breakdown of fees" do EnterpriseFeeCalculator.new(distributor, order_cycle).fees_by_type_for(product.master).should == {admin: 1.23, sales: 4.56, packing: 7.89, transport: 0.12} end + + it "filters out zero fees" do + ef_admin.calculator.update_attribute :preferred_amount, 0 + + EnterpriseFeeCalculator.new(distributor, order_cycle).fees_by_type_for(product.master).should == {sales: 4.56, packing: 7.89, transport: 0.12} + end end describe "creating adjustments" do