Fees are calculated correctly for items with variant overrides

This commit is contained in:
Rohan Mitchell
2014-12-18 11:53:17 +11:00
parent ead84aa9ff
commit 5fcb2982fa
2 changed files with 18 additions and 9 deletions

View File

@@ -12,22 +12,22 @@
%li.cost
.right {{ variant.price | localizeCurrency }}
Item cost
%li{"bo-if" => "variant.fees.admin"}
%li.admin-fee{"bo-if" => "variant.fees.admin"}
.right {{ variant.fees.admin | localizeCurrency }}
Admin fee
%li{"bo-if" => "variant.fees.sales"}
%li.sales-fee{"bo-if" => "variant.fees.sales"}
.right {{ variant.fees.sales | localizeCurrency }}
Sales fee
%li{"bo-if" => "variant.fees.packing"}
%li.packing-fee{"bo-if" => "variant.fees.packing"}
.right {{ variant.fees.packing | localizeCurrency }}
Packing fee
%li{"bo-if" => "variant.fees.transport"}
%li.transport-fee{"bo-if" => "variant.fees.transport"}
.right {{ variant.fees.transport | localizeCurrency }}
Transport fee
%li{"bo-if" => "variant.fees.fundraising"}
%li.fundraising-fee{"bo-if" => "variant.fees.fundraising"}
.right {{ variant.fees.fundraising | localizeCurrency }}
Fundraising fee
%li
%li.total
%strong
.right = {{ variant.price_with_fees | localizeCurrency }}
 

View File

@@ -18,21 +18,23 @@ feature "shopping with variant overrides defined", js: true do
let(:v1) { create(:variant, product: p1, price: 11.11, unit_value: 1) }
let(:v2) { create(:variant, product: p1, price: 22.22, unit_value: 2) }
let(:v3) { create(:variant, product: p2, price: 33.33, unit_value: 3) }
let!(:vo1) { create(:variant_override, hub: hub, variant: v1, price: 99.99) }
let!(:vo1) { create(:variant_override, hub: hub, variant: v1, price: 55.55) }
let!(:vo2) { create(:variant_override, hub: hub, variant: v2, count_on_hand: 0) }
let!(:vo3) { create(:variant_override, hub: hub, variant: v3, count_on_hand: 0) }
let(:ef) { create(:enterprise_fee, enterprise: hub, fee_type: 'packing', calculator: Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10)) }
before do
outgoing_exchange.variants << v1
outgoing_exchange.variants << v2
outgoing_exchange.variants << v3
outgoing_exchange.enterprise_fees << ef
visit shop_path
click_link hub.name
end
it "shows the overridden price" do
page.should_not have_price "$11.11"
page.should have_price "$99.99"
page.should have_price "$61.11"
end
it "looks up stock from the override" do
@@ -44,7 +46,14 @@ feature "shopping with variant overrides defined", js: true do
page.should_not have_content v3.options_text
end
it "calculates fees correctly"
it "calculates fees correctly" do
page.find("#variant-#{v1.id} .graph-button").click
page.find(".price_breakdown a").click
page.should have_selector 'li.cost div', text: '$55.55'
page.should have_selector 'li.packing-fee div', text: '$5.56'
page.should have_selector 'li.total div', text: '= $61.11'
end
it "shows the overridden price with fees in the quick cart"
it "shows the correct prices in the shopping cart"
it "shows the correct prices in the checkout"