Permalink
Browse files

moved tax calculation in order model postprocess method to after line…

… item post process so coupons and other line items types can be calcuated properly
  • Loading branch information...
Waylon87 committed Nov 30, 2014
1 parent 1f89e28 commit 270d57575453e5f244389563b76fbaea3d9e2072
Showing with 11 additions and 11 deletions.
  1. +11 −11 app/models/piggybak/order.rb
@@ -81,6 +81,17 @@ def postprocess_order
end
end
# Postprocess everything but payments first
self.line_items.each do |line_item|
next if line_item.line_item_type == "payment"
method = "postprocess_#{line_item.line_item_type}"
if line_item.respond_to?(method)
if !line_item.send(method)
return false
end
end
end
# Recalculate and create line item for tax
# If a tax line item already exists, reset price
# If a tax line item doesn't, create
@@ -96,17 +107,6 @@ def postprocess_order
elsif tax_line_item.any?
tax_line_item.first.mark_for_destruction
end
# Postprocess everything but payments first
self.line_items.each do |line_item|
next if line_item.line_item_type == "payment"
method = "postprocess_#{line_item.line_item_type}"
if line_item.respond_to?(method)
if !line_item.send(method)
return false
end
end
end
# Recalculating total and total due, in case post process changed totals
self.total_due = 0

0 comments on commit 270d575

Please sign in to comment.