mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE): adding 4 input scenario marketing type
This commit is contained in:
@@ -15,7 +15,7 @@ export type MarketingFormValues = {
|
||||
total_price?: string | number;
|
||||
marketing_type?: { value: string; label: string } | null;
|
||||
convertion_unit?: { value: string; label: string } | null;
|
||||
weeks?: { value: number; label: string } | null;
|
||||
week?: { value?: number; label?: string } | null;
|
||||
weight_per_convertion?: number | null;
|
||||
price_per_convertion?: number | null;
|
||||
total_peti?: number | null;
|
||||
@@ -100,7 +100,7 @@ export const calculateAyamPullet = (
|
||||
): void => {
|
||||
const { values, setFieldValue } = ctx;
|
||||
const unitPrice = Number(values.unit_price || 0);
|
||||
const weeks = Number(values.weeks?.value || 0);
|
||||
const week = Number(values.week?.value || 0);
|
||||
const qty = Number(values.qty || 0);
|
||||
const avgWeight = Number(values.avg_weight || 0);
|
||||
const totalWeight = Number(values.total_weight || 0);
|
||||
@@ -108,11 +108,11 @@ export const calculateAyamPullet = (
|
||||
|
||||
switch (field) {
|
||||
case 'unit_price':
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'qty': {
|
||||
// total_price = unit_price × weeks × qty
|
||||
if (unitPrice > 0 && weeks > 0 && qty > 0) {
|
||||
setFieldValue('total_price', roundPrice(unitPrice * weeks * qty));
|
||||
// total_price = unit_price × week × qty
|
||||
if (unitPrice > 0 && week > 0 && qty > 0) {
|
||||
setFieldValue('total_price', roundPrice(unitPrice * week * qty));
|
||||
}
|
||||
// total_weight = avg_weight × qty
|
||||
if (avgWeight > 0 && qty > 0) {
|
||||
@@ -133,9 +133,9 @@ export const calculateAyamPullet = (
|
||||
break;
|
||||
}
|
||||
case 'total_price': {
|
||||
// Reverse: unit_price = total_price / (weeks × qty)
|
||||
if (totalPrice > 0 && weeks > 0 && qty > 0) {
|
||||
setFieldValue('unit_price', roundPrice(totalPrice / (weeks * qty)));
|
||||
// Reverse: unit_price = total_price / (week × qty)
|
||||
if (totalPrice > 0 && week > 0 && qty > 0) {
|
||||
setFieldValue('unit_price', roundPrice(totalPrice / (week * qty)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user