import currency from "currency.js" export default class InvoiceItem { UnitOfMeasure: string Quantity: string Name: string Description: string HSN: string UnitPrice: string GSTPercentage: string BrandName: string constructor() { this.Name = '' this.Description = '' this.HSN = '' this.UnitPrice = '' this.GSTPercentage = '' this.UnitOfMeasure = '' this.Quantity = "" 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.multiply(gstPercentage).divide(100).add(amountWithoutGST) }) })