diff --git a/app/assets/javascripts/templates/price_breakdown.html.haml b/app/assets/javascripts/templates/price_breakdown.html.haml index 01588933ca..0b7eba917a 100644 --- a/app/assets/javascripts/templates/price_breakdown.html.haml +++ b/app/assets/javascripts/templates/price_breakdown.html.haml @@ -24,6 +24,9 @@ %li{"bo-if" => "variant.fees.transport"} .right {{ variant.fees.transport | currency }} Transport fee + %li{"bo-if" => "variant.fees.fundraising"} + .right {{ variant.fees.fundraising | currency }} + Fundraising fee %li %strong .right = {{ variant.price | currency }} diff --git a/app/models/enterprise_fee.rb b/app/models/enterprise_fee.rb index f41ad76c96..6270f77b7a 100644 --- a/app/models/enterprise_fee.rb +++ b/app/models/enterprise_fee.rb @@ -10,7 +10,7 @@ class EnterpriseFee < ActiveRecord::Base attr_accessible :enterprise_id, :fee_type, :name, :calculator_type - FEE_TYPES = %w(packing transport admin sales) + FEE_TYPES = %w(packing transport admin sales fundraising) PER_ORDER_CALCULATORS = ['Spree::Calculator::FlatRate', 'Spree::Calculator::FlexiRate'] 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 0ca7da4999..9c950234cd 100644 --- a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb +++ b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb @@ -37,19 +37,20 @@ module OpenFoodNetwork let!(:ef_sales) { create(:enterprise_fee, fee_type: 'sales', amount: 4.56) } let!(:ef_packing) { create(:enterprise_fee, fee_type: 'packing', amount: 7.89) } let!(:ef_transport) { create(:enterprise_fee, fee_type: 'transport', amount: 0.12) } + let!(:ef_fundraising) { create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45) } let!(:exchange) { create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: distributor, incoming: false, - enterprise_fees: [ef_admin, ef_sales, ef_packing, ef_transport], + enterprise_fees: [ef_admin, ef_sales, ef_packing, ef_transport, ef_fundraising], variants: [product.master]) } 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} + EnterpriseFeeCalculator.new(distributor, order_cycle).fees_by_type_for(product.master).should == {admin: 1.23, sales: 4.56, packing: 7.89, transport: 0.12, fundraising: 3.45} 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} + EnterpriseFeeCalculator.new(distributor, order_cycle).fees_by_type_for(product.master).should == {sales: 4.56, packing: 7.89, transport: 0.12, fundraising: 3.45} end end