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 ++++++++++ src/components/invoice_header_editor.vue | 2 +- src/components/invoice_summary.vue | 9 ++++ src/components/sidebar.vue | 4 +- src/router/index.ts | 11 ++++- src/views/EditInvoice.vue | 31 ++------------ src/views/HomeView.vue | 2 +- src/views/ViewInvoice.vue | 72 ++++++++++++++++++++++++++++++++ 8 files changed, 119 insertions(+), 33 deletions(-) create mode 100644 src/components/invoice_summary.vue create mode 100644 src/views/ViewInvoice.vue (limited to 'src') 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) + }) +}) diff --git a/src/components/invoice_header_editor.vue b/src/components/invoice_header_editor.vue index 0a39ce5..6bd62b8 100644 --- a/src/components/invoice_header_editor.vue +++ b/src/components/invoice_header_editor.vue @@ -58,7 +58,7 @@ const submit = async (e: Event) => { "customerwebsite": c.Website, }) - route.push({ name: "edit-draft", params: { id: res.data.data.ID }}) + route.push({ name: "edit-invoice", params: { id: res.data.data.ID }}) } catch (err: any) { const statusCode: any = err.request.status const res: any = JSON.parse(err.request.response) diff --git a/src/components/invoice_summary.vue b/src/components/invoice_summary.vue new file mode 100644 index 0000000..6ca7907 --- /dev/null +++ b/src/components/invoice_summary.vue @@ -0,0 +1,9 @@ + + + diff --git a/src/components/sidebar.vue b/src/components/sidebar.vue index 4c4623f..ada509e 100644 --- a/src/components/sidebar.vue +++ b/src/components/sidebar.vue @@ -1,5 +1,5 @@ + + + + -- cgit v1.2.3