Sha256: b41632c9788bb89b07cfe8eea58aca79d7d787eb1fc03e435607783fa1b29614

Contents?: true

Size: 332 Bytes

Versions: 12

Compression:

Stored size: 332 Bytes

Contents

class TaxCalculator
  def initialize(order)
    @order = order
  end

  # Returns tax amount in float
  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

  private

  def tax_percentage
    Shop.first.tax_percentage
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
nimbleshop_core-0.0.4.beta1 app/models/tax_calculator.rb
nimbleshop_core-0.0.4 app/models/tax_calculator.rb
nimbleshop_core-0.0.3 app/models/tax_calculator.rb
nimbleshop_core-0.0.2 app/models/tax_calculator.rb
nimbleshop_core-0.0.2.beta1 app/models/tax_calculator.rb
nimbleshop_core-0.0.1 app/models/tax_calculator.rb
nimbleshop_core-0.0.1.rc6 app/models/tax_calculator.rb
nimbleshop_core-0.0.1.rc5 app/models/tax_calculator.rb
nimbleshop_core-0.0.1.rc4 app/models/tax_calculator.rb
nimbleshop_core-0.0.1.rc3 app/models/tax_calculator.rb
nimbleshop_core-0.0.1.rc2 app/models/tax_calculator.rb
nimbleshop_core-0.0.1.rc1 app/models/tax_calculator.rb