mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Include enterprise fee tax on sales tax report
This commit is contained in:
@@ -8,7 +8,7 @@ module OpenFoodNetwork
|
||||
|
||||
def header
|
||||
["Order number", "Date", "Items", "Items total (#{currency_symbol})", "Taxable Items Total (#{currency_symbol})",
|
||||
"Sales Tax (#{currency_symbol})", "Delivery Charge (#{currency_symbol})", "Tax on Delivery (#{currency_symbol})",
|
||||
"Sales Tax (#{currency_symbol})", "Delivery Charge (#{currency_symbol})", "Tax on Delivery (#{currency_symbol})", "Tax on Fees (#{currency_symbol})",
|
||||
"Total Tax (#{currency_symbol})", "Customer", "Distributor"]
|
||||
end
|
||||
|
||||
@@ -17,9 +17,10 @@ module OpenFoodNetwork
|
||||
totals = totals_of order.line_items
|
||||
shipping_cost = shipping_cost_for order
|
||||
shipping_tax = order.shipping_tax
|
||||
|
||||
enterprise_fee_tax = order.enterprise_fee_tax
|
||||
|
||||
[order.number, order.created_at, totals[:items], totals[:items_total],
|
||||
totals[:taxable_total], totals[:sales_tax], shipping_cost, shipping_tax, totals[:sales_tax] + shipping_tax,
|
||||
totals[:taxable_total], totals[:sales_tax], shipping_cost, shipping_tax, enterprise_fee_tax, totals[:sales_tax] + shipping_tax + enterprise_fee_tax,
|
||||
order.bill_address.full_name, order.distributor.andand.name]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -109,12 +109,16 @@ feature %q{
|
||||
end
|
||||
|
||||
describe "Sales tax report" do
|
||||
let(:user1) { create_enterprise_user enterprises: [create(:distributor_enterprise, with_payment_and_shipping: true)] }
|
||||
let(:user2) { create_enterprise_user enterprises: [create(:distributor_enterprise, with_payment_and_shipping: true)] }
|
||||
let(:distributor1) { create(:distributor_enterprise, with_payment_and_shipping: true) }
|
||||
let(:distributor2) { create(:distributor_enterprise, with_payment_and_shipping: true) }
|
||||
let(:user1) { create_enterprise_user enterprises: [distributor1] }
|
||||
let(:user2) { create_enterprise_user enterprises: [distributor2] }
|
||||
let(:shipping_method) { create(:shipping_method, name: "Shipping", description: "Expensive", calculator: Spree::Calculator::FlatRate.new(preferred_amount: 100.55)) }
|
||||
let(:enterprise_fee) { create(:enterprise_fee, enterprise: user1.enterprises.first, tax_category: product2.tax_category, calculator: Spree::Calculator::FlatRate.new(preferred_amount: 120.0)) }
|
||||
let(:order_cycle) { create(:simple_order_cycle, coordinator: distributor1, coordinator_fees: [enterprise_fee], distributors: [distributor1], variants: [product1.master]) }
|
||||
|
||||
let!(:zone) { create(:zone_with_member) }
|
||||
let(:order1) { create(:order, distributor: user1.enterprises.first, shipping_method: shipping_method, bill_address: create(:address)) }
|
||||
let(:order1) { create(:order, order_cycle: order_cycle, distributor: user1.enterprises.first, shipping_method: shipping_method, bill_address: create(:address)) }
|
||||
let(:product1) { create(:taxed_product, zone: zone, price: 12.54, tax_rate_amount: 0) }
|
||||
let(:product2) { create(:taxed_product, zone: zone, price: 500.15, tax_rate_amount: 0.2) }
|
||||
|
||||
@@ -129,6 +133,8 @@ feature %q{
|
||||
Spree::Config.shipping_tax_rate = 0.2
|
||||
|
||||
3.times { order1.next }
|
||||
order1.reload.update_distribution_charge!
|
||||
|
||||
order1.finalize!
|
||||
|
||||
login_to_admin_as user1
|
||||
@@ -149,14 +155,18 @@ feature %q{
|
||||
page.should have_content "#{order1.number}"
|
||||
|
||||
# And the totals and sales tax should be correct
|
||||
page.should have_content "1512.99" # items total
|
||||
page.should have_content "1500.45" # taxable items total
|
||||
page.should have_content "123.0" # sales tax (from adj_li2_tax, not calculated on the fly)
|
||||
page.should have_content "1512.99" # items total
|
||||
page.should have_content "1500.45" # taxable items total
|
||||
page.should have_content "123.0" # sales tax (from adj_li2_tax, not calculated on the fly)
|
||||
page.should_not have_content "250.08" # the number that would have been calculated on the fly
|
||||
page.should have_content "20.0" # enterprise fee tax
|
||||
|
||||
# And the shipping cost and tax should be correct
|
||||
page.should have_content "100.55" # shipping cost
|
||||
page.should have_content "16.76" # shipping tax # TODO: do not calculate on the fly
|
||||
page.should have_content "16.76" # shipping tax
|
||||
|
||||
# And the total tax should be correct
|
||||
page.should have_content "159.76" # total tax
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user