mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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;
|
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