aboutsummaryrefslogtreecommitdiff
path: root/src/components/Form
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-04-18 10:04:28 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-04-18 10:04:28 +0530
commitbb331d9c61a0e38cbbfc891204819557327e1ca0 (patch)
treec6c221d041f8ef1a8c878eb079e93bd60c1d656a /src/components/Form
parent4e880f6efe86c0b7e86e587e08eeee0f594417d5 (diff)
Added HSN support
Diffstat (limited to 'src/components/Form')
-rw-r--r--src/components/Form/AddNewItemForm.js20
1 files changed, 17 insertions, 3 deletions
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);
@@ -123,6 +128,15 @@ const AddNewItemForm = (props) => {
</label>
<label>
+ HSN: <input type="number" min="0" value={itemHSNValue} onChange={
+ (event) => {
+ const value = event.target.value;
+ setItemHSNValue(value);
+ }
+ } required />
+ </label>
+
+ <label>
GST: <input type="number" min="0" value={itemGSTValue} onChange={
(event) => {
const value = event.target.value;
@@ -136,7 +150,7 @@ const AddNewItemForm = (props) => {
<input type="button" value="Placeholder1" />
<input type="button" value="Placeholder2" />
<input type="button" value="Placeholder3" />
- <input type="submit" value="Placeholder4" />
+ <input type="submit" value="Panic" />
<input
type="submit"
value="add"