feat(order): receive return and additional calculations (#7314)
This commit is contained in:
committed by
GitHub
parent
d680c7ee4c
commit
4ef70d37bf
@@ -96,14 +96,14 @@ describe("Order Exchange - Actions", function () {
|
||||
|
||||
const sumToJSON = JSON.parse(JSON.stringify(changes.summary))
|
||||
expect(sumToJSON).toEqual({
|
||||
transactionTotal: 0,
|
||||
originalOrderTotal: 270,
|
||||
currentOrderTotal: 312.5,
|
||||
temporaryDifference: 62.5,
|
||||
futureDifference: 0,
|
||||
futureTemporaryDifference: 0,
|
||||
pendingDifference: 312.5,
|
||||
differenceSum: 42.5,
|
||||
transaction_total: 0,
|
||||
original_order_total: 270,
|
||||
current_order_total: 312.5,
|
||||
temporary_difference: 62.5,
|
||||
future_difference: 0,
|
||||
future_temporary_difference: 0,
|
||||
pending_difference: 312.5,
|
||||
difference_sum: 42.5,
|
||||
})
|
||||
|
||||
const toJson = JSON.parse(JSON.stringify(changes.order.items))
|
||||
|
||||
@@ -2238,8 +2238,8 @@ export default class OrderModuleService<
|
||||
return {
|
||||
action: ChangeActionType.RETURN_ITEM,
|
||||
internal_note: item.internal_note,
|
||||
reference: data.reference,
|
||||
reference_id: shippingMethodId,
|
||||
reference: data.reference ?? "fulfillment",
|
||||
reference_id: data.reference_id ?? shippingMethodId,
|
||||
details: {
|
||||
reference_id: item.id,
|
||||
quantity: item.quantity,
|
||||
@@ -2251,8 +2251,8 @@ export default class OrderModuleService<
|
||||
if (shippingMethodId) {
|
||||
actions.push({
|
||||
action: ChangeActionType.SHIPPING_ADD,
|
||||
reference: data.reference,
|
||||
reference_id: shippingMethodId,
|
||||
reference: data.reference ?? "fulfillment",
|
||||
reference_id: data.reference_id ?? shippingMethodId,
|
||||
amount: calculatedAmount.total,
|
||||
})
|
||||
}
|
||||
@@ -2544,4 +2544,37 @@ export default class OrderModuleService<
|
||||
|
||||
return await this.returnReasonService_.update(toUpdate, sharedContext)
|
||||
}
|
||||
|
||||
public async receiveReturn(
|
||||
data: OrderTypes.ReceiveOrderReturnDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<void> {
|
||||
const items = data.items.map((item) => {
|
||||
return {
|
||||
action: ChangeActionType.RECEIVE_RETURN_ITEM,
|
||||
internal_note: item.internal_note,
|
||||
reference: data.reference,
|
||||
reference_id: data.reference_id,
|
||||
details: {
|
||||
reference_id: item.id,
|
||||
quantity: item.quantity,
|
||||
metadata: item.metadata,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
const change = await this.createOrderChange_(
|
||||
{
|
||||
order_id: data.order_id,
|
||||
description: data.description,
|
||||
internal_note: data.internal_note,
|
||||
created_by: data.created_by,
|
||||
metadata: data.metadata,
|
||||
actions: items,
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
|
||||
await this.confirmOrderChange(change[0].id, sharedContext)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user