Sha256: 005fcfae6f04f9dd337686744d8caa663a4359e639fa245a8530a70e9680463d

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

# Currency helper routines
#------------------------------------------------------------------------------
module DmUtilities::CurrencyHelper
  include ActionView::Helpers::NumberHelper

  # Takes a number and a country code and formats it as a monetary value
  # TODO see if there is a better way to hook in the Globalize::Currency object
  # TODO we're not using the country object right now - I think this is a problem
  #------------------------------------------------------------------------------
  def ut_currency(amount, country, options = {})
    return "—".html_safe if amount.blank?
    precision = options[:precision] || 2
    number_to_currency(amount, :locale => country.locale, :precision => precision)
  end

  # Takes a number and a country code and formats it as a monetary value
  #------------------------------------------------------------------------------
  def ut_currency_cents(cents, country, options = {})
    return "—".html_safe if cents.blank?
    ut_currency(cents/100, country, options)
  end
  

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dm_core-4.2.3.10 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.9 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.8 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.7 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.6 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.5 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.4 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.3 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.2 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3.1 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.3 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.2.3 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.2.2 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.2.1 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.2 app/helpers/dm_utilities/currency_helper.rb
dm_core-4.2.1.5 app/helpers/dm_utilities/currency_helper.rb