Skip to content

Dashboard chapter 12 amountInCents = amount * 100 doesn't convert to integer. #636

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

Open
tpdickson opened this issue Apr 3, 2024 · 0 comments

Comments

@tpdickson
Copy link

In Chapter 12:

https://nextjs.org/learn/dashboard-app/mutating-data#storing-values-in-cents

The dollar amount is converted to cents by multiplying by 100. However, this doesn't convert it to an integer and can lead to database errors. The value after multiplication needs to be rounded (Math.round(amount * 100)).

For example, entering 2.55:

image

Database Error: Failed to Update Invoice. NeonDbError: invalid input syntax for type integer: "254.99999999999997"

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

No branches or pull requests

1 participant