removed redundant code from invoice/bill show

This commit is contained in:
Denis Duliçi 2021-07-20 11:09:28 +03:00
parent c2fd5c3eaa
commit 3432a2c22c
5 changed files with 6 additions and 32 deletions

View File

@ -47,19 +47,6 @@ class Bills extends Controller
*/
public function show(Document $bill)
{
// Get Bill Totals
foreach ($bill->totals_sorted as $bill_total) {
$bill->{$bill_total->code} = $bill_total->amount;
}
$total = money($bill->total, $bill->currency_code, true)->format();
$bill->grand_total = money($total, $bill->currency_code)->getAmount();
if (!empty($bill->paid)) {
$bill->grand_total = round($bill->total - $bill->paid, config('money.' . $bill->currency_code . '.precision'));
}
return view('purchases.bills.show', compact('bill'));
}

View File

@ -45,19 +45,6 @@ class Invoices extends Controller
*/
public function show(Document $invoice)
{
// Get Invoice Totals
foreach ($invoice->totals_sorted as $invoice_total) {
$invoice->{$invoice_total->code} = $invoice_total->amount;
}
$total = money($invoice->total, $invoice->currency_code, true)->format();
$invoice->grand_total = money($total, $invoice->currency_code)->getAmount();
if (!empty($invoice->paid)) {
$invoice->grand_total = round($invoice->total - $invoice->paid, config('money.' . $invoice->currency_code . '.precision'));
}
return view('sales.invoices.show', compact('invoice'));
}

View File

@ -5,7 +5,7 @@
{{ $textDocumentTitle }}
</h3>
@if ($textDocumentSubheading)
@if ($textDocumentSubheading)
<h5>
{{ $textDocumentSubheading }}
</h5>
@ -280,7 +280,7 @@
@stack('grand_total_tr_start')
<div class="border-top-dashed py-2">
<strong class="float-left">{{ trans($total->name) }}:</strong>
<span>@money($total->amount - $document->paid, $document->currency_code, true)</span>
<span>@money($document->amount_due, $document->currency_code, true)</span>
</div>
@stack('grand_total_tr_end')
@endif

View File

@ -5,7 +5,7 @@
{{ $textDocumentTitle }}
</h3>
@if ($textDocumentSubheading)
@if ($textDocumentSubheading)
<h5>
{{ $textDocumentSubheading }}
</h5>
@ -263,7 +263,7 @@
@stack('grand_total_tr_start')
<div class="border-top-1 py-2">
<strong class="float-left">{{ trans($total->name) }}:</strong>
<span>@money($total->amount - $document->paid, $document->currency_code, true)</span>
<span>@money($document->amount_due, $document->currency_code, true)</span>
</div>
@stack('grand_total_tr_end')
@endif

View File

@ -5,7 +5,7 @@
{{ $textDocumentTitle }}
</h3>
@if ($textDocumentSubheading)
@if ($textDocumentSubheading)
<h5>
{{ $textDocumentSubheading }}
</h5>
@ -249,7 +249,7 @@
@endif
@stack('grand_total_tr_start')
<strong class="float-left">{{ trans($total->name) }}:</strong>
<span>@money($total->amount - $document->paid, $document->currency_code, true)</span>
<span>@money($document->amount_due, $document->currency_code, true)</span>
@stack('grand_total_tr_end')
@endif
@endforeach