chore(order): preview order change (#8025)

What:
 - new method `previewOrderChange`
   - Calculate all the actions related to an order change.
   - Return the preview of the final Order, with all the calculated values.
   - Associate actions with items and shipping_methods they modified.

FIXES: CORE-2509
This commit is contained in:
Carlos R. L. Rodrigues
2024-07-09 11:45:55 -03:00
committed by GitHub
parent 4736d9e2dd
commit 2b2e2fbb3d
25 changed files with 373 additions and 57 deletions

View File

@@ -1,6 +1,19 @@
export function setActionReference(existing, action) {
export function setActionReference(existing, action, options) {
existing.detail ??= {}
existing.detail.order_id ??= action.order_id
existing.detail.return_id ??= action.return_id
existing.detail.claim_id ??= action.claim_id
existing.detail.exchange_id ??= action.exchange_id
if (options?.addActionReferenceToObject) {
existing.actions ??= []
existing.actions.push(action)
}
}
export function unsetActionReference(existing, action) {
if (Array.isArray(existing?.actions)) {
existing.actions = existing.actions.filter((a) => a.id !== action.id)
}
}