Sha256: e77c4111e31c008ad5921022b0167a1fc0796508080dac04281deec10754bc87
Contents?: true
Size: 921 Bytes
Versions: 2
Compression:
Stored size: 921 Bytes
Contents
module Piggybak class TaxCalculator::Percent KEYS = ["state_id", "rate"] def self.available?(method, object) id = method.metadata.detect { |t| t.key == "state_id" }.value if object.is_a?(Cart) if object.extra_data["state_id"] != "" state = State.find(object.extra_data["state_id"]) return state.id == id.to_i if state end else if object.billing_address && object.billing_address.state return object.billing_address.state.id == id.to_i end end return false end def self.rate(method, object) taxable_total = 0 if object.is_a?(Cart) taxable_total = object.total else object.line_items.each do |line_item| taxable_total = line_item.total end end (method.metadata.detect { |m| m.key == "rate" }.value.to_f * taxable_total).to_c end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
piggybak-0.3.1 | app/models/piggybak/tax_calculator/percent.rb |
piggybak-0.3.0 | app/models/piggybak/tax_calculator/percent.rb |