Skip to content

Commit c8ea085

Browse files
ArshidArshid
authored andcommitted
GST/VAT added
1 parent bb3b8d2 commit c8ea085

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed

resources/views/invoices/3-invoice.blade.php

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
margin: 0;
1212
padding: 0;
1313
}
14-
.tex-center{
15-
text-align: center;
14+
.text-right{
15+
text-align: right;
1616
}
1717
table {
1818
width: 100%;
@@ -39,6 +39,9 @@
3939
.pt-0{
4040
padding-top: 0;
4141
}
42+
.pb-0{
43+
padding-bottom: 0;
44+
}
4245
.font-bold{
4346
font-weight: bold;
4447
}
@@ -59,6 +62,9 @@
5962
font-size: 10px;
6063
margin-top: 10mm;
6164
}
65+
.text-center{
66+
text-align: center
67+
}
6268
.border-b-d{
6369
border-bottom: 1px dashed #999;
6470
}
@@ -77,6 +83,9 @@
7783
font-family: 'Courier New', Courier, monospace;
7884
font-size: 12px;
7985
}
86+
.mt-0{
87+
margin-top: 0;
88+
}
8089
</style>
8190
</head>
8291
<body>
@@ -105,7 +114,12 @@
105114
</tr>
106115
</thead>
107116
<tbody>
108-
@php $i = 0; @endphp
117+
@php
118+
$i = 0;
119+
$total_price = 0;
120+
$total_tax = [];
121+
$grand_total = 0;
122+
@endphp
109123
@foreach($items as $item)
110124
@php $i++; @endphp
111125
<tr>
@@ -115,20 +129,58 @@
115129
<td class="pt-0">VAT {{(int)$item['tax']}}%</td>
116130
<td class="tex-center pt-0">{{ number_format($item['price'], 2, '.', '') }}</td>
117131
<td class="tex-center pt-0">{{ $item['quantity'] }}</td>
118-
<td class="tex-center pt-0">{{ number_format( ($item['price'] * $item['quantity']), 2, '.', '') }}</td>
132+
@php
133+
$tax = $item['tax'];
134+
$item_total = $item->price * $item->quantity;
135+
$tax_amount = ($item_total * $tax) / 100;
136+
$item_total_with_tax = $item_total + $tax_amount;
137+
$total_price += $item_total;
138+
$total_tax[$tax] = ($total_tax[$tax] ?? 0) + $tax_amount;
139+
$grand_total += $item_total_with_tax;
140+
@endphp
141+
<td class="tex-center pt-0">{{ number_format( $item_total_with_tax , 2, '.', '') }}</td>
119142
</tr>
120143
<tr>
121144
<td class="border-b-d" colspan="4" style="height: 0; padding:0;"></td>
122145
</tr>
123146
@endforeach
147+
124148
<tr>
125-
<td colspan="3" style="font-size:16px">
149+
<td class="text-center " colspan="4" style="padding-top:3mm; padding-bottom:0; font-size:16px">
150+
INVOICE SUMMARY
151+
</td>
152+
</tr>
153+
154+
<tr>
155+
<td class="mt-2" colspan="3" style="font-size:16px;">
126156
Total
127157
</td>
128-
<td style="text-align: center; font-size:16px">
158+
<td class="pt-0" style="text-align: right; font-size:16px">
129159
{{$currency_symbol}}{{$order->total_price}}
130160
</td>
131161
</tr>
162+
163+
@foreach ($total_tax as $rate => $amount)
164+
<tr>
165+
<td colspan="3" style="font-size:16px; padding-top:0; padding-bottom:0">
166+
VAT/GST @ {{ $rate }}%
167+
</td>
168+
<td class="pt-0 pb-0" class="text-right" style=" padding-top:0; padding-bottom:0; font-size:16px">
169+
{{$rate}}
170+
</td>
171+
</tr>
172+
@endforeach
173+
<tr>
174+
<td class="border-b-d" colspan="4" style="height: 0; padding:0; padding-top:2mm"></td>
175+
</tr>
176+
<tr>
177+
<td colspan="3" style="font-size:16px">
178+
Grand Total
179+
</td>
180+
<td class="text-right" style=" font-size:16px">
181+
{{ $currency_symbol }}{{ number_format($grand_total, 2) }}
182+
</td>
183+
<tr>
132184
<tr>
133185
<td class="border-b-d" colspan="4" style="height: 0; padding:0;"></td>
134186
</tr>

0 commit comments

Comments
 (0)