mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix: prioritize DO data if delivery orders exist
This commit is contained in:
@@ -203,6 +203,8 @@ export const mergeSOwithDO = (
|
||||
deliveryOrders: DeliveryOrderProductFormValues[],
|
||||
autofill?: boolean
|
||||
): DeliveryOrderProductFormValues[] => {
|
||||
const hasDeliveryOrders = deliveryOrders.length > 0;
|
||||
|
||||
return salesOrders.map((so) => {
|
||||
const delivery = deliveryOrders.find(
|
||||
(d) => d?.marketing_product_id === so.id
|
||||
@@ -227,30 +229,50 @@ export const mergeSOwithDO = (
|
||||
delivery_date: delivery?.delivery_date || undefined,
|
||||
do_number: delivery?.do_number || undefined,
|
||||
vehicle_number: delivery?.vehicle_number || so.vehicle_number,
|
||||
unit_price: autofill ? delivery?.unit_price : salesOrderUnitPrice,
|
||||
total_weight: autofill ? delivery?.total_weight : so.total_weight,
|
||||
qty: autofill ? delivery?.qty : so.qty,
|
||||
avg_weight: autofill ? delivery?.avg_weight : so.avg_weight,
|
||||
total_price: autofill ? delivery?.total_price : so.total_price,
|
||||
unit_price:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.unit_price
|
||||
: salesOrderUnitPrice,
|
||||
total_weight:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.total_weight
|
||||
: so.total_weight,
|
||||
qty: autofill && hasDeliveryOrders ? delivery?.qty : so.qty,
|
||||
avg_weight:
|
||||
autofill && hasDeliveryOrders ? delivery?.avg_weight : so.avg_weight,
|
||||
total_price:
|
||||
autofill && hasDeliveryOrders ? delivery?.total_price : so.total_price,
|
||||
marketing_product: so, // jika ada, override
|
||||
uom: autofill ? delivery?.uom : so.uom,
|
||||
weight_per_convertion: autofill
|
||||
uom: autofill && hasDeliveryOrders ? delivery?.uom : so.uom,
|
||||
weight_per_convertion:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.weight_per_convertion
|
||||
: so.weight_per_convertion,
|
||||
price_per_convertion: autofill
|
||||
price_per_convertion:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.price_per_convertion
|
||||
: so.price_per_convertion,
|
||||
convertion_unit: autofill
|
||||
convertion_unit:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.convertion_unit
|
||||
: so.convertion_unit,
|
||||
marketing_type: autofill ? delivery?.marketing_type : so.marketing_type,
|
||||
total_peti: autofill ? delivery?.total_peti : so.total_peti,
|
||||
price_per_qty: autofill ? delivery?.price_per_qty : salesOrderPricePerQty,
|
||||
sisa_berat: autofill ? delivery?.sisa_berat : so.sisa_berat,
|
||||
price_sisa_berat: autofill
|
||||
marketing_type:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.marketing_type
|
||||
: so.marketing_type,
|
||||
total_peti:
|
||||
autofill && hasDeliveryOrders ? delivery?.total_peti : so.total_peti,
|
||||
price_per_qty:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.price_per_qty
|
||||
: salesOrderPricePerQty,
|
||||
sisa_berat:
|
||||
autofill && hasDeliveryOrders ? delivery?.sisa_berat : so.sisa_berat,
|
||||
price_sisa_berat:
|
||||
autofill && hasDeliveryOrders
|
||||
? delivery?.price_sisa_berat
|
||||
: so.price_sisa_berat,
|
||||
week: autofill ? delivery?.week : so.week,
|
||||
week: autofill && hasDeliveryOrders ? delivery?.week : so.week,
|
||||
} as DeliveryOrderProductFormValues;
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user