Repository navigation
fix(pricing): don't drop price list updates that carry explicit ids - #17439
Conversation
ðĶ Changeset detectedLatest commit: 322a71f The changes in this PR will be included in the next version bump. This PR includes changesets to release 83 packages
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 |
|
Thanks for the contribution! Initial automated review looks good. Verdict: Looks good for a final review by the team. Changes Checked: security, performance, correctness, conventions, tests. The fix is a one-liner that preserves the existing hash-based deduplication for entries without ids. All five callers of Triggered by: new PR opened |
Summary
What â Price updates that carry distinct explicit ids are no longer collapsed into one when they omit the optional currency and quantity fields.
Why â Calling
updatePriceListPrices(for example throughbatchPriceListPricesWorkflowor the admin price list batch route) with several{ id, price_set_id, amount }updates for prices in the same price set only applied the last one. The others were silently dropped and the workflow still succeeded.normalizePricesdeduplicated the input by a hash of the identity fields it contained, and that hash ignoresid. Partial updates without currency or quantity fields all produced the same hash, so each one overwrote the previous entry in the map.How â In
packages/modules/pricing/src/services/pricing-module.ts(normalizePrices), entries are now keyed by theiridwhen present: either the explicit id or the id copied from a matched existing price. Entries without an id still fall back to the hash, so prices that match an existing row are still deduplicated as before.Testing â Added
should update every price identified by id when quantity fields are omittedtopackages/modules/pricing/integration-tests/__tests__/services/pricing-module/price-list.spec.ts. It creates two quantity-band prices (1-9 and 10+) in one price list and price set, then updates both by id with onlyprice_set_idandamount. Before the fix it fails with["price-band-1", 1, 80](expected 78). After the fix it passes. The full pricing module integration suite (138 tests) and the unit suite pass.Checklist
Additional Context
dist. To verify, the same one-line change was applied to the local build output, because a rebuild couldn't be run in this environment.normalizePricesreplaces the supplied id with the matched price's id (entry.id = existing.id ?? entry.id).updatePriceListPrices_only fetches the existing rows by id when ids are supplied, so this case doesn't arise in the reported flow.Fixes #17289