mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Take into account voucher tax part when displaying tax included in price
This commit is contained in:
committed by
Maikel Linke
parent
350ca3b778
commit
8254bd9625
@@ -53,7 +53,9 @@ module CheckoutHelper
|
||||
end
|
||||
|
||||
def display_checkout_tax_total(order)
|
||||
Spree::Money.new order.total_tax, currency: order.currency
|
||||
total_tax = order.total_tax + VoucherAdjustmentsService.new(order).voucher_included_tax
|
||||
|
||||
Spree::Money.new(total_tax, currency: order.currency)
|
||||
end
|
||||
|
||||
def display_checkout_taxes_hash(order)
|
||||
|
||||
@@ -15,12 +15,29 @@ describe CheckoutHelper, type: :helper do
|
||||
helper.validated_input("test", "foo", type: :email)
|
||||
end
|
||||
|
||||
describe "displaying the tax total for an order" do
|
||||
let(:order) { double(:order, total_tax: 123.45, currency: 'AUD') }
|
||||
describe "#display_checkout_tax_total" do
|
||||
subject(:display_checkout_tax_total) { helper.display_checkout_tax_total(order) }
|
||||
|
||||
let(:order) { instance_double(Spree::Order, total_tax: 123.45, currency: 'AUD') }
|
||||
let(:service) do
|
||||
instance_double(VoucherAdjustmentsService, voucher_included_tax: voucher_included_tax)
|
||||
end
|
||||
let(:voucher_included_tax) { 0.0 }
|
||||
|
||||
before do
|
||||
allow(VoucherAdjustmentsService).to receive(:new).and_return(service)
|
||||
end
|
||||
|
||||
it "retrieves the total tax on the order" do
|
||||
expect(helper.display_checkout_tax_total(order)).to eq(Spree::Money.new(123.45,
|
||||
currency: 'AUD'))
|
||||
expect(display_checkout_tax_total).to eq(Spree::Money.new(123.45, currency: 'AUD'))
|
||||
end
|
||||
|
||||
context "with a voucher" do
|
||||
let(:voucher_included_tax) { -0.45 }
|
||||
|
||||
it "displays the discounted total tax" do
|
||||
expect(display_checkout_tax_total).to eq(Spree::Money.new(123.00, currency: 'AUD'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user