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

feat: support float amount values, and fix debts and gifts amount forms #3906

Merged
merged 31 commits into from
May 20, 2020

Conversation

asbiin
Copy link
Member

@asbiin asbiin commented Apr 25, 2020

This fix #333
This also fix #3761, storing amount in database as integer value, rather that decimal.
Every currencies don't use a 2 digits precision, and using decimal/float can lead to calculation errors.

This introduce the notions of monetary amount vs exchange value:

  • exchange value is the amount displayed for the user, or entered by a user, like 12.34 (or 12,34)
  • monetary amount is the amount stored in the database, so as an integer.

@asbiin asbiin marked this pull request as draft April 26, 2020 19:34
@asbiin asbiin marked this pull request as ready for review April 29, 2020 20:34
@asbiin asbiin requested a review from djaiss May 8, 2020 19:21
Copy link
Member

@djaiss djaiss left a comment

Choose a reason for hiding this comment

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

I don't understand why this change was needed.

@asbiin
Copy link
Member Author

asbiin commented May 11, 2020

The reason for this PR is explain in this tweet: https://twitter.com/michaeldyrynda/status/1253516294571175938

In addition, as you may now, some currency have a 2 digit precision (like $ 12.34), but others could have 3 digits (dinar), 1 digit (Cambodian Riel), or 0.
So we really should store amount as an integer (like 1234 for $12.34), and that actually the format required by the \Money\Money class. It will reduce possible bugs, complexity, and improve accuracy.

@asbiin asbiin changed the title feat: stores amount as integer-ish values, and fix debts and gifts amount forms feat: support float amount values, and fix debts and gifts amount forms May 14, 2020
@asbiin asbiin requested a review from djaiss May 19, 2020 12:00
Copy link
Member

@djaiss djaiss left a comment

Choose a reason for hiding this comment

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

😀 Go to go!

@asbiin asbiin merged commit 5c50cad into master May 20, 2020
@asbiin asbiin deleted the 2020-04-25-stores-amount-integer branch May 20, 2020 11:12
@github-actions
Copy link

This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store amount (debt, gift cost) as int + currency Allow float in debt amount field
3 participants