Line items report whether they have tax included

This commit is contained in:
Rohan Mitchell
2015-09-21 15:57:04 +10:00
parent 9dc0598870
commit 8f40702369
2 changed files with 19 additions and 0 deletions

View File

@@ -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

View File

@@ -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