From 617a4e23e06743b8c286dd8e0f0c4e27dbdc01d2 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Wed, 29 Nov 2023 11:13:16 +0530 Subject: [PATCH] Convert the unit from grams to kg in inventory form --- src/Components/Facility/AddInventoryForm.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Components/Facility/AddInventoryForm.tsx b/src/Components/Facility/AddInventoryForm.tsx index df217cad3ec..9e4f761b550 100644 --- a/src/Components/Facility/AddInventoryForm.tsx +++ b/src/Components/Facility/AddInventoryForm.tsx @@ -146,7 +146,7 @@ export const AddInventoryForm = (props: any) => { if (unitName === "Dozen") { return Number(unitData.quantity) * 12; } - if (unitName === "Gram") { + if (unitName === "gram") { return Number(unitData.quantity) / 1000; } return Number(unitData.quantity); @@ -238,6 +238,11 @@ export const AddInventoryForm = (props: any) => { }; // if user has selected "Add stock" or "stockValidation" function is true if (data.is_incoming || stockValidation(data)) { + // if user has selected grams as unit then convert it to kg + if (data.unit === 5) { + data.quantity = data.quantity / 1000; + data.unit = 6; + } const res = await dispatchAction(postInventory(data, { facilityId })); setIsLoading(false);