From 300a4eb39ccea56da416d83400cddc97118e1649 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 12 Oct 2022 21:04:39 +0530 Subject: showing total (sum) values in InvoiceItemTable --- src/components/tables/invoice-item-table.js | 116 ++++++++++++++++++---------- 1 file changed, 74 insertions(+), 42 deletions(-) (limited to 'src/components/tables/invoice-item-table.js') diff --git a/src/components/tables/invoice-item-table.js b/src/components/tables/invoice-item-table.js index 6b0a1a5..12ee52e 100644 --- a/src/components/tables/invoice-item-table.js +++ b/src/components/tables/invoice-item-table.js @@ -16,11 +16,11 @@ */ import './scss/table.scss'; -import { deleteItem } from './../../classes/item'; +import { deleteItem, getDiscountValue, getGSTValue, getAmount } from './../../classes/item'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faPencil, faTrashCan } from '@fortawesome/free-solid-svg-icons' -const ItemTable = ({items, setItems}) => { +const ItemTable = ({items, setItems, isInterstate, sum}) => { const handleEdit = (i) => { alert("coming soon; please delete and add item again"); } @@ -29,15 +29,7 @@ const ItemTable = ({items, setItems}) => { setItems(items.filter(i => i.Id !== item.Id)); } - /* TODO: all the math should be done here - * i.e CGST, IGST, total price (i.e price x quantity) - * discount/gst value (i.e number instead of percentage) - * - * the total cost and the like may be handled by - * parent component since they are needed - * by other things (probably) - * - * all the values will be calculated on runtime. + /* all the values will be calculated on runtime. * the database will only store the unit price * and gst/discount *percentages* and everything else * will be calculated on runtime. i.e the @@ -45,40 +37,80 @@ const ItemTable = ({items, setItems}) => { * those same values shown to the user while creating the invoice */ return ( - - - - - - - - - - - - {/* TODO: CGST, IGST, etc */} - - - - - {items && items.map((i, id=id+1) => ( - - - - - - - - - + <> +
S. NoNameDescriptionBrand NameUOMHSNUnit PriceGST %
{id+1}{i.Name}{i.Description}{i.Brand.Name}{i.UnitOfMeasure}{i.HSN}{i.UnitPrice}{i.GSTPercentage}
+ + + + + + + + + + + {isInterstate + ? + : <> + + + + } + + + + + + + {items && items.map((i, id) => ( + + + + + + + + + + {isInterstate + ? + : <> + + + + } + + + + + ))} + + + + + + + + + + {isInterstate + ? + : <> + + + + } + + - ))} - -
S. NoNameDescriptionBrand NameQuantityUOMUnit PriceDiscount (%)IGST (%)SGST (%)CGST (%)HSNAmount
{id+1}{i.Name}{i.Description}{i.Brand.Name}{i.Quantity}{i.UnitOfMeasure} 0 ? "" : "empty"}>{i.UnitPrice} 0 ? "" : "empty"}>{getDiscountValue(i)} ({i.DiscountPercentage}%) 0 ? "" : "empty"}>{getGSTValue(i)} ({i.GSTPercentage}%) 0 ? "" : "empty"}>{getGSTValue(i) / 2} ({i.GSTPercentage / 2}%) 0 ? "" : "empty"}>{getGSTValue(i) / 2} ({i.GSTPercentage / 2}%){i.HSN}{getAmount(i)} + handleEdit(i)}/> + handleDelete(i)}/> +
Total 0 ? "" : "empty"}>{sum.Quantity} 0 ? "" : "empty"}>{sum.UnitPrice} 0 ? "" : "empty"}>{sum.Discount} 0 ? "" : "empty"}>{sum.GST} 0 ? "" : "empty"}>{sum.GST / 2} 0 ? "" : "empty"}>{sum.GST / 2} 0 ? "" : "empty"}>{sum.Amount} - handleEdit(i)}/> - handleDelete(i)}/>
+ + + ); } -- cgit v1.2.3