mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
fix: adjust DeliveryProductToFieldValues and mergeSOwithDO return values
This commit is contained in:
@@ -144,15 +144,15 @@ export const DeliveryProductToFieldValues = (
|
|||||||
delivery: BaseDeliveryOrder
|
delivery: BaseDeliveryOrder
|
||||||
): DeliveryOrderProductFormValues[] => {
|
): DeliveryOrderProductFormValues[] => {
|
||||||
const data = delivery.deliveries.map((item) => {
|
const data = delivery.deliveries.map((item) => {
|
||||||
const soId = salesOrders.find(
|
const salesOrder = salesOrders.find(
|
||||||
(so) => so.product_warehouse.id === item.product_warehouse.id
|
(so) => so.product_warehouse.id === item.product_warehouse.id
|
||||||
)?.id;
|
);
|
||||||
const warehouseOption = {
|
const warehouseOption = {
|
||||||
value: item.product_warehouse.warehouse.id,
|
value: item.product_warehouse.warehouse.id,
|
||||||
label: item.product_warehouse.warehouse.name,
|
label: item.product_warehouse.warehouse.name,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
id: soId,
|
id: salesOrder?.id,
|
||||||
unit_price: item.unit_price,
|
unit_price: item.unit_price,
|
||||||
total_weight: item.total_weight,
|
total_weight: item.total_weight,
|
||||||
qty: item.qty,
|
qty: item.qty,
|
||||||
@@ -161,9 +161,21 @@ export const DeliveryProductToFieldValues = (
|
|||||||
vehicle_number: item.vehicle_number,
|
vehicle_number: item.vehicle_number,
|
||||||
delivery_date: formatDate(delivery.delivery_date, 'yyyy-MM-DD'),
|
delivery_date: formatDate(delivery.delivery_date, 'yyyy-MM-DD'),
|
||||||
do_number: delivery.do_number,
|
do_number: delivery.do_number,
|
||||||
marketing_product_id: soId,
|
marketing_product_id: salesOrder?.id,
|
||||||
|
marketing_type: salesOrder?.marketing_type
|
||||||
|
? {
|
||||||
|
value: salesOrder?.marketing_type,
|
||||||
|
label: formatTitleCase(salesOrder?.marketing_type),
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
convertion_unit: salesOrder?.convertion_unit
|
||||||
|
? {
|
||||||
|
value: salesOrder?.convertion_unit.toLowerCase(),
|
||||||
|
label: formatTitleCase(salesOrder?.convertion_unit),
|
||||||
|
}
|
||||||
|
: null,
|
||||||
marketing_product: {
|
marketing_product: {
|
||||||
id: soId,
|
id: salesOrder?.id,
|
||||||
vehicle_number: item.vehicle_number,
|
vehicle_number: item.vehicle_number,
|
||||||
warehouse_id: item.product_warehouse.warehouse.id,
|
warehouse_id: item.product_warehouse.warehouse.id,
|
||||||
warehouse: warehouseOption,
|
warehouse: warehouseOption,
|
||||||
@@ -183,6 +195,7 @@ export const DeliveryProductToFieldValues = (
|
|||||||
},
|
},
|
||||||
} as DeliveryOrderProductFormValues;
|
} as DeliveryOrderProductFormValues;
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
export const mergeSOwithDO = (
|
export const mergeSOwithDO = (
|
||||||
@@ -214,30 +227,30 @@ export const mergeSOwithDO = (
|
|||||||
delivery_date: delivery?.delivery_date || undefined,
|
delivery_date: delivery?.delivery_date || undefined,
|
||||||
do_number: delivery?.do_number || undefined,
|
do_number: delivery?.do_number || undefined,
|
||||||
vehicle_number: delivery?.vehicle_number || so.vehicle_number,
|
vehicle_number: delivery?.vehicle_number || so.vehicle_number,
|
||||||
unit_price: autofill ? salesOrderUnitPrice : delivery?.unit_price,
|
unit_price: autofill ? delivery?.unit_price : salesOrderUnitPrice,
|
||||||
total_weight: autofill ? so.total_weight : delivery?.total_weight,
|
total_weight: autofill ? delivery?.total_weight : so.total_weight,
|
||||||
qty: autofill ? so.qty : delivery?.qty,
|
qty: autofill ? delivery?.qty : so.qty,
|
||||||
avg_weight: autofill ? so.avg_weight : delivery?.avg_weight,
|
avg_weight: autofill ? delivery?.avg_weight : so.avg_weight,
|
||||||
total_price: autofill ? so.total_price : delivery?.total_price,
|
total_price: autofill ? delivery?.total_price : so.total_price,
|
||||||
marketing_product: so, // jika ada, override
|
marketing_product: so, // jika ada, override
|
||||||
uom: autofill ? so.uom : delivery?.uom,
|
uom: autofill ? delivery?.uom : so.uom,
|
||||||
weight_per_convertion: autofill
|
weight_per_convertion: autofill
|
||||||
? so.weight_per_convertion
|
? delivery?.weight_per_convertion
|
||||||
: delivery?.weight_per_convertion,
|
: so.weight_per_convertion,
|
||||||
price_per_convertion: autofill
|
price_per_convertion: autofill
|
||||||
? so.price_per_convertion
|
? delivery?.price_per_convertion
|
||||||
: delivery?.price_per_convertion,
|
: so.price_per_convertion,
|
||||||
convertion_unit: autofill
|
convertion_unit: autofill
|
||||||
? so.convertion_unit
|
? delivery?.convertion_unit
|
||||||
: delivery?.convertion_unit,
|
: so.convertion_unit,
|
||||||
marketing_type: autofill ? so.marketing_type : delivery?.marketing_type,
|
marketing_type: autofill ? delivery?.marketing_type : so.marketing_type,
|
||||||
total_peti: autofill ? so.total_peti : delivery?.total_peti,
|
total_peti: autofill ? delivery?.total_peti : so.total_peti,
|
||||||
price_per_qty: autofill ? salesOrderPricePerQty : delivery?.price_per_qty,
|
price_per_qty: autofill ? delivery?.price_per_qty : salesOrderPricePerQty,
|
||||||
sisa_berat: autofill ? so.sisa_berat : delivery?.sisa_berat,
|
sisa_berat: autofill ? delivery?.sisa_berat : so.sisa_berat,
|
||||||
price_sisa_berat: autofill
|
price_sisa_berat: autofill
|
||||||
? so.price_sisa_berat
|
? delivery?.price_sisa_berat
|
||||||
: delivery?.price_sisa_berat,
|
: so.price_sisa_berat,
|
||||||
week: autofill ? so.week : delivery?.week,
|
week: autofill ? delivery?.week : so.week,
|
||||||
} as DeliveryOrderProductFormValues;
|
} as DeliveryOrderProductFormValues;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user