Class: TaxCalculator
- Inherits:
-
Object
- Object
- TaxCalculator
- Defined in:
- app/models/tax_calculator.rb
Instance Method Summary collapse
-
#initialize(order) ⇒ TaxCalculator
constructor
A new instance of TaxCalculator.
-
#tax ⇒ Object
Returns tax amount in float.
Constructor Details
#initialize(order) ⇒ TaxCalculator
Returns a new instance of TaxCalculator.
2 3 4 |
# File 'app/models/tax_calculator.rb', line 2 def initialize(order) @order = order end |
Instance Method Details
#tax ⇒ Object
Returns tax amount in float
7 8 9 10 11 |
# File 'app/models/tax_calculator.rb', line 7 def tax amount = BigDecimal(@order.line_items_total.to_s) (amount * BigDecimal(tax_percentage.to_s) * BigDecimal.new("0.01")).round(2).to_f end |