mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add fundraising fees
This commit is contained in:
@@ -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 }}
|
||||
|
||||
@@ -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']
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user