Skip to content

Instantly share code, notes, and snippets.

@amencarini
Created February 18, 2012 16:55
Show Gist options
  • Save amencarini/1860175 to your computer and use it in GitHub Desktop.
Save amencarini/1860175 to your computer and use it in GitHub Desktop.
default_tax.rb with different calculation method
def compute_order(order)
matched_line_items = order.line_items.select do |line_item|
line_item.product.tax_category == rate.tax_category
end
line_items_total = matched_line_items.sum(&:total)
round_to_two_places(line_items_total - ( line_items_total / (1 + rate.amount) ) )
end
def compute_line_item(line_item)
if line_item.product.tax_category == rate.tax_category
round_to_two_places(line_item.total - ( line_item.total / (1 + rate.amount) ) )
else
0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment