feat(medusa): Add difference due to OrderEdit totals (#2352)
This commit is contained in:
@@ -120,6 +120,7 @@ export default class OrderEditService extends TransactionBaseService {
|
|||||||
discount_total: number
|
discount_total: number
|
||||||
tax_total: number | null
|
tax_total: number | null
|
||||||
subtotal: number
|
subtotal: number
|
||||||
|
difference_due: number
|
||||||
total: number
|
total: number
|
||||||
}> {
|
}> {
|
||||||
const manager = this.transactionManager_ ?? this.manager_
|
const manager = this.transactionManager_ ?? this.manager_
|
||||||
@@ -127,6 +128,7 @@ export default class OrderEditService extends TransactionBaseService {
|
|||||||
select: ["id", "order_id", "items"],
|
select: ["id", "order_id", "items"],
|
||||||
relations: ["items", "items.tax_lines", "items.adjustments"],
|
relations: ["items", "items.tax_lines", "items.adjustments"],
|
||||||
})
|
})
|
||||||
|
|
||||||
const order = await this.orderService_
|
const order = await this.orderService_
|
||||||
.withTransaction(manager)
|
.withTransaction(manager)
|
||||||
.retrieve(order_id, {
|
.retrieve(order_id, {
|
||||||
@@ -135,6 +137,9 @@ export default class OrderEditService extends TransactionBaseService {
|
|||||||
"discounts.rule",
|
"discounts.rule",
|
||||||
"gift_cards",
|
"gift_cards",
|
||||||
"region",
|
"region",
|
||||||
|
"items",
|
||||||
|
"items.tax_lines",
|
||||||
|
"items.adjustments",
|
||||||
"region.tax_rates",
|
"region.tax_rates",
|
||||||
"shipping_methods",
|
"shipping_methods",
|
||||||
"shipping_methods.tax_lines",
|
"shipping_methods.tax_lines",
|
||||||
@@ -152,6 +157,9 @@ export default class OrderEditService extends TransactionBaseService {
|
|||||||
const subtotal = await totalsServiceTx.getSubtotal(computedOrder)
|
const subtotal = await totalsServiceTx.getSubtotal(computedOrder)
|
||||||
const total = await totalsServiceTx.getTotal(computedOrder)
|
const total = await totalsServiceTx.getTotal(computedOrder)
|
||||||
|
|
||||||
|
const orderTotal = await totalsServiceTx.getTotal(order)
|
||||||
|
const difference_due = total - orderTotal
|
||||||
|
|
||||||
return {
|
return {
|
||||||
shipping_total,
|
shipping_total,
|
||||||
gift_card_total,
|
gift_card_total,
|
||||||
@@ -160,6 +168,7 @@ export default class OrderEditService extends TransactionBaseService {
|
|||||||
tax_total,
|
tax_total,
|
||||||
subtotal,
|
subtotal,
|
||||||
total,
|
total,
|
||||||
|
difference_due,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,6 +507,7 @@ export default class OrderEditService extends TransactionBaseService {
|
|||||||
orderEdit.subtotal = totals.subtotal
|
orderEdit.subtotal = totals.subtotal
|
||||||
orderEdit.tax_total = totals.tax_total
|
orderEdit.tax_total = totals.tax_total
|
||||||
orderEdit.total = totals.total
|
orderEdit.total = totals.total
|
||||||
|
orderEdit.difference_due = totals.difference_due
|
||||||
|
|
||||||
return orderEdit
|
return orderEdit
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user