mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-03 06:59:14 +00:00
Line items report whether they have tax included
This commit is contained in:
@@ -33,6 +33,10 @@ Spree::LineItem.class_eval do
|
||||
where('spree_adjustments.id IS NULL')
|
||||
|
||||
|
||||
def has_tax?
|
||||
adjustments.included_tax.any?
|
||||
end
|
||||
|
||||
def price_with_adjustments
|
||||
# EnterpriseFee#create_locked_adjustment applies adjustments on line items to their parent order,
|
||||
# so line_item.adjustments returns an empty array
|
||||
|
||||
@@ -63,5 +63,20 @@ module Spree
|
||||
li.amount_with_adjustments.should == 122.22
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking if a line item has tax included" do
|
||||
let(:li_no_tax) { create(:line_item) }
|
||||
let(:li_tax) { create(:line_item) }
|
||||
let(:tax_rate) { create(:tax_rate, calculator: Spree::Calculator::DefaultTax.new) }
|
||||
let!(:adjustment) { create(:adjustment, adjustable: li_tax, originator: tax_rate, label: "TR", amount: 123, included_tax: 10.00) }
|
||||
|
||||
it "returns true when it does" do
|
||||
li_tax.should have_tax
|
||||
end
|
||||
|
||||
it "returns false otherwise" do
|
||||
li_no_tax.should_not have_tax
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user