-
Notifications
You must be signed in to change notification settings - Fork 23
feat: enable HighPrecisionMoney #365
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: enable HighPrecisionMoney #365
Conversation
🦋 Changeset detectedLatest commit: d8bbd3a The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
chore: add changeset and refactor refactor: formatting refactor: formatting fix: clear the outdated preciseAmount on required CentPrecisionMoney types refactor: validate if calculcated amount matches the external price
efcd894 to
1740505
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for HighPrecisionMoney in the commercetools mock API, enabling currency amounts with more than the standard 2-3 fraction digits. The implementation includes new helper functions for converting between precise amounts and cent amounts, with proper rounding support.
Key changes:
- New helper functions to handle high precision money calculations and conversions
- Updated all money-related operations (cart line items, custom line items, orders) to support both CentPrecisionMoney and HighPrecisionMoney
- Added comprehensive integration tests for high precision external prices
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.changeset/cold-phones-film.md |
Adds changeset documenting the HighPrecisionMoney feature addition |
src/repositories/helpers.ts |
Implements core high precision money support with new helper functions for currency fraction digits lookup, cent amount calculation from precise amounts, and money type creation |
src/repositories/cart/helpers.ts |
Updates line item price calculations to use the new helper for accurate total price computation with high precision support |
src/repositories/cart/index.ts |
Updates cart line item creation to properly calculate total prices using the new money calculation helper |
src/repositories/cart/actions.ts |
Updates all cart update actions (add line item, set quantities, set prices) to correctly handle high precision money calculations |
src/repositories/order/index.ts |
Updates order line item and custom line item creation to support high precision money in import drafts |
src/repositories/shipping-method/helpers.ts |
Explicitly uses CentPrecisionMoney for shipping rates (shipping rates don't support high precision) |
src/services/cart.test.ts |
Adds integration tests validating high precision external prices with different fraction digits (3 and 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @labdigital/[email protected] ### Minor Changes - [#365](#365) [`ef7ef13`](ef7ef13) Thanks [@robertmoelker](https://github.com/robertmoelker)! - Add HighPrecisionMoney support - [#360](#360) [`06315c6`](06315c6) Thanks [@daanjo3](https://github.com/daanjo3)! - Add basic support for discount codes in the cart repository Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Support HighPrecisionMoney