From 6874be2c3016b872016ba32181823a8e1232a1a7 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Fri, 25 Jun 2021 18:06:56 +0530 Subject: Ported SummaryDisplay to tsx --- src/components/Form/Items/AddNewItemForm.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/components/Form/Items/AddNewItemForm.tsx') 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) => { // 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) => { (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, -- cgit v1.2.3