Skip to content

Conversation

@robertmoelker
Copy link
Contributor

@robertmoelker robertmoelker commented Dec 24, 2025

Support HighPrecisionMoney

@changeset-bot
Copy link

changeset-bot bot commented Dec 24, 2025

🦋 Changeset detected

Latest 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
Copy link

Copilot AI left a 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)

Copy link

Copilot AI left a 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.

@mvantellingen mvantellingen self-requested a review December 24, 2025 11:55
@mvantellingen mvantellingen merged commit ef7ef13 into labd:main Dec 24, 2025
11 checks passed
mvantellingen pushed a commit that referenced this pull request Dec 30, 2025
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>
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