fix(order): order change references (#8845)
This commit is contained in:
@@ -427,11 +427,11 @@ medusaIntegrationTestRunner({
|
|||||||
|
|
||||||
expect(orderResult.summary).toEqual(
|
expect(orderResult.summary).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
paid_total: 0,
|
paid_total: 61,
|
||||||
difference_sum: 0,
|
difference_sum: 0,
|
||||||
refunded_total: 0,
|
refunded_total: 0,
|
||||||
transaction_total: 0,
|
transaction_total: 61,
|
||||||
pending_difference: 61,
|
pending_difference: 0,
|
||||||
current_order_total: 61,
|
current_order_total: 61,
|
||||||
original_order_total: 61,
|
original_order_total: 61,
|
||||||
temporary_difference: 0,
|
temporary_difference: 0,
|
||||||
@@ -698,7 +698,7 @@ medusaIntegrationTestRunner({
|
|||||||
expect(paymentCollections[0]).toEqual(
|
expect(paymentCollections[0]).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
status: "not_paid",
|
status: "not_paid",
|
||||||
amount: 171.5,
|
amount: 110.5,
|
||||||
currency_code: "usd",
|
currency_code: "usd",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -742,7 +742,7 @@ medusaIntegrationTestRunner({
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("should create a payment collection successfully & mark as paid", async () => {
|
it("should create a payment collection successfully & mark as paid", async () => {
|
||||||
const paymentDelta = 171.5
|
const paymentDelta = 110.5
|
||||||
const orderForPayment = (
|
const orderForPayment = (
|
||||||
await api.get(`/admin/orders/${order.id}`, adminHeaders)
|
await api.get(`/admin/orders/${order.id}`, adminHeaders)
|
||||||
).data.order
|
).data.order
|
||||||
@@ -1093,7 +1093,7 @@ medusaIntegrationTestRunner({
|
|||||||
expect(result[0].canceled_at).toBeNull()
|
expect(result[0].canceled_at).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it.only("test inbound only", async () => {
|
it("test inbound only", async () => {
|
||||||
const orderCheck = (
|
const orderCheck = (
|
||||||
await api.get(`/admin/orders/${order.id}`, adminHeaders)
|
await api.get(`/admin/orders/${order.id}`, adminHeaders)
|
||||||
).data.order
|
).data.order
|
||||||
|
|||||||
@@ -223,23 +223,29 @@ export default class OrderChangeAction {
|
|||||||
onCreate() {
|
onCreate() {
|
||||||
this.id = generateEntityId(this.id, "ordchact")
|
this.id = generateEntityId(this.id, "ordchact")
|
||||||
this.order_id ??= this.order?.id ?? this.order_change?.order_id ?? null
|
this.order_id ??= this.order?.id ?? this.order_change?.order_id ?? null
|
||||||
this.return_id ??= this.return?.id ?? this.order_change?.return_id ?? null
|
|
||||||
this.claim_id ??= this.claim?.id ?? this.order_change?.claim_id ?? null
|
this.claim_id ??= this.claim?.id ?? this.order_change?.claim_id ?? null
|
||||||
this.exchange_id ??=
|
this.exchange_id ??=
|
||||||
this.exchange?.id ?? this.order_change?.exchange_id ?? null
|
this.exchange?.id ?? this.order_change?.exchange_id ?? null
|
||||||
this.order_change_id ??= this.order_change?.id ?? null
|
this.order_change_id ??= this.order_change?.id ?? null
|
||||||
this.version ??= this.order_change?.version ?? null
|
this.version ??= this.order_change?.version ?? null
|
||||||
|
|
||||||
|
if (!this.claim_id && !this.exchange_id) {
|
||||||
|
this.return_id ??= this.return?.id ?? this.order_change?.return_id ?? null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnInit()
|
@OnInit()
|
||||||
onInit() {
|
onInit() {
|
||||||
this.id = generateEntityId(this.id, "ordchact")
|
this.id = generateEntityId(this.id, "ordchact")
|
||||||
this.order_id ??= this.order?.id ?? this.order_change?.order_id ?? null
|
this.order_id ??= this.order?.id ?? this.order_change?.order_id ?? null
|
||||||
this.return_id ??= this.return?.id ?? this.order_change?.return_id ?? null
|
|
||||||
this.claim_id ??= this.claim?.id ?? this.order_change?.claim_id ?? null
|
this.claim_id ??= this.claim?.id ?? this.order_change?.claim_id ?? null
|
||||||
this.exchange_id ??=
|
this.exchange_id ??=
|
||||||
this.exchange?.id ?? this.order_change?.exchange_id ?? null
|
this.exchange?.id ?? this.order_change?.exchange_id ?? null
|
||||||
this.order_change_id ??= this.order_change?.id ?? null
|
this.order_change_id ??= this.order_change?.id ?? null
|
||||||
this.version ??= this.order_change?.version ?? null
|
this.version ??= this.order_change?.version ?? null
|
||||||
|
|
||||||
|
if (!this.claim_id && !this.exchange_id) {
|
||||||
|
this.return_id ??= this.return?.id ?? this.order_change?.return_id ?? null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2034,17 +2034,6 @@ export default class OrderModuleService<
|
|||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
orderChange.actions = orderChange.actions.map((action) => {
|
|
||||||
return {
|
|
||||||
...action,
|
|
||||||
version: orderChange.version,
|
|
||||||
order_id: orderChange.order_id,
|
|
||||||
return_id: orderChange.return_id,
|
|
||||||
claim_id: orderChange.claim_id,
|
|
||||||
exchange_id: orderChange.exchange_id,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const { itemsToUpsert, shippingMethodsToUpsert, calculatedOrders } =
|
const { itemsToUpsert, shippingMethodsToUpsert, calculatedOrders } =
|
||||||
applyChangesToOrder(
|
applyChangesToOrder(
|
||||||
[order],
|
[order],
|
||||||
@@ -2243,16 +2232,6 @@ export default class OrderModuleService<
|
|||||||
await this.orderChangeService_.update(updates as any, sharedContext)
|
await this.orderChangeService_.update(updates as any, sharedContext)
|
||||||
|
|
||||||
const orderChanges = orderChange.map((change) => {
|
const orderChanges = orderChange.map((change) => {
|
||||||
change.actions = change.actions.map((action) => {
|
|
||||||
return {
|
|
||||||
...action,
|
|
||||||
version: change.version,
|
|
||||||
order_id: change.order_id,
|
|
||||||
return_id: change.return_id,
|
|
||||||
claim_id: change.claim_id,
|
|
||||||
exchange_id: change.exchange_id,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return change.actions
|
return change.actions
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user