feat(order): bundled actions (#7133)
This commit is contained in:
committed by
GitHub
parent
e4898fb00d
commit
d02905cefa
@@ -1,5 +1,6 @@
|
||||
import { BigNumberInput, OrderSummaryDTO } from "@medusajs/types"
|
||||
import {
|
||||
BigNumber,
|
||||
MathBN,
|
||||
isDefined,
|
||||
transformPropertiesToBigNumber,
|
||||
@@ -61,8 +62,8 @@ export class OrderChangeProcessing {
|
||||
pendingDifference: 0,
|
||||
futureTemporarySum: 0,
|
||||
differenceSum: 0,
|
||||
currentOrderTotal: this.order.summary?.total ?? 0,
|
||||
originalOrderTotal: this.order.summary?.total ?? 0,
|
||||
currentOrderTotal: this.order.total ?? 0,
|
||||
originalOrderTotal: this.order.total ?? 0,
|
||||
transactionTotal,
|
||||
}
|
||||
}
|
||||
@@ -344,14 +345,16 @@ export class OrderChangeProcessing {
|
||||
public getSummary(): OrderSummaryDTO {
|
||||
const summary = this.summary
|
||||
const orderSummary = {
|
||||
transactionTotal: summary.transactionTotal,
|
||||
originalOrderTotal: summary.originalOrderTotal,
|
||||
currentOrderTotal: summary.currentOrderTotal,
|
||||
temporaryDifference: summary.temporaryDifference,
|
||||
futureDifference: summary.futureDifference,
|
||||
futureTemporaryDifference: summary.futureTemporaryDifference,
|
||||
pendingDifference: summary.pendingDifference,
|
||||
differenceSum: summary.differenceSum,
|
||||
transactionTotal: new BigNumber(summary.transactionTotal),
|
||||
originalOrderTotal: new BigNumber(summary.originalOrderTotal),
|
||||
currentOrderTotal: new BigNumber(summary.currentOrderTotal),
|
||||
temporaryDifference: new BigNumber(summary.temporaryDifference),
|
||||
futureDifference: new BigNumber(summary.futureDifference),
|
||||
futureTemporaryDifference: new BigNumber(
|
||||
summary.futureTemporaryDifference
|
||||
),
|
||||
pendingDifference: new BigNumber(summary.pendingDifference),
|
||||
differenceSum: new BigNumber(summary.differenceSum),
|
||||
} as unknown as OrderSummaryDTO
|
||||
|
||||
/*
|
||||
|
||||
@@ -29,6 +29,19 @@ export function formatOrder(
|
||||
}
|
||||
})
|
||||
|
||||
order.shipping_methods = order.shipping_methods?.map((shippingMethod) => {
|
||||
const sm = { ...shippingMethod.shipping_method }
|
||||
|
||||
delete shippingMethod.shipping_method
|
||||
return {
|
||||
...sm,
|
||||
order_id: shippingMethod.order_id,
|
||||
detail: {
|
||||
...shippingMethod,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
order.summary = order.summary?.[0]?.totals
|
||||
|
||||
return options?.includeTotals
|
||||
@@ -58,6 +71,16 @@ export function mapRepositoryToOrderModel(config) {
|
||||
if (rel == "summary" && type === "fields") {
|
||||
obj.populate.push("summary")
|
||||
return "summary.totals"
|
||||
} else if (
|
||||
rel.includes("shipping_methods") &&
|
||||
!rel.includes("shipping_methods.shipping_method")
|
||||
) {
|
||||
obj.populate.push("shipping_methods.shipping_method")
|
||||
|
||||
return rel.replace(
|
||||
"shipping_methods",
|
||||
"shipping_methods.shipping_method"
|
||||
)
|
||||
} else if (rel.includes("items.detail")) {
|
||||
return rel.replace("items.detail", "items")
|
||||
} else if (rel == "items") {
|
||||
|
||||
Reference in New Issue
Block a user