aboutsummaryrefslogtreecommitdiff
path: root/src/components/Form/Items/AddNewItemForm.tsx
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-25 18:06:56 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-25 18:06:56 +0530
commit6874be2c3016b872016ba32181823a8e1232a1a7 (patch)
tree8e1469bfdc6b646738ff2e6ae5f0e2e1f032dd7f /src/components/Form/Items/AddNewItemForm.tsx
parent35a44621c25b06471ae5b29bbdfb35fdcf652cf1 (diff)
Ported SummaryDisplay to tsx
Diffstat (limited to 'src/components/Form/Items/AddNewItemForm.tsx')
-rw-r--r--src/components/Form/Items/AddNewItemForm.tsx11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/components/Form/Items/AddNewItemForm.tsx b/src/components/Form/Items/AddNewItemForm.tsx
index e51ecfc..48ca4b2 100644
--- a/src/components/Form/Items/AddNewItemForm.tsx
+++ b/src/components/Form/Items/AddNewItemForm.tsx
@@ -38,7 +38,6 @@ const AddNewItemForm: React.FC<props> = (props) => {
// set description and price if match found in DB
const applyItemInfo = (i: any) => {
- console.log(i)
setItemDescValue(i.Description);
setItemPriceValue(i.UnitPrice);
setItemHSNValue(i.HSN);
@@ -68,14 +67,18 @@ const AddNewItemForm: React.FC<props> = (props) => {
(event) => {
event.preventDefault();
- const discountValue: number = (itemDiscountPercentage / 100) * itemPriceValue;
- const totalGSTValue: number = (itemGSTPercentage / 100) * (itemQTYValue);
+ const totalValue: number = itemPriceValue * itemQTYValue;
+
+ // the values below are being rounded to two decimal places
+ const discountValue: number = parseFloat(((itemDiscountPercentage / 100) * itemPriceValue).toFixed(2))
+ const totalGSTValue: number = parseFloat(((itemGSTPercentage / 100) * totalValue).toFixed(2))
+
const newInvoiceItem: Item = {
Model: itemNameValue,
Description: itemDescValue,
Quantity: itemQTYValue,
UnitPrice: itemPriceValue,
- TotalValue: itemPriceValue * itemQTYValue,
+ TotalValue: totalValue,
Discount: itemDiscountPercentage,
DiscountValue: discountValue,
HSN: itemHSNValue,