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

fix(fractionless): Honor decimals in fractionless amounts #1

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

alexpresthus
Copy link
Owner

Honor the configured precision, as defined by options.decimals or
currency if options.decimals = undefined, when instatiating with
.fromFractionlessAmount() and converting .toFractionlessAmount().

Fixes old behavior:

Money.fromFractionlessAmount(1000, 'NOK', { decimals: 3 }) => 10.000 NOK
money.toFractionlessAmount() => 1000 NOK

To expected behavior:

Money.fromFractionlessAmount(1000, 'NOK', { decimals: 3 }) => 1.000 NOK
money.toFractionlessAmount() => 1000 NOK

Honor the configured precision, as defined by `options.decimals` or
`currency` if `options.decimals = undefined`, when instatiating with
`.fromFractionlessAmount()` and converting `.toFractionlessAmount()`.

Fixes old behavior:
```
Money.fromFractionlessAmount(1000, 'NOK', { decimals: 3 }) => 10.000 NOK
money.toFractionlessAmount() => 1000 NOK
```
To expected behavior:
```
Money.fromFractionlessAmount(1000, 'NOK', { decimals: 3 }) => 1.000 NOK
money.toFractionlessAmount() => 1000 NOK
```
@alexpresthus alexpresthus self-assigned this Nov 21, 2024
@alexpresthus alexpresthus merged commit 842c921 into master Nov 21, 2024
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