Skip to content

Commit 6431709

Browse files
committed
better taxes display
1 parent 0e5210b commit 6431709

File tree

1 file changed

+61
-41
lines changed

1 file changed

+61
-41
lines changed

resources/views/default/invoice.blade.php

Lines changed: 61 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@
250250
</tbody>
251251
</table>
252252

253+
@php
254+
$hasTaxes = $invoice->tax_label || $invoice->totalTaxAmount()->isPositive();
255+
@endphp
256+
253257
<table class="mb-5 w-full">
254258
<thead>
255259
<tr class="text-gray-500">
@@ -262,9 +266,15 @@
262266
<th class="whitespace-nowrap border-b p-2 text-left text-xs font-normal">
263267
{{ __('invoices::invoice.unit_price') }}
264268
</th>
265-
<th class="whitespace-nowrap border-b p-2 text-left text-xs font-normal">
266-
{{ __('invoices::invoice.tax') }}
267-
</th>
269+
270+
@if ($hasTaxes)
271+
<th class="whitespace-nowrap border-b p-2 text-left text-xs font-normal">
272+
{{ __('invoices::invoice.tax') }}
273+
</th>
274+
@else
275+
<th class="p-0"></th>
276+
@endif
277+
268278
<th class="whitespace-nowrap border-b py-2 pl-2 text-right text-xs font-normal">
269279
{{ __('invoices::invoice.amount') }}
270280
</th>
@@ -285,17 +295,26 @@
285295
<td class="whitespace-nowrap border-b p-2 align-top text-xs">
286296
<p>{{ $item->formatMoney($item->unit_price) }}</p>
287297
</td>
288-
<td class="whitespace-nowrap border-b p-2 align-top text-xs">
289-
@if ($item->unit_tax && $item->tax_percentage)
290-
<p>{{ $item->formatMoney($item->unit_tax) }}
291-
({{ $item->formatPercentage($item->tax_percentage) }})
292-
</p>
293-
@elseif ($item->unit_tax)
294-
<p>{{ $item->formatMoney($item->unit_tax) }}</p>
295-
@else
296-
<p>{{ $item->formatPercentage($item->tax_percentage) }}</p>
297-
@endif
298-
</td>
298+
299+
@if ($hasTaxes)
300+
<td class="whitespace-nowrap border-b p-2 align-top text-xs">
301+
@if ($item->unit_tax !== null && $item->tax_percentage !== null)
302+
<p>
303+
{{ $item->formatMoney($item->unit_tax) }}
304+
({{ $item->formatPercentage($item->tax_percentage) }})
305+
</p>
306+
@elseif ($item->unit_tax !== null)
307+
<p>{{ $item->formatMoney($item->unit_tax) }}</p>
308+
@elseif($item->tax_percentage !== null)
309+
<p>{{ $item->formatPercentage($item->tax_percentage) }}</p>
310+
@else
311+
<p>-</p>
312+
@endif
313+
</td>
314+
@else
315+
<td class="p-0"></td>
316+
@endif
317+
299318
<td class="whitespace-nowrap border-b py-2 pl-2 text-right align-top text-xs">
300319
<p>{{ $item->formatMoney($item->totalAmount()) }}</p>
301320
</td>
@@ -311,34 +330,35 @@
311330
{{ $invoice->formatMoney($invoice->subTotalAmount()) }}
312331
</td>
313332
</tr>
314-
@if ($invoice->discounts)
315-
@foreach ($invoice->discounts as $discount)
316-
<tr>
317-
{{-- empty space --}}
318-
<td class="py-2 pr-2"></td>
319-
<td class="border-b p-2 text-xs" colspan="3">
320-
{{ __($discount->name) ?? __('invoices::invoice.discount_name') }}
321-
@if ($discount->percent_off)
322-
({{ $discount->formatPercentage($discount->percent_off) }})
323-
@endif
324-
</td>
325-
<td class="whitespace-nowrap border-b py-2 pl-2 text-right text-xs">
326-
{{ $invoice->formatMoney($discount->computeDiscountAmountOn($invoice->subTotalAmount())?->multipliedBy(-1)) }}
327-
</td>
328-
</tr>
329-
@endforeach
330-
@endif
331333

332-
<tr>
333-
{{-- empty space --}}
334-
<td class="py-2 pr-2"></td>
335-
<td class="border-b p-2 text-xs" colspan="3">
336-
{{ $invoice->tax_label ?? __('invoices::invoice.tax_label') }}
337-
</td>
338-
<td class="whitespace-nowrap border-b py-2 pl-2 text-right text-xs">
339-
{{ $invoice->formatMoney($invoice->totalTaxAmount()) }}
340-
</td>
341-
</tr>
334+
@foreach ($invoice->discounts as $discount)
335+
<tr>
336+
{{-- empty space --}}
337+
<td class="py-2 pr-2"></td>
338+
<td class="border-b p-2 text-xs" colspan="3">
339+
{{ __($discount->name) ?? __('invoices::invoice.discount_name') }}
340+
@if ($discount->percent_off)
341+
({{ $discount->formatPercentage($discount->percent_off) }})
342+
@endif
343+
</td>
344+
<td class="whitespace-nowrap border-b py-2 pl-2 text-right text-xs">
345+
{{ $invoice->formatMoney($discount->computeDiscountAmountOn($invoice->subTotalAmount())?->multipliedBy(-1)) }}
346+
</td>
347+
</tr>
348+
@endforeach
349+
350+
@if ($hasTaxes)
351+
<tr>
352+
{{-- empty space --}}
353+
<td class="py-2 pr-2"></td>
354+
<td class="border-b p-2 text-xs" colspan="3">
355+
{{ $invoice->tax_label ?? __('invoices::invoice.tax_label') }}
356+
</td>
357+
<td class="whitespace-nowrap border-b py-2 pl-2 text-right text-xs">
358+
{{ $invoice->formatMoney($invoice->totalTaxAmount()) }}
359+
</td>
360+
</tr>
361+
@endif
342362

343363
<tr>
344364
{{-- empty space --}}

0 commit comments

Comments
 (0)