Skip to content

Instantly share code, notes, and snippets.

@rounders
Created June 22, 2011 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rounders/1041041 to your computer and use it in GitHub Desktop.
Save rounders/1041041 to your computer and use it in GitHub Desktop.
def site_taxes
zones = Zone.match(self.shipment.address)
tax_rates = zones.map { |zone| zone.tax_rates}.flatten.uniq
calculated_taxes = {}
tax_rates.each do |tax_rate|
calculated_taxes[tax_rate.calculator.description] ||= 0
calculated_taxes[tax_rate.calculator.description] += tax_rate.calculate_tax(self)
end
calculated_taxes.delete_if { |k, v| v == 0 }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment