Sha256: cff45ed34c49ccf66b5b741558f6b361ee36b560a472ebb714946c8e2a7eac72
Contents?: true
Size: 814 Bytes
Versions: 8
Compression:
Stored size: 814 Bytes
Contents
# applies the specified sales tax rate to all taxable items if the order is being shipped to a state # that requires sales tax class SalesTax # rate map can be override by the setter (for testing purposes) @@rate_map = SALES_TAX_RATES # set this constant to be the id of the tax treatment used for sales tax in the db US_SALES_TAX = 2 # right now this is just used in testing but its possible we may want to programatically set this value def self.rate_map= (rate_map) @@rate_map = rate_map end def self.calc_tax(order) state = order.ship_address.state.abbr.to_sym return 0 unless @@rate_map.has_key? state tt = 0 order.line_items.each do |li| tt += li.total if li.product.apply_tax_treatment? US_SALES_TAX end tt * @@rate_map[state] end end
Version data entries
8 entries across 8 versions & 2 rubygems