Skip to content

Suporte para identificar moeda automaticamente por código/símbolo #82 #111

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

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

theuves
Copy link
Member

@theuves theuves commented Mar 5, 2025

Descrição

Esta PR implementa a funcionalidade de detecção automática de moedas através de códigos (ex: BRL, USD) ou símbolos monetários (ex: R$, $), conforme solicitado na issue #82.

Principais alterações:

  • Implementação da detecção automática de moeda por código ou símbolo
  • Ativação automática do modo CURRENCY quando uma moeda é identificada
  • Correção no tratamento de partes decimais no modo DIGIT:
    • Removida adição desnecessária de "vírgula zero"
    • Melhorado o tratamento de casas decimais
    • Inclusão de decimais apenas quando não são zero

Testes

  • Adicionados testes para modos inválidos
  • Cobertura de casos com e sem parte decimal
  • Validação de diferentes códigos e símbolos de moeda

Closes #82

@theuves theuves added the new features Describe the new feature you would like to see implemented label Mar 5, 2025
theuves added 12 commits March 5, 2025 23:06
Ensures decimal parts are only included when non-zero and prevents unnecessary decimal representation
Removed trailing whitespaces and updated TypeScript error handling annotations across multiple test and utility files
- Refactored currency detection tests to use a more structured approach with test cases
- Added test helpers for generating formatted amounts with currency codes and symbols
- Simplified test cases for currency detection in `detectCurrency()` and `extenso()`
- Introduced `currencyTestCases` and `invalidCurrencyTestCases` for more comprehensive testing
- Created utility functions `getFormattedAmount()` and `getFormattedAmountWithSymbol()`
Copy link

sonarqubecloud bot commented Mar 9, 2025

Copy link
Member Author

@theuves theuves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Em extenso(): should handle currency codes in different positions deveria retornar erro pois em 1234.56 EUR 789 o 789 não faz parte do número e em 1234.56 789 USD o 789 também não.
    • O mesmo ocorre em extenso(): should handle currency symbols in different positions.
  • Em extenso(): should handle multiple currency indicators deveria retornar erro também; não deveria ser possível passar múltiplas moedas ao mesmo tempo.

@theuves theuves mentioned this pull request Jul 19, 2025
3 tasks
@theuves theuves marked this pull request as draft July 23, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new features Describe the new feature you would like to see implemented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suporte para identificar moeda automaticamente por código/símbolo
1 participant