Skip to content

Commit

Permalink
Convert the unit from grams to kg in inventory form
Browse files Browse the repository at this point in the history
  • Loading branch information
sriharsh05 committed Nov 29, 2023
1 parent c37b554 commit 617a4e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Components/Facility/AddInventoryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 617a4e2

Please sign in to comment.