From 4c48edc7905d6fb16b01ea707ee7e730dff78ced Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Thu, 7 Dec 2023 05:01:08 +0530 Subject: added view invoice page with print button! --- src/classes/invoice_item.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/classes/invoice_item.ts') diff --git a/src/classes/invoice_item.ts b/src/classes/invoice_item.ts index a7a0a85..dcb917a 100644 --- a/src/classes/invoice_item.ts +++ b/src/classes/invoice_item.ts @@ -1,3 +1,5 @@ +import currency from "currency.js" + export default class InvoiceItem { UnitOfMeasure: string Quantity: string @@ -19,3 +21,22 @@ export default class InvoiceItem { this.BrandName = "" } } + +export const calculate = (items: InvoiceItem[]) => items.map((x: InvoiceItem) => { + const quantity = currency(x.Quantity) + const unitPrice = currency(x.UnitPrice) + const gstPercentage = currency(x.GSTPercentage) + const gstValue = unitPrice.multiply(gstPercentage).divide(100) + const totalGSTValue = gstValue.multiply(quantity) + const amountWithoutGST = unitPrice.multiply(quantity) + + return({ + ...x + , Quantity: quantity + , UnitPrice: unitPrice + , GSTValue: gstValue + , TotalGSTValue: totalGSTValue + , AmountWithoutGST: amountWithoutGST + , TotalAmount: amountWithoutGST.add(totalGSTValue) + }) +}) -- cgit v1.2.3