Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"add-product-type-update-actions",
"add-sqlite-storage",
"async-storage-layer",
"external-tax-mode-support",
"fix-cart-discount-codes",
"fix-category-parent-by-key",
"fix-empty-json-body-on-delete",
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# CHANGELOG

## 3.0.0-beta.4

### Minor Changes

- [#388](https://github.com/labd/commercetools-node-mock/pull/388) [`f053fb9`](https://github.com/labd/commercetools-node-mock/commit/f053fb9106128719dc1088634bf1fc02ffe80296) Thanks [@BramKaashoek](https://github.com/BramKaashoek)! - Add support for `External` and `ExternalAmount` tax modes on carts.

### New behavior

- **`External` tax mode** — `LineItem`, `CustomLineItem`, and shipping methods can now carry an `externalTaxRate`:
- `createCart` honors `LineItemDraft.externalTaxRate`, `CustomLineItemDraft.externalTaxRate`, and `CartDraft.externalTaxRateForShippingMethod`.
- `addLineItem`, `addCustomLineItem`, and `setShippingMethod`/`setCustomShippingMethod` accept `externalTaxRate`.
- New update actions: `setLineItemTaxRate`, `setCustomLineItemTaxRate`, `setShippingMethodTaxRate`.
- **`ExternalAmount` tax mode** — explicit gross amounts can be supplied per item and at the cart level:
- New update actions: `setLineItemTaxAmount`, `setCustomLineItemTaxAmount`, `setShippingMethodTaxAmount`, `setCartTotalTax`.
- In this mode the cart's `taxedPrice` is whatever `setCartTotalTax` last set; it is no longer aggregated from line items. `taxedShippingPrice` continues to mirror `shippingInfo.taxedPrice`.
- All tax calculations now respect `cart.taxRoundingMode` (`HalfEven` / `HalfUp` / `HalfDown`) instead of always using `Math.round`.

### Cart total recomputation after update actions

`CartUpdateHandler.apply` now recomputes `cart.taxedPrice` and `cart.taxedShippingPrice` after every update batch (except in `ExternalAmount` mode, where the cart total is authoritative via `setCartTotalTax`).

This fixes a pre-existing latent bug: previously these fields were only computed once during `create()` and were never refreshed after update actions, so e.g. running `setShippingMethod` after cart creation would leave the cart-level aggregate stale. It didn't show up before because `LineItem.taxedPrice` was never populated in any mode, so the aggregate had no contributors that could drift. With the new tax-mode work, line items and custom line items now actually carry `taxedPrice`, which made the gap observable and required fixing.

## 3.0.0-beta.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labdigital/commercetools-mock",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"license": "MIT",
"author": "Michael van Tellingen",
"type": "module",
Expand Down