Skip to content

Commit ceff893

Browse files
committed
feat: add shipment template
1 parent 37ceca4 commit ceff893

File tree

2 files changed

+121
-5
lines changed

2 files changed

+121
-5
lines changed

src/utils/printTemplates.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export async function getPrintTemplatePropValues(
5151
const values: PrintValues = { doc: {}, print: {} };
5252
values.doc = await getPrintTemplateDocValues(doc);
5353

54-
if (values.doc.entryType !== ModelNameEnum.Payment) {
54+
if (
55+
values.doc.entryType === ModelNameEnum.SalesInvoice ||
56+
values.doc.entryType === ModelNameEnum.PurchaseInvoice
57+
) {
5558
paymentId = await (doc as SalesInvoice).getPaymentIds();
5659

5760
if (paymentId && paymentId.length) {
@@ -71,9 +74,11 @@ export async function getPrintTemplatePropValues(
7174
}
7275
}
7376

74-
const totalTax = await (
75-
(sinvDoc as Invoice) ?? (doc as Payment)
76-
)?.getTotalTax();
77+
let totalTax;
78+
79+
if (values.doc.entryType !== ModelNameEnum.Shipment) {
80+
totalTax = await ((sinvDoc as Invoice) ?? (doc as Payment))?.getTotalTax();
81+
}
7782

7883
if (doc.schema.name == ModelNameEnum.Payment) {
7984
(values.doc as PrintTemplateData).amountPaidInWords = getGrandTotalInWords(
@@ -82,7 +87,7 @@ export async function getPrintTemplatePropValues(
8287
}
8388

8489
(values.doc as PrintTemplateData).subTotal = doc.fyo.format(
85-
((doc.grandTotal as Money) ?? (doc.amount as Money)).sub(totalTax),
90+
((doc.grandTotal as Money) ?? (doc.amount as Money)).sub(totalTax || 0),
8691
ModelNameEnum.Currency
8792
);
8893

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<main class="bg-white h-full" :style="{ 'font-family': print.font }">
2+
<!-- Invoice Header -->
3+
<header class="bg-gray-100 px-12 py-10">
4+
<!-- Company Details -->
5+
<section class="flex items-center">
6+
<img
7+
v-if="print.displayLogo"
8+
class="h-12 max-w-32 object-contain mr-4"
9+
:src="print.logo"
10+
/>
11+
12+
<div>
13+
<p class="font-semibold text-xl" :style="{ color: print.color }">
14+
{{ print.companyName }}
15+
</p>
16+
17+
<p class="text-sm text-gray-800" v-if="print.address">
18+
{{ print.links.address.addressDisplay }}
19+
</p>
20+
21+
<p class="text-sm text-gray-800" v-if="print.gstin">
22+
GSTIN: {{ print.gstin }}
23+
</p>
24+
</div>
25+
</section>
26+
27+
<!-- Sub Heading Section -->
28+
<div class="mt-8 text-lg">
29+
<!-- Doc Details -->
30+
<section class="flex">
31+
<h3 class="w-1/3 font-semibold">{{t`Bill`}}</h3>
32+
<div class="w-2/3 text-gray-800">
33+
<p class="font-semibold">{{ doc.name }}</p>
34+
35+
<div class="flex gap-2">
36+
<p>{{ doc.date }}</p>
37+
<p>{{doc?.time }}</p>
38+
</div>
39+
</div>
40+
</section>
41+
42+
<!-- Party Details -->
43+
<section class="mt-4 flex">
44+
<h3 class="w-1/3 font-semibold">{{t`party`}}</h3>
45+
46+
<div class="w-2/3 text-gray-800" v-if="doc.party">
47+
<p class="font-semibold">{{ doc.party }}</p>
48+
49+
<p v-if="doc.links.party.address">
50+
{{ doc.links.party.links.address.addressDisplay }}
51+
</p>
52+
53+
<p v-if="doc.links.party.gstin">GSTIN: {{ doc.links.party.gstin }}</p>
54+
</div>
55+
</section>
56+
</div>
57+
</header>
58+
59+
<!-- Items Table -->
60+
<section class="mt-5 mx-16">
61+
<!-- Heading Row -->
62+
<section class="w-full font-semibold flex border-b">
63+
<div class="py-1 w-1/2">{{ t`Item` }}</div>
64+
<div class="py-1 text-right w-3/12" v-if="doc.showHSN">
65+
{{ t`HSN/SAC` }}
66+
</div>
67+
<div class="py-1 text-right w-1/4">{{ t`From` }}</div>
68+
<div class="py-1 text-right w-1/4">{{ t`Quantity` }}</div>
69+
<div class="py-1 text-right w-3/12">{{ t`Rate` }}</div>
70+
<div class="py-1 text-right w-3/12">{{ t`Amount` }}</div>
71+
</section>
72+
73+
<!-- Body Rows -->
74+
<section
75+
class="flex py-1 text-gray-900 w-full border-b"
76+
v-for="row in doc.items"
77+
:key="row.name"
78+
>
79+
<div class="w-1/2 py-1">{{ row.item }}</div>
80+
<div class="w-3/12 text-right py-1" v-if="doc.showHSN">
81+
{{ row.hsnCode }}
82+
</div>
83+
<div class="w-1/4 text-right py-1">{{ row.location }}</div>
84+
<div class="w-1/4 text-right py-1">{{ row.quantity }}</div>
85+
<div class="w-3/12 text-right py-1">{{ row.rate }}</div>
86+
<div class="w-3/12 text-right py-1">{{ row.amount }}</div>
87+
</section>
88+
</section>
89+
<footer class="px-12 pt-10 text-lg">
90+
<!-- Totaled Amounts -->
91+
<section class="flex -mx-3 justify-end flex-1 bg-gray-100 gap-8">
92+
<div class="flex items-center">{{doc.grandTotalInWords}}</div>
93+
94+
<!-- Grand Total -->
95+
<div
96+
class="py-3 px-4 text-right text-white"
97+
:style="{ backgroundColor: print.color }"
98+
>
99+
<h3>{{ t`Grand Total` }}</h3>
100+
<p class="text-2xl mt-2 font-semibold">{{ doc.grandTotal }}</p>
101+
</div>
102+
</section>
103+
104+
<!-- Invoice Terms -->
105+
<section class="mt-12" v-if="doc.terms">
106+
<h3 class="text-lg font-semibold">Notes</h3>
107+
108+
<p class="mt-4 text-lg whitespace-pre-line">{{ doc.terms }}</p>
109+
</section>
110+
</footer>
111+
</main>

0 commit comments

Comments
 (0)