Module: CurrencyRoundingHelper

Defined in:
app/helpers/currency_rounding_helper.rb

Instance Method Summary collapse

Instance Method Details

#currency_decimal_places(currency) ⇒ Object



7
8
9
# File 'app/helpers/currency_rounding_helper.rb', line 7

def currency_decimal_places(currency)
  Money::Currency.find(currency).decimal_places
end

#round_by_currency(amount, currency) ⇒ Object



2
3
4
5
# File 'app/helpers/currency_rounding_helper.rb', line 2

def round_by_currency(amount, currency)
  decimal_places = currency_decimal_places(currency)
  BigDecimal(amount.to_s).round(decimal_places, BigDecimal::ROUND_HALF_UP)
end