Merge branch 'fix/marketing-delivery-order' into 'development'

[FIX/FE] Marketing Delivery Order

See merge request mbugroup/lti-web-client!384
This commit is contained in:
Rivaldi A N S
2026-04-09 09:38:58 +00:00
2 changed files with 47 additions and 25 deletions
@@ -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
? delivery?.weight_per_convertion
: so.weight_per_convertion,
price_per_convertion: autofill
? delivery?.price_per_convertion
: so.price_per_convertion,
convertion_unit: autofill
? 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
? delivery?.price_sisa_berat
: so.price_sisa_berat,
week: autofill ? delivery?.week : so.week,
uom: autofill && hasDeliveryOrders ? delivery?.uom : so.uom,
weight_per_convertion:
autofill && hasDeliveryOrders
? delivery?.weight_per_convertion
: so.weight_per_convertion,
price_per_convertion:
autofill && hasDeliveryOrders
? delivery?.price_per_convertion
: so.price_per_convertion,
convertion_unit:
autofill && hasDeliveryOrders
? delivery?.convertion_unit
: so.convertion_unit,
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 && hasDeliveryOrders ? delivery?.week : so.week,
} as DeliveryOrderProductFormValues;
});
};
@@ -85,7 +85,7 @@ const DeliveryOrderProductTable = ({
<th className='text-start font-medium text-base-content/50 text-sm px-4 py-3'>
<div className='flex w-full flex-row gap-1 items-center justify-between h-full'>
<div>Value</div>
{formType !== 'success' &&
{/* {formType !== 'success' &&
(formType === 'add_delivery' ||
formType === 'edit_delivery' ||
formType === 'detail') && (
@@ -102,7 +102,7 @@ const DeliveryOrderProductTable = ({
<Icon icon='heroicons:pencil' width={20} height={20} />
</Button>
</div>
)}
)} */}
</div>
</th>
</tr>