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 incorrect computations for unit_price_decimal for discounted prices #157

Conversation

josecarneiro
Copy link
Contributor

No description provided.

* Right now we have a solution that targets specifically discounted prices,
* but this should be generalized.
*/
...(price?.pricing_model === PricingModel.perUnit && { unit_amount_decimal: unitAmountDecimal }),
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look correct.

Did you understand why are we adding it only when it's per_unit?

* but this should be generalized.
*/
...(price?.pricing_model === PricingModel.perUnit && { unit_amount_decimal: unitAmountDecimal }),
...(typeof itemValues.unit_amount === 'number' &&
Copy link
Member

Choose a reason for hiding this comment

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

All these conditions should be evaluated to true. Since we are using dineroJS to compute values it only uses and outputs integers, if you are receiving here any other thing the issue should be before this step.

…/incorrect-computations-for-unit_price_decimal-for-discounted-prices
@josecarneiro josecarneiro merged commit e0a647a into main Jan 3, 2025
2 checks passed
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.

2 participants