From c3206679f476e7fd001756190024e03f05340ea2 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sat, 6 Jul 2024 03:20:30 +0530 Subject: populated items list and total in print preview --- src/assets/placeholdersignature.png | Bin 0 -> 16683 bytes src/classes/invoice.ts | 16 ++++- src/classes/invoice_item.ts | 24 ++++++- src/components/PrintPreview.vue | 16 +++-- src/components/PrintPreviewFooter.vue | 68 +++++++++++++++++++ src/components/PrintPreviewHeader.vue | 1 - src/components/PrintPreviewItemsList.vue | 51 +++++++++++---- src/components/invoice_header.vue | 109 +------------------------------ src/components/invoice_items_table.vue | 13 ++-- src/components/sidebar.vue | 4 +- src/views/EditInvoice.vue | 6 +- src/views/ViewInvoice.vue | 26 +++++--- 12 files changed, 185 insertions(+), 149 deletions(-) create mode 100644 src/assets/placeholdersignature.png create mode 100644 src/components/PrintPreviewFooter.vue (limited to 'src') diff --git a/src/assets/placeholdersignature.png b/src/assets/placeholdersignature.png new file mode 100644 index 0000000..82f8d99 Binary files /dev/null and b/src/assets/placeholdersignature.png differ diff --git a/src/classes/invoice.ts b/src/classes/invoice.ts index 213eddc..0fee42f 100644 --- a/src/classes/invoice.ts +++ b/src/classes/invoice.ts @@ -1,7 +1,7 @@ import Address from './address' import Item from './item' -export default class Customer { +export default class Invoice { InvoiceDate: string InvoiceNumber: number BillingAddress: Address @@ -32,3 +32,17 @@ export default class Customer { this.CustomerWebsite = "" } } + +export class InvoiceTotal { + TotalQuantity: string + TotalGSTValue: string + TotalWithoutGST: string + TotalWithGST: string + + constructor() { + this.TotalQuantity = "" + this.TotalGSTValue = "" + this.TotalWithoutGST = "" + this.TotalWithGST = "" + } +} diff --git a/src/classes/invoice_item.ts b/src/classes/invoice_item.ts index c3da433..fe92f10 100644 --- a/src/classes/invoice_item.ts +++ b/src/classes/invoice_item.ts @@ -22,7 +22,7 @@ export default class InvoiceItem { } } -export const calculate = (items: InvoiceItem[]) => items.map((x: InvoiceItem) => { +export const calculate = (x: InvoiceItem) => { const quantity = currency(x.Quantity) const unitPrice = currency(x.UnitPrice) const gstPercentage = currency(x.GSTPercentage) @@ -39,4 +39,24 @@ export const calculate = (items: InvoiceItem[]) => items.map((x: InvoiceItem) => , AmountWithoutGST: amountWithoutGST , TotalAmount: amountWithoutGST.multiply(gstPercentage).divide(100).add(amountWithoutGST) }) -}) +} + +export const calculateArr = (items: InvoiceItem[]) => + items.map((x: InvoiceItem) => calculate(x)) + +export const calculateTotal = (items: InvoiceItem[]) => + items.reduce((total, item) => { + const c = calculate(item) + + return ({ + TotalQuantity: total.TotalQuantity.add(c.Quantity), + TotalGSTValue: total.TotalGSTValue.add(c.TotalGSTValue), + TotalWithoutGST: total.TotalWithoutGST.add(c.AmountWithoutGST), + TotalWithGST: total.TotalWithGST.add(c.TotalAmount) + }) + }, { + TotalQuantity: currency(0), + TotalGSTValue: currency(0), + TotalWithoutGST: currency(0), + TotalWithGST: currency(0) + }) diff --git a/src/components/PrintPreview.vue b/src/components/PrintPreview.vue index ecbda88..1e98eb7 100644 --- a/src/components/PrintPreview.vue +++ b/src/components/PrintPreview.vue @@ -1,13 +1,12 @@ @@ -28,4 +29,9 @@ .print-preview p { margin: 0; } +.print-preview { + display: grid; + grid-template-rows: 1fr 2fr auto 1.5fr; + row-gap: 1em; +} diff --git a/src/components/PrintPreviewFooter.vue b/src/components/PrintPreviewFooter.vue new file mode 100644 index 0000000..4594a92 --- /dev/null +++ b/src/components/PrintPreviewFooter.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/components/PrintPreviewHeader.vue b/src/components/PrintPreviewHeader.vue index 33f82f2..4492eb5 100644 --- a/src/components/PrintPreviewHeader.vue +++ b/src/components/PrintPreviewHeader.vue @@ -49,7 +49,6 @@ grid-template-columns: 1.7in 2.4in auto; grid-column-gap: 1em; width: 100%; - margin-bottom: 1em; } .logo-container { display: flex; diff --git a/src/components/PrintPreviewItemsList.vue b/src/components/PrintPreviewItemsList.vue index 72f0fc1..2e81e9a 100644 --- a/src/components/PrintPreviewItemsList.vue +++ b/src/components/PrintPreviewItemsList.vue @@ -12,20 +12,32 @@
Unit Price
Discount
Taxable Value
-
GST
+
+
GST
+
+
%
+
cgst
+
sgst
+
+
Total
-
{{ index + 1 }}
-
{{ item.Name }}
+
{{ index + 1 }}
+
{{ item.Brand }} {{ item.Name }}
{{ item.HSN }}
-
1
-
100
-
0
-
10
-
18
-
1000
+
{{ item.Quantity }}
+
{{ item.UnitPrice }}
+
null
+
{{ item.AmountWithoutGST }}
+
+ +
{{ item.GSTPercentage }}%
+
{{ item.TotalGSTValue.distribute(2)[0] }}
+
{{ item.TotalGSTValue.distribute(2)[1] }}
+
+
{{ item.TotalAmount }}
@@ -33,7 +45,6 @@ diff --git a/src/components/invoice_header.vue b/src/components/invoice_header.vue index fe35980..846c811 100644 --- a/src/components/invoice_header.vue +++ b/src/components/invoice_header.vue @@ -3,112 +3,9 @@ const props = defineProps(["invoice"]) diff --git a/src/components/invoice_items_table.vue b/src/components/invoice_items_table.vue index ad1bf94..8b6c71d 100644 --- a/src/components/invoice_items_table.vue +++ b/src/components/invoice_items_table.vue @@ -27,20 +27,19 @@ const handleDelete = async (id) => { - +
- + - - - + - @@ -72,7 +69,7 @@ const handleDelete = async (id) => { -
# Item NameBrandBrand HSN Unit PriceTaxable Value GST Quantity Amount +
{{ item.Name }} - {{ item.BrandName }} {{ item.Description }} {{ item.BrandName }}{{ item.BrandName }} {{ item.HSN }} {{ item.UnitPrice }}{{ item.AmountWithoutGST }} {{ item.GSTValue }} {{ item.GSTPercentage }}% {{ item.TotalAmount }} +