mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
fix: calculate unit price by weight
This commit is contained in:
@@ -235,10 +235,8 @@ export const calculateTelurPeti = (
|
||||
const totalPrice = pricePerConvertion * totalPeti + priceSisaBerat;
|
||||
setFieldValue('total_price', totalPrice);
|
||||
// Recalculate unit_price = total_price / total_weight
|
||||
|
||||
// TODO: consider sisa berat later
|
||||
const totalWeight = weightPerConvertion * totalPeti + sisaBerat;
|
||||
updateUnitPrice(totalPrice, totalPeti);
|
||||
updateUnitPrice(totalPrice, totalWeight);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -257,8 +255,8 @@ export const calculateTelurPeti = (
|
||||
if (pricePerConvertion > 0 && totalPeti > 0) {
|
||||
const totalPrice = pricePerConvertion * totalPeti + priceSisaBerat;
|
||||
setFieldValue('total_price', totalPrice);
|
||||
// Recalculate unit_price = total_price / total_peti
|
||||
updateUnitPrice(totalPrice, totalPeti);
|
||||
// Recalculate unit_price = total_price / totalWeight
|
||||
updateUnitPrice(totalPrice, totalWeight);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -317,6 +315,15 @@ export const calculateTelurPeti = (
|
||||
updateUnitPrice(totalPrice, totalWeight);
|
||||
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