show invoice/bill totals sorted

This commit is contained in:
denisdulici 2020-04-18 16:20:11 +03:00
parent ec07675437
commit 88f64ad4ab
11 changed files with 16 additions and 11 deletions

View File

@ -15,6 +15,11 @@ abstract class DocumentModel extends Model
{
use Cloneable, Currencies, DateTime, Media, Recurring;
public function totals_sorted()
{
return $this->totals()->orderBy('sort_order');
}
public function scopeDue($query, $date)
{
return $query->whereDate('due_at', '=', $date);

View File

@ -74,7 +74,7 @@ class Bills extends Controller
$date_format = $this->getCompanyDateFormat();
// Get Bill Totals
foreach ($bill->totals as $bill_total) {
foreach ($bill->totals_sorted as $bill_total) {
$bill->{$bill_total->code} = $bill_total->amount;
}

View File

@ -77,7 +77,7 @@ class Invoices extends Controller
$date_format = $this->getCompanyDateFormat();
// Get Invoice Totals
foreach ($invoice->totals as $invoice_total) {
foreach ($invoice->totals_sorted as $invoice_total) {
$invoice->{$invoice_total->code} = $invoice_total->amount;
}

View File

@ -236,7 +236,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<tr>

View File

@ -184,7 +184,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach($invoice->totals as $total)
@foreach($invoice->totals_sorted as $total)
@if($total->code != 'total')
<tr>
<th>{{ trans($total['name']) }}:</th>

View File

@ -173,7 +173,7 @@
<div class="col-42">
<div class="text company pr-2">
@foreach ($bill->totals as $total)
@foreach ($bill->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<div class="border-top-1 py-2">

View File

@ -410,7 +410,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach ($bill->totals as $total)
@foreach ($bill->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<tr>

View File

@ -111,7 +111,7 @@
<span class="float-right">@date($invoice->due_at)</span><br><br>
@stack('due_at_input_end')
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code == 'total')
<strong>{{ trans($total->name) }}:</strong>
<span class="float-right">@money($total->amount - $invoice->paid, $invoice->currency_code, true)</span><br><br>
@ -189,7 +189,7 @@
<div class="col-42 float-right text-right">
<div class="text company pr-2">
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<div class="border-top-dashed py-2">

View File

@ -177,7 +177,7 @@
<div class="col-42 float-right text-right">
<div class="text company">
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<div class="border-top-1 py-2">

View File

@ -158,7 +158,7 @@
<div class="col-42 float-right text-right">
<div class="text company pr-2">
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<strong class="float-left">{{ trans($total->title) }}:</strong>

View File

@ -427,7 +427,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<tr>