feat(order,dashboard): version order credit lines (#13766)

* feat(): version order credit lines

* undo last change

* adjust where

* remove date on ui

* Create five-donuts-obey.md

* add test

* nit comment

* woops
This commit is contained in:
William Bouchard
2025-10-22 04:26:05 -04:00
committed by GitHub
parent bad0858348
commit fe4e7481a9
9 changed files with 206 additions and 55 deletions

View File

@@ -3116,6 +3116,21 @@ export default class OrderModuleService
this.orderShippingService_.softDelete(orderShippingIds, sharedContext)
)
// Order Credit Lines
const orderCreditLines = await this.orderCreditLineService_.list(
{
order_id: order.id,
version: currentVersion,
},
{ select: ["id", "version"] },
sharedContext
)
const orderCreditLineIds = orderCreditLines.map((cl) => cl.id)
updatePromises.push(
this.orderCreditLineService_.softDelete(orderCreditLineIds, sharedContext)
)
// Order
updatePromises.push(
this.orderService_.update(
@@ -3220,6 +3235,21 @@ export default class OrderModuleService
this.orderShippingService_.softDelete(orderShippingIds, sharedContext)
)
// Order Credit Lines
const orderCreditLines = await this.orderCreditLineService_.list(
{
order_id: order.id,
version: currentVersion,
},
{ select: ["id", "version"] },
sharedContext
)
const orderCreditLineIds = orderCreditLines.map((cl) => cl.id)
updatePromises.push(
this.orderCreditLineService_.softDelete(orderCreditLineIds, sharedContext)
)
// Order
updatePromises.push(
this.orderService_.update(
@@ -3487,7 +3517,7 @@ export default class OrderModuleService
shippingMethodsToUpsert,
summariesToUpsert,
orderToUpdate,
creditLinesToCreate,
creditLinesToUpsert,
} = await applyChangesToOrder(orders, actionsMap, {
addActionReferenceToObject: true,
includeTaxLinesAndAdjustementsToPreview: async (...args) => {
@@ -3505,7 +3535,7 @@ export default class OrderModuleService
orderItems,
_orderSummaryUpdate,
orderShippingMethods,
createdOrderCreditLines,
orderCreditLines,
] = await promiseAll([
orderToUpdate.length
? this.orderService_.update(orderToUpdate, sharedContext)
@@ -3525,9 +3555,9 @@ export default class OrderModuleService
sharedContext
)
: null,
creditLinesToCreate.length
? this.orderCreditLineService_.create(
creditLinesToCreate,
creditLinesToUpsert.length
? this.orderCreditLineService_.upsert(
creditLinesToUpsert,
sharedContext
)
: null,
@@ -3536,7 +3566,7 @@ export default class OrderModuleService
return {
items: orderItems ?? [],
shipping_methods: orderShippingMethods ?? [],
credit_lines: createdOrderCreditLines ?? ([] as any),
credit_lines: orderCreditLines ?? ([] as any),
}
}