From 31b7690ce92d5b07e6d52aa9dc8d0546c40a59f0 Mon Sep 17 00:00:00 2001 From: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:13:10 +0530 Subject: [PATCH] Convert the unit from grams to kg in inventory form (#6750) --- 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);