From bb331d9c61a0e38cbbfc891204819557327e1ca0 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Sun, 18 Apr 2021 10:04:28 +0530 Subject: Added HSN support --- src/components/Form/AddNewItemForm.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/components/Form/AddNewItemForm.js') diff --git a/src/components/Form/AddNewItemForm.js b/src/components/Form/AddNewItemForm.js index 09536b1..798bfc9 100644 --- a/src/components/Form/AddNewItemForm.js +++ b/src/components/Form/AddNewItemForm.js @@ -9,8 +9,9 @@ const AddNewItemForm = (props) => { const [itemDiscountValue, setItemDiscountValue] = useState(0.00); const [itemGSTValue, setItemGSTValue] = useState(props.defGSTValue); const [itemQtyValue, setItemQtyValue] = useState(1); + const [itemHSNValue, setItemHSNValue] = useState(0); - const enterItemNamePrompt = "Start typing here"; + const enterItemNamePrompt = "start typing here"; const registerItemPrompt = "add new"; const emptyItemNames = [enterItemNamePrompt, registerItemPrompt, ""]; @@ -25,14 +26,16 @@ const AddNewItemForm = (props) => { // set description and price // when item is entered const setItemInfo = (itemName) => { - for (let i = 0; i < props.savedItems.length - 1; i++) { + for (let i = 0; i < props.savedItems.length; i++) { const mod = props.savedItems[i].Model.toLowerCase(); const desc = props.savedItems[i].Description; const price = props.savedItems[i].Price; + const hsn = props.savedItems[i].HSN; if (mod === itemName) { setItemDescValue(desc); setItemPriceValue(price); + setItemHSNValue(hsn); break; } } @@ -44,6 +47,7 @@ const AddNewItemForm = (props) => { setItemQtyValue(1); setItemPriceValue(1); setItemDiscountValue(0); + setItemHSNValue(0); setItemGSTValue(props.defGSTValue); } @@ -58,6 +62,7 @@ const AddNewItemForm = (props) => { "Quantity": parseInt(itemQtyValue), "Price": parseFloat(itemPriceValue), "Discount": parseInt(itemDiscountValue), + "HSN": parseInt(itemHSNValue), "GST": parseInt(itemGSTValue) }; props.addItem(newInvoiceItem); @@ -122,6 +127,15 @@ const AddNewItemForm = (props) => { } /> + +