feat(dashboard,core-flows,types,order): change order accepts price updates (#9476)
* chore: change order can accept price updates * chore: add changes to transformed order * chore: fix transform * chore: transform raw unit price
This commit is contained in:
@@ -13,6 +13,7 @@ OrderChangeProcessing.registerActionType(ChangeActionType.ITEM_UPDATE, {
|
||||
(item) => item.id === action.details.reference_id
|
||||
)
|
||||
|
||||
const unitPrice = action.details.unit_price
|
||||
const existing = currentOrder.items[existingIndex]
|
||||
|
||||
existing.detail.quantity ??= 0
|
||||
@@ -26,6 +27,13 @@ OrderChangeProcessing.registerActionType(ChangeActionType.ITEM_UPDATE, {
|
||||
existing.quantity = quant
|
||||
existing.detail.quantity = quant
|
||||
|
||||
if (unitPrice) {
|
||||
const unitPriceBN = new BigNumber(unitPrice)
|
||||
|
||||
existing.unit_price = unitPriceBN
|
||||
existing.detail.unit_price = unitPriceBN
|
||||
}
|
||||
|
||||
setActionReference(existing, action, options)
|
||||
|
||||
return MathBN.mult(existing.unit_price, quantityDiff)
|
||||
|
||||
@@ -57,6 +57,7 @@ export function applyChangesToOrder(
|
||||
order_id: order.id,
|
||||
version,
|
||||
quantity: orderItem.quantity,
|
||||
unit_price: item.unit_price ?? orderItem.unit_price,
|
||||
fulfilled_quantity: orderItem.fulfilled_quantity ?? 0,
|
||||
delivered_quantity: orderItem.delivered_quantity ?? 0,
|
||||
shipped_quantity: orderItem.shipped_quantity ?? 0,
|
||||
|
||||
@@ -46,6 +46,8 @@ export function formatOrder<T = any>(
|
||||
...orderItem.item,
|
||||
quantity: detail.quantity,
|
||||
raw_quantity: detail.raw_quantity,
|
||||
unit_price: detail.unit_price ?? orderItem.item.unit_price,
|
||||
raw_unit_price: detail.raw_unit_price ?? orderItem.item.raw_unit_price,
|
||||
detail,
|
||||
}
|
||||
})
|
||||
@@ -247,6 +249,11 @@ export function mapRepositoryToOrderModel(config, isRelatedEntity = false) {
|
||||
delete conf.where.items.item.quantity
|
||||
}
|
||||
|
||||
if (original.unit_price) {
|
||||
conf.where.items.unit_price = original.unit_price
|
||||
delete conf.where.items.item.unit_price
|
||||
}
|
||||
|
||||
if (original.detail) {
|
||||
conf.where.items = {
|
||||
...original.detail,
|
||||
|
||||
Reference in New Issue
Block a user