fix(order): summary original_total (#8616)
This commit is contained in:
committed by
GitHub
parent
9de9b3825f
commit
ba34c53151
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Context,
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderClaimDTO,
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import { ChangeActionType, promiseAll } from "@medusajs/utils"
|
||||
@@ -33,7 +34,7 @@ export async function cancelClaim(
|
||||
data: OrderTypes.CancelOrderClaimDTO,
|
||||
sharedContext?: Context
|
||||
) {
|
||||
const claimOrder = await this.retrieveOrderClaim(
|
||||
const claimOrder = (await this.retrieveOrderClaim(
|
||||
data.claim_id,
|
||||
{
|
||||
select: [
|
||||
@@ -50,7 +51,7 @@ export async function cancelClaim(
|
||||
relations: ["claim_items", "additional_items", "shipping_methods"],
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
)) as OrderClaimDTO
|
||||
|
||||
const actions: CreateOrderChangeActionDTO[] = []
|
||||
|
||||
@@ -88,7 +89,7 @@ export async function cancelClaim(
|
||||
claim_id: claimOrder.id,
|
||||
reference: "claim",
|
||||
reference_id: shipping.id,
|
||||
amount: shipping.price,
|
||||
amount: shipping.raw_amount ?? shipping.amount,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Context,
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderExchangeDTO,
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import { ChangeActionType, promiseAll } from "@medusajs/utils"
|
||||
@@ -33,7 +34,7 @@ export async function cancelExchange(
|
||||
data: OrderTypes.CancelOrderExchangeDTO,
|
||||
sharedContext?: Context
|
||||
) {
|
||||
const exchangeOrder = await this.retrieveOrderExchange(
|
||||
const exchangeOrder = (await this.retrieveOrderExchange(
|
||||
data.exchange_id,
|
||||
{
|
||||
select: [
|
||||
@@ -46,7 +47,7 @@ export async function cancelExchange(
|
||||
relations: ["additional_items", "shipping_methods"],
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
)) as OrderExchangeDTO
|
||||
|
||||
const actions: CreateOrderChangeActionDTO[] = []
|
||||
|
||||
@@ -73,7 +74,7 @@ export async function cancelExchange(
|
||||
exchange_id: exchangeOrder.id,
|
||||
reference: "exchange",
|
||||
reference_id: shipping.id,
|
||||
amount: shipping.price,
|
||||
amount: shipping.raw_amount ?? shipping.amount,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
Context,
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderTypes,
|
||||
ReturnDTO,
|
||||
} from "@medusajs/types"
|
||||
import { ChangeActionType, promiseAll } from "@medusajs/utils"
|
||||
|
||||
@@ -33,7 +34,7 @@ export async function cancelReturn(
|
||||
data: OrderTypes.CancelOrderReturnDTO,
|
||||
sharedContext?: Context
|
||||
) {
|
||||
const returnOrder = await this.retrieveReturn(
|
||||
const returnOrder = (await this.retrieveReturn(
|
||||
data.return_id,
|
||||
{
|
||||
select: [
|
||||
@@ -46,7 +47,7 @@ export async function cancelReturn(
|
||||
relations: ["items", "shipping_methods"],
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
)) as ReturnDTO
|
||||
|
||||
const actions: CreateOrderChangeActionDTO[] = []
|
||||
|
||||
@@ -71,7 +72,7 @@ export async function cancelReturn(
|
||||
return_id: returnOrder.id,
|
||||
reference: "return",
|
||||
reference_id: shipping.id,
|
||||
amount: shipping.price,
|
||||
amount: shipping.raw_amount ?? shipping.amount,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ export default class OrderModuleService<
|
||||
config.relations ??= []
|
||||
config.select ??= []
|
||||
|
||||
const requiredFieldsForTotals = [
|
||||
const requiredRelationsForTotals = [
|
||||
"items",
|
||||
"items.tax_lines",
|
||||
"items.adjustments",
|
||||
@@ -302,14 +302,15 @@ export default class OrderModuleService<
|
||||
"shipping_methods.tax_lines",
|
||||
"shipping_methods.adjustments",
|
||||
]
|
||||
|
||||
config.relations = deduplicate([
|
||||
...config.relations,
|
||||
...requiredFieldsForTotals,
|
||||
...requiredRelationsForTotals,
|
||||
])
|
||||
|
||||
config.select = config.select.filter((field) => {
|
||||
return (
|
||||
!requiredFieldsForTotals.some((val) =>
|
||||
!requiredRelationsForTotals.some((val) =>
|
||||
val.startsWith(field as string)
|
||||
) && !totalFields.includes(field)
|
||||
)
|
||||
@@ -2017,12 +2018,7 @@ export default class OrderModuleService<
|
||||
orderId,
|
||||
{
|
||||
select: ["id", "version", "items.detail", "summary", "total"],
|
||||
relations: [
|
||||
"transactions",
|
||||
"items",
|
||||
"items.detail",
|
||||
"shipping_methods",
|
||||
],
|
||||
relations: ["transactions", "items", "shipping_methods"],
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
@@ -2212,7 +2208,7 @@ export default class OrderModuleService<
|
||||
data: OrderTypes.ConfirmOrderChangeDTO[],
|
||||
sharedContext?: Context
|
||||
)
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
@InjectManager("baseRepository_")
|
||||
async confirmOrderChange(
|
||||
orderChangeIdOrData:
|
||||
| string
|
||||
@@ -2648,6 +2644,7 @@ export default class OrderModuleService<
|
||||
return Array.isArray(data) ? actions : actions[0]
|
||||
}
|
||||
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
private async applyOrderChanges_(
|
||||
changeActions: ApplyOrderChangeDTO[],
|
||||
sharedContext?: Context
|
||||
@@ -2683,7 +2680,7 @@ export default class OrderModuleService<
|
||||
}
|
||||
}
|
||||
|
||||
let orders = await super.listOrders(
|
||||
let orders = await this.listOrders(
|
||||
{ id: deduplicate(ordersIds) },
|
||||
{
|
||||
select: ["id", "version", "items.detail", "summary", "total"],
|
||||
@@ -2693,8 +2690,9 @@ export default class OrderModuleService<
|
||||
"items.detail",
|
||||
"shipping_methods",
|
||||
],
|
||||
},
|
||||
sharedContext
|
||||
}
|
||||
// sharedContext
|
||||
// TODO: investigate issue while using sharedContext in receive return action
|
||||
)
|
||||
orders = formatOrder(orders, {
|
||||
entity: Order,
|
||||
|
||||
Reference in New Issue
Block a user