aboutsummaryrefslogtreecommitdiff
path: root/src/classes/invoice_item.ts
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2023-12-07 05:01:08 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2023-12-07 05:01:08 +0530
commit4c48edc7905d6fb16b01ea707ee7e730dff78ced (patch)
tree343839b5c7bcd7abf24ba7ef9f3ba7c33ccf78f8 /src/classes/invoice_item.ts
parent464dac56714f4fb187785abda04bf3f2170af2a2 (diff)
added view invoice page with print button!0.3.0
Diffstat (limited to 'src/classes/invoice_item.ts')
-rw-r--r--src/classes/invoice_item.ts21
1 files changed, 21 insertions, 0 deletions
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)
+ })
+})