Skip to content

String#to_money parsing issue #57

@bertBruynooghe

Description

@bertBruynooghe

when parsing 1.234 with a currency that has , as decimal_mark and . as thousands_separator, the currency settings are ignored, and . is considered to be the decimail_mark.

I patched the code locally in my rails project:

module Monetize
  class << self
    def extract_cents_with_decimals_addition(input, currency = Money.default_currency)
      decimal_mark = I18n.t('number.currency.format.separator')
      input = "#{input}#{decimal_mark}0" unless input.include?(decimal_mark)
      extract_cents_without_decimals_addition(input, currency)
    end
    alias_method_chain :extract_cents, :decimals_addition
  end
end```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions