Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse currency correctly if found from existing hash #167

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

kahshing96
Copy link
Contributor

@kahshing96 kahshing96 commented Jan 10, 2024

  • Fix parsing issue for certain currency symbols like Malaysia Ringgit (RM) as addressed in Version 1.11.0 broke parsing for Malaysian ringgit when using the symbol 'RM' #153 by checking that
    • the computed_currency parsed from the given input from a match ISO currency code regex is a correct ISO code from existing Monetize::Parser::CURRENCY_SYMBOLS, then only assigned it with value
    • else fallback to use compute_currency which match against currency symbol regex
    • eg:
    "RM100".to_money    # #<Money fractional:10000 currency:MYR>
    "S$100".to_money    # #<Money fractional:10000 currency:SGD>
    "NT$100".to_money   # #<Money fractional:10000 currency:TWD>
    "HK$100".to_money   # #<Money fractional:10000 currency:HKD>
    "$100 CAD".to_money # #<Money fractional:10000 currency:CAD>
  • Add & fix related rspecs

@kahshing96
Copy link
Contributor Author

Hi @semmons99 , would you able to take a look at this PR?

@semmons99 semmons99 merged commit 643b2f3 into RubyMoney:main Jan 18, 2024
5 checks passed
@semmons99
Copy link
Member

ty. merged!

@kahshing96
Copy link
Contributor Author

Hi @semmons99 thanks for merging, is it possible to bump the version for this gem in both rubygems and create a new version tag in Github ?

@semmons99
Copy link
Member

done. release 1.13.0 @kahshing96

@Calyhre
Copy link

Calyhre commented Mar 8, 2024

@kahshing96 @semmons99 That's a massive breaking change considering the limited set of CURRENCY_SYMBOLS.

# monetize 0.12.0
'100 NOK'.to_money => #<Money fractional:10000 currency:NOK>

# monetize 0.13.0 (with EUR as default)
'100 NOK'.to_money => #<Money fractional:10000 currency:EUR>

@tagliala
Copy link
Contributor

Just noticed this change when writing 1.13.0 changelog

Yes, this is a breaking change and should not belong to 1.x, however, I'm wondering why this is not using ISO codes from Money (Money::Currency.all.map(&:iso_code))

@weizheheng
Copy link

Yes, this is breaking our production because Monetize::Parser::CURRENCY_SYMBOLS do not have the full list of currency. Now when we try to do:

fee = "AUD 10.00"

# Our default currency is "USD"
Monetize.parse(fee)
# => #<Money fractional:1000 currency:USD>

# The result is in USD instead of AUD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants