Add helper to display total tax on an order

This commit is contained in:
Rohan Mitchell
2015-04-02 11:20:47 +11:00
parent 2b5fc656fe
commit e75c6a8e1d
2 changed files with 17 additions and 5 deletions

View File

@@ -18,20 +18,24 @@ module CheckoutHelper
end
def display_checkout_admin_and_handling_adjustments_total_for(order)
adjustments = order.adjustments.eligible.where('originator_type = ? AND source_type != ? ', 'EnterpriseFee', 'Spree::LineItem' )
Spree::Money.new( adjustments.sum( &:amount ) , { :currency => order.currency })
adjustments = order.adjustments.eligible.where('originator_type = ? AND source_type != ? ', 'EnterpriseFee', 'Spree::LineItem')
Spree::Money.new adjustments.sum(&:amount) , currency: order.currency
end
def checkout_line_item_adjustments(order)
order.adjustments.eligible.where( source_type: "Spree::LineItem")
order.adjustments.eligible.where(source_type: "Spree::LineItem")
end
def checkout_subtotal(order)
order.item_total + checkout_line_item_adjustments(order).sum( &:amount )
order.item_total + checkout_line_item_adjustments(order).sum(&:amount)
end
def display_checkout_subtotal(order)
Spree::Money.new( checkout_subtotal(order) , { :currency => order.currency })
Spree::Money.new checkout_subtotal(order) , currency: order.currency
end
def display_checkout_tax_total(order)
Spree::Money.new order.total_tax, currency: order.currency
end
def checkout_state_options(source_address)

View File

@@ -12,4 +12,12 @@ describe CheckoutHelper 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') }
it "retrieves the total tax on the order" do
helper.display_checkout_tax_total(order).should == Spree::Money.new(123.45, currency: 'AUD')
end
end
end