aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-10 08:03:19 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-10 08:03:19 +0530
commit33c10cfa027d769c1d02a54bad766f431b1196ee (patch)
treebb487bcecf9944250c5a94267295ec917e087529 /src
parent86e800430360ac3af422faf1f6f7317aea9b1a19 (diff)
added sgst, cgst, igst support instead of GST as a whole
Diffstat (limited to 'src')
-rw-r--r--src/components/Display/DisplayItem.js6
-rw-r--r--src/components/Display/ItemsDisplay.js7
-rw-r--r--src/components/Display/SummaryDisplay.js7
-rw-r--r--src/components/Form/Items/AddNewItemForm.js35
-rw-r--r--src/components/Form/Items/RegisterItemForm.js3
-rw-r--r--src/styles/global.scss2
6 files changed, 37 insertions, 23 deletions
diff --git a/src/components/Display/DisplayItem.js b/src/components/Display/DisplayItem.js
index 04a7d8b..02693ab 100644
--- a/src/components/Display/DisplayItem.js
+++ b/src/components/Display/DisplayItem.js
@@ -20,7 +20,11 @@ const DisplayItem = (props) => {
<td className={item.Description === "" ? "leftAlign disabledBorder" : "leftAlign"}>{item.Description}</td>
<td>{item.Quantity}</td>
<td className={item.Discount === 0 ? "disabledBorder" : ""}>{item.Discount}</td>
- <td className={item.GST === props.defGSTValue ? "" : "warningBorder"}>{item.GST}</td>
+
+ <td className={item.cgst === "" ? "disabledBorder" : (props.defGSTValue / 2 ? "" : "warningBorder")}>{item.sgst}</td>
+ <td className={item.sgst === "" ? "disabledBorder" : (props.defGSTValue / 2 ? "" : "warningBorder")}>{item.cgst}</td>
+ <td className={item.igst === "" ? "disabledBorder" : (item.igst === props.defGSTValue ? "" : "warningBorder")}>{item.igst}</td>
+
<td>{item.HSN}</td>
<td>{item.TotalPrice}</td>
</tr>
diff --git a/src/components/Display/ItemsDisplay.js b/src/components/Display/ItemsDisplay.js
index 7afc341..0b2fbf0 100644
--- a/src/components/Display/ItemsDisplay.js
+++ b/src/components/Display/ItemsDisplay.js
@@ -13,6 +13,7 @@ import {SummaryDisplayTR} from "./SummaryDisplay";
const ItemsDisplay = (props) => {
const items = props.items;
+ // TODO: remove mutability
let itemNumber = 0;
// TODO: Add HSN Support
@@ -26,7 +27,9 @@ const ItemsDisplay = (props) => {
<th className={"leftAlign"}>Description</th>
<th>Quantity(NOS)</th>
<th>Discount(%)</th>
- <th>GST(%)</th>
+ <th>sgst(%)</th>
+ <th>cgst(%)</th>
+ <th>igst(%)</th>
<th>HSN</th>
<th>Price</th>
</tr>
@@ -35,7 +38,7 @@ const ItemsDisplay = (props) => {
(item) => {
itemNumber++
return (
- <DisplayItem itemNumber={itemNumber} item={item} defGSTValue={props.defGSTValue}/>
+ <DisplayItem key={itemNumber} itemNumber={itemNumber} item={item} defGSTValue={props.defGSTValue}/>
);
}
)}
diff --git a/src/components/Display/SummaryDisplay.js b/src/components/Display/SummaryDisplay.js
index 9b1ca6b..1bcc713 100644
--- a/src/components/Display/SummaryDisplay.js
+++ b/src/components/Display/SummaryDisplay.js
@@ -28,6 +28,7 @@ const getBasicSummary = (items) => {
);
}
+// TODO: remove mutability from this function
const getFullSummary = (items) => {
let totalRawPrice = 0;
let totalDiscount = 0; // to be subtracted from totalRawPrice
@@ -39,7 +40,9 @@ const getFullSummary = (items) => {
totalRawPrice += itemTotalPrice;
totalDiscount += itemDiscount;
- totalTax += (i.GST / 100) * (itemTotalPrice - itemDiscount);
+ totalTax += i.igst === ""
+ ? ((i.sgst + i.cgst) / 100) * (itemTotalPrice - itemDiscount)
+ : (i.igst / 100) * (itemTotalPrice - itemDiscount);
return null;
})
@@ -72,6 +75,8 @@ export const SummaryDisplayTR = (props) => {
<td className={"disabledBorder"}></td>
<td className={"disabledBorder"}></td>
<td className={"disabledBorder"}></td>
+ <td className={"disabledBorder"}></td>
+ <td className={"disabledBorder"}></td>
<td>{summary.TotalRawPrice}</td>
</tr>
);
diff --git a/src/components/Form/Items/AddNewItemForm.js b/src/components/Form/Items/AddNewItemForm.js
index de524c7..a4710f9 100644
--- a/src/components/Form/Items/AddNewItemForm.js
+++ b/src/components/Form/Items/AddNewItemForm.js
@@ -18,6 +18,11 @@ const AddNewItemForm = (props) => {
const [itemQtyValue, setItemQtyValue] = useState(1);
const [itemHSNValue, setItemHSNValue] = useState(0);
+ // to be handled by DocumentInfo
+ // check if client is in same state
+ // and apply cgst+sgst or igst accordingly
+ const inState = true;
+
const enterItemNamePrompt = "start typing here";
const registerItemPrompt = "add new";
const emptyItemNames = [enterItemNamePrompt, registerItemPrompt, ""];
@@ -31,16 +36,10 @@ const AddNewItemForm = (props) => {
}
// check the item name value and do stuff accordingly
- const setItemInfo = (itemName) => {
- props.savedItems.some(
- (i) => {
- itemName === i.Model.toLowerCase()
- ? applyItemInfo(i)
- : itemName === registerItemPrompt && props.registerItemFormVisibility(true)
- return null;
- }
- )
- }
+ const setItemInfo = (itemName) =>
+ (props.savedItems === null || itemName === registerItemPrompt)
+ ? props.registerItemFormVisibility(true)
+ : props.savedItems.some((i) => itemName === i.Model.toLowerCase() && applyItemInfo(i))
const resetAllValues = () => {
setItemNameValue("");
@@ -56,7 +55,6 @@ const AddNewItemForm = (props) => {
<div className={"formContainer"}>
<form className={"threePaneForm"} onSubmit={
(event) => {
- alert("submit")
event.preventDefault();
const newInvoiceItem = {
"Model": itemNameValue,
@@ -66,8 +64,13 @@ const AddNewItemForm = (props) => {
"TotalPrice": parseFloat(itemPriceValue * itemQtyValue),
"Discount": parseInt(itemDiscountValue),
"HSN": parseInt(itemHSNValue),
- "GST": parseInt(itemGSTValue)
+
+ // this also checks if igst applies or not
+ "sgst": inState ? parseInt(itemGSTValue) / 2 : "",
+ "cgst": inState ? parseInt(itemGSTValue) / 2 : "",
+ "igst": inState ? "" : parseInt(itemGSTValue)
};
+ console.log(newInvoiceItem);
props.addItem(newInvoiceItem);
resetAllValues();
}
@@ -83,12 +86,10 @@ const AddNewItemForm = (props) => {
setItemNameValue(event.target.value);
setItemInfo(event.target.value.toLowerCase());
}
- }>
+ }>
<option key={enterItemNamePrompt}>{enterItemNamePrompt}</option>
- {props.savedItems === null || props.savedItems.map(
- (i) => {
- return <option key={i.Model}>{i.Model}</option>
- }
+ {props.savedItems !== null && props.savedItems.map(
+ (i) => <option key={i.Model}>{i.Model}</option>
)}
<option key={registerItemPrompt}>{registerItemPrompt}</option>
</select>
diff --git a/src/components/Form/Items/RegisterItemForm.js b/src/components/Form/Items/RegisterItemForm.js
index b57db9f..6ad4c1f 100644
--- a/src/components/Form/Items/RegisterItemForm.js
+++ b/src/components/Form/Items/RegisterItemForm.js
@@ -45,11 +45,12 @@ const RegisterItemForm = (props) => {
.then((res) => {
console.log(res);
props.setVisibility(false);
+ props.updateItemsList();
})
.catch((err) => {
console.log(err);
+ alert("Something went wrong, please check the log by opening the console.")
});
- props.updateItemsList();
}
diff --git a/src/styles/global.scss b/src/styles/global.scss
index 9bf0904..54cbddc 100644
--- a/src/styles/global.scss
+++ b/src/styles/global.scss
@@ -18,7 +18,7 @@
width: 1vw;
}
* {
- scrollbar-width: 0.1vw; /* Firefox */
+ scrollbar-width: 1vw; /* Firefox */
}
html, body {