mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'fix/marketing-delivery-order' into 'development'
[FIX/FE] Marketing Delivery Order See merge request mbugroup/lti-web-client!385
This commit is contained in:
@@ -151,6 +151,25 @@ export const DeliveryProductToFieldValues = (
|
|||||||
value: item.product_warehouse.warehouse.id,
|
value: item.product_warehouse.warehouse.id,
|
||||||
label: item.product_warehouse.warehouse.name,
|
label: item.product_warehouse.warehouse.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const initialSisaBerat =
|
||||||
|
item?.total_weight &&
|
||||||
|
salesOrder?.weight_per_convertion &&
|
||||||
|
salesOrder?.total_peti
|
||||||
|
? Number(item.total_weight) -
|
||||||
|
Number(salesOrder.weight_per_convertion) *
|
||||||
|
Number(salesOrder.total_peti)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
const initialPricePerConvertion =
|
||||||
|
item?.total_price &&
|
||||||
|
salesOrder?.total_peti &&
|
||||||
|
Number(salesOrder.total_peti) !== 0
|
||||||
|
? (Number(item.total_price) -
|
||||||
|
initialSisaBerat * Number(item.unit_price || 0)) /
|
||||||
|
Number(salesOrder.total_peti)
|
||||||
|
: Number(item?.unit_price || 0);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: salesOrder?.id,
|
id: salesOrder?.id,
|
||||||
unit_price: item.unit_price,
|
unit_price: item.unit_price,
|
||||||
@@ -193,6 +212,9 @@ export const DeliveryProductToFieldValues = (
|
|||||||
avg_weight: item.avg_weight,
|
avg_weight: item.avg_weight,
|
||||||
total_price: item.total_price,
|
total_price: item.total_price,
|
||||||
},
|
},
|
||||||
|
total_peti: salesOrder?.total_peti,
|
||||||
|
weight_per_convertion: salesOrder?.weight_per_convertion,
|
||||||
|
price_per_convertion: initialPricePerConvertion,
|
||||||
} as DeliveryOrderProductFormValues;
|
} as DeliveryOrderProductFormValues;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+12
-13
@@ -126,18 +126,14 @@ const DeliveryOrderProductForm = ({
|
|||||||
Number(initialValues.total_peti)
|
Number(initialValues.total_peti)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
// const initialPricePerConvertion =
|
const initialPricePerConvertion =
|
||||||
// initialValues?.total_price &&
|
initialValues?.total_price &&
|
||||||
// initialValues?.total_peti &&
|
initialValues?.total_peti &&
|
||||||
// Number(initialValues.total_peti) !== 0
|
Number(initialValues.total_peti) !== 0
|
||||||
// ? (Number(initialValues.total_price) -
|
? (Number(initialValues.total_price) -
|
||||||
// initialSisaBerat * Number(initialValues.unit_price || 0)) /
|
initialSisaBerat * Number(initialValues.unit_price || 0)) /
|
||||||
// Number(initialValues.total_peti)
|
Number(initialValues.total_peti)
|
||||||
// : 0;
|
: Number(initialValues?.unit_price || 0);
|
||||||
|
|
||||||
const initialPricePerConvertion = initialValues?.unit_price
|
|
||||||
? Number(initialValues?.unit_price)
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
const initialPriceSisaBerat =
|
const initialPriceSisaBerat =
|
||||||
initialValues?.total_price && initialValues?.total_peti
|
initialValues?.total_price && initialValues?.total_peti
|
||||||
@@ -728,7 +724,7 @@ const DeliveryOrderProductForm = ({
|
|||||||
placeholder='Masukan Total Peti'
|
placeholder='Masukan Total Peti'
|
||||||
endAdornment={
|
endAdornment={
|
||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<span className='text-sm text-base-content/50'>Kg</span>
|
<span className='text-sm text-base-content/50'>Peti</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
bottomLabel={`1 ${formik.values.convertion_unit?.value.toLowerCase()} = ${formik.values.weight_per_convertion ?? 0} Kg`}
|
bottomLabel={`1 ${formik.values.convertion_unit?.value.toLowerCase()} = ${formik.values.weight_per_convertion ?? 0} Kg`}
|
||||||
@@ -778,6 +774,9 @@ const DeliveryOrderProductForm = ({
|
|||||||
}
|
}
|
||||||
errorMessage={formik.errors.total_weight}
|
errorMessage={formik.errors.total_weight}
|
||||||
placeholder='Masukan Total Bobot'
|
placeholder='Masukan Total Bobot'
|
||||||
|
disabled={
|
||||||
|
formik.values.convertion_unit?.value.toLowerCase() === 'peti'
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
+12
-13
@@ -61,18 +61,14 @@ const SalesOrderProductForm = ({
|
|||||||
Number(initialValues.total_peti)
|
Number(initialValues.total_peti)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
// const initialPricePerConvertion =
|
const initialPricePerConvertion =
|
||||||
// initialValues?.total_price &&
|
initialValues?.total_price &&
|
||||||
// initialValues?.total_peti &&
|
initialValues?.total_peti &&
|
||||||
// Number(initialValues.total_peti) !== 0
|
Number(initialValues.total_peti) !== 0
|
||||||
// ? (Number(initialValues.total_price) -
|
? (Number(initialValues.total_price) -
|
||||||
// initialSisaBerat * Number(initialValues.unit_price || 0)) /
|
initialSisaBerat * Number(initialValues.unit_price || 0)) /
|
||||||
// Number(initialValues.total_peti)
|
Number(initialValues.total_peti)
|
||||||
// : 0;
|
: Number(initialValues?.unit_price || 0);
|
||||||
|
|
||||||
const initialPricePerConvertion = initialValues?.unit_price
|
|
||||||
? Number(initialValues?.unit_price)
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
const isInitialTelurQty =
|
const isInitialTelurQty =
|
||||||
initialValues?.marketing_type?.value?.toLowerCase() === 'telur' &&
|
initialValues?.marketing_type?.value?.toLowerCase() === 'telur' &&
|
||||||
@@ -624,7 +620,7 @@ const SalesOrderProductForm = ({
|
|||||||
placeholder='Masukan Total Peti'
|
placeholder='Masukan Total Peti'
|
||||||
endAdornment={
|
endAdornment={
|
||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<span className='text-sm text-base-content/50'>Kg</span>
|
<span className='text-sm text-base-content/50'>Peti</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
bottomLabel={`1 ${formik.values.convertion_unit?.value.toLowerCase()} = ${formik.values.weight_per_convertion ?? 0} Kg`}
|
bottomLabel={`1 ${formik.values.convertion_unit?.value.toLowerCase()} = ${formik.values.weight_per_convertion ?? 0} Kg`}
|
||||||
@@ -674,6 +670,9 @@ const SalesOrderProductForm = ({
|
|||||||
}
|
}
|
||||||
errorMessage={formik.errors.total_weight}
|
errorMessage={formik.errors.total_weight}
|
||||||
placeholder='Masukan Total Bobot'
|
placeholder='Masukan Total Bobot'
|
||||||
|
disabled={
|
||||||
|
formik.values.convertion_unit?.value.toLowerCase() === 'peti'
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -141,12 +141,15 @@ const DeliveryOrderProductTable = ({
|
|||||||
<tr>
|
<tr>
|
||||||
<td className='text-sm px-4 py-3'>Total Bobot</td>
|
<td className='text-sm px-4 py-3'>Total Bobot</td>
|
||||||
<td className='text-sm px-4 py-3'>
|
<td className='text-sm px-4 py-3'>
|
||||||
{formatNumber(Number(item.total_weight))}
|
{formatNumber(Number(item.total_weight))} Kg
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
<tr>
|
<tr>
|
||||||
<td className='text-sm px-4 py-3'>Total Harga Satuan</td>
|
<td className='text-sm px-4 py-3'>
|
||||||
|
Total Harga Satuan
|
||||||
|
{item.convertion_unit?.label.toLowerCase() === 'peti' && ' (Kg)'}
|
||||||
|
</td>
|
||||||
<td className='text-sm px-4 py-3'>
|
<td className='text-sm px-4 py-3'>
|
||||||
{formatCurrency(parseFloat(item.unit_price as string))}
|
{formatCurrency(parseFloat(item.unit_price as string))}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -137,8 +137,22 @@ const SalesOrderProductTable = ({
|
|||||||
{`${formatNumber(parseFloat(item.qty as string))} ${item.uom || ''}`}
|
{`${formatNumber(parseFloat(item.qty as string))} ${item.uom || ''}`}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{item.convertion_unit?.value.toLowerCase() === 'peti' && (
|
||||||
<tr>
|
<tr>
|
||||||
<td className='text-sm px-4 py-3'>Harga Satuan</td>
|
<td className='text-sm px-4 py-3'>Harga Satuan Per Peti</td>
|
||||||
|
<td className='text-sm px-4 py-3'>
|
||||||
|
{formatCurrency(
|
||||||
|
parseFloat(item.unit_price as string) *
|
||||||
|
parseFloat(String(item.weight_per_convertion))
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
<tr>
|
||||||
|
<td className='text-sm px-4 py-3'>
|
||||||
|
Harga Satuan
|
||||||
|
{item.convertion_unit?.value.toLowerCase() === 'peti' && ' (Kg)'}
|
||||||
|
</td>
|
||||||
<td className='text-sm px-4 py-3'>
|
<td className='text-sm px-4 py-3'>
|
||||||
{formatCurrency(parseFloat(item.unit_price as string))}
|
{formatCurrency(parseFloat(item.unit_price as string))}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -235,10 +235,8 @@ export const calculateTelurPeti = (
|
|||||||
const totalPrice = pricePerConvertion * totalPeti + priceSisaBerat;
|
const totalPrice = pricePerConvertion * totalPeti + priceSisaBerat;
|
||||||
setFieldValue('total_price', totalPrice);
|
setFieldValue('total_price', totalPrice);
|
||||||
// Recalculate unit_price = total_price / total_weight
|
// Recalculate unit_price = total_price / total_weight
|
||||||
|
|
||||||
// TODO: consider sisa berat later
|
|
||||||
const totalWeight = weightPerConvertion * totalPeti + sisaBerat;
|
const totalWeight = weightPerConvertion * totalPeti + sisaBerat;
|
||||||
updateUnitPrice(totalPrice, totalPeti);
|
updateUnitPrice(totalPrice, totalWeight);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -257,8 +255,8 @@ export const calculateTelurPeti = (
|
|||||||
if (pricePerConvertion > 0 && totalPeti > 0) {
|
if (pricePerConvertion > 0 && totalPeti > 0) {
|
||||||
const totalPrice = pricePerConvertion * totalPeti + priceSisaBerat;
|
const totalPrice = pricePerConvertion * totalPeti + priceSisaBerat;
|
||||||
setFieldValue('total_price', totalPrice);
|
setFieldValue('total_price', totalPrice);
|
||||||
// Recalculate unit_price = total_price / total_peti
|
// Recalculate unit_price = total_price / totalWeight
|
||||||
updateUnitPrice(totalPrice, totalPeti);
|
updateUnitPrice(totalPrice, totalWeight);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -317,6 +315,15 @@ export const calculateTelurPeti = (
|
|||||||
updateUnitPrice(totalPrice, totalWeight);
|
updateUnitPrice(totalPrice, totalWeight);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'qty':
|
||||||
|
// Recalculate avg_weight = total_weight / qty
|
||||||
|
if (qty > 0 && values.total_weight) {
|
||||||
|
setFieldValue(
|
||||||
|
'avg_weight',
|
||||||
|
preciseWeight(Number(values.total_weight) / qty)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user