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

Improve currency symbol detection #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RubenIgnacio
Copy link

The version v1.13.0 of monetize currently detects limited currency symbols. For example:

Expected behavior:

Monetize.parse('S/10') # <Money fractional:1000 currency:PEN>
Monetize.parse('PEN10') # <Money fractional:1000 currency:PEN>

Current behavior:

Monetize.parse('S/10') # <Money fractional:1000 currency:USD>
Monetize.parse('PEN10') # <Money fractional:1000 currency:USD>

Proposed Solution

The Money::Currency.table can be used to retrieve the list of currency symbols. In cases where symbols are repeated, the disambiguate_symbol can be used as the symbol. However, this solution has some limitations:

  • Symbols that contain dots may be confused with decimal marks.
  • Certain symbols can be misinterpreted as multiplier suffixes (e.g., "K" for thousands).

To address these limitations, such symbols will be ignored during parsing. Additionally, any problematic symbols can be added to a list of ignored symbols to prevent issues. This can be a starting point but can be refined further to handle more cases and support additional symbols in the future.

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.

1 participant