missing bills in paid view #296

This commit is contained in:
denisdulici 2018-04-16 14:37:19 +03:00
parent 342bad81df
commit 0d4f3e9dae
2 changed files with 8 additions and 12 deletions

View File

@ -66,26 +66,26 @@ class TaxSummary extends Controller
switch ($status) { switch ($status) {
case 'paid': case 'paid':
// Invoices // Invoices
$invoices = InvoicePayment::monthsOfYear('paid_at')->get(); $invoices = InvoicePayment::with(['invoice', 'invoice.totals'])->monthsOfYear('paid_at')->get();
$this->setAmount($incomes, $totals, $invoices, 'invoice', 'paid_at'); $this->setAmount($incomes, $totals, $invoices, 'invoice', 'paid_at');
// Bills // Bills
$bills = BillPayment::monthsOfYear('paid_at')->get(); $bills = BillPayment::with(['bill', 'bill.totals'])->monthsOfYear('paid_at')->get();
$this->setAmount($expenses, $totals, $bills, 'bill', 'paid_at'); $this->setAmount($expenses, $totals, $bills, 'bill', 'paid_at');
break; break;
case 'upcoming': case 'upcoming':
// Invoices // Invoices
$invoices = Invoice::accrued()->monthsOfYear('due_at')->get(); $invoices = Invoice::with(['totals'])->accrued()->monthsOfYear('due_at')->get();
$this->setAmount($incomes, $totals, $invoices, 'invoice', 'due_at'); $this->setAmount($incomes, $totals, $invoices, 'invoice', 'due_at');
// Bills // Bills
$bills = Bill::accrued()->monthsOfYear('due_at')->get(); $bills = Bill::with(['totals'])->accrued()->monthsOfYear('due_at')->get();
$this->setAmount($expenses, $totals, $bills, 'bill', 'due_at'); $this->setAmount($expenses, $totals, $bills, 'bill', 'due_at');
break; break;
default: default:
// Invoices // Invoices
$invoices = Invoice::accrued()->monthsOfYear('invoiced_at')->get(); $invoices = Invoice::with(['totals'])->accrued()->monthsOfYear('invoiced_at')->get();
$this->setAmount($incomes, $totals, $invoices, 'invoice', 'invoiced_at'); $this->setAmount($incomes, $totals, $invoices, 'invoice', 'invoiced_at');
// Bills // Bills
$bills = Bill::accrued()->monthsOfYear('billed_at')->get(); $bills = Bill::with(['totals'])->accrued()->monthsOfYear('billed_at')->get();
$this->setAmount($expenses, $totals, $bills, 'bill', 'billed_at'); $this->setAmount($expenses, $totals, $bills, 'bill', 'billed_at');
break; break;
} }
@ -106,11 +106,7 @@ class TaxSummary extends Controller
$date = Date::parse($row->$date_field)->format('M'); $date = Date::parse($row->$date_field)->format('M');
if ($date_field == 'paid_at') { if ($date_field == 'paid_at') {
if (!$row->invoice instanceof Invoice) { $row_totals = $row->$type->totals;
continue;
}
$row_totals = $row->invoice->totals;
} else { } else {
$row_totals = $row->totals; $row_totals = $row->totals;
} }

View File

@ -13,7 +13,7 @@
<div class="pull-left" style="margin-left: 5px"> <div class="pull-left" style="margin-left: 5px">
<a href="{{ url('reports/tax-summary') }}?year={{ request('year', $this_year) }}"><span class="badge @if (request('status') == '') bg-green @else bg-default @endif">{{ trans('general.all') }}</span></a> <a href="{{ url('reports/tax-summary') }}?year={{ request('year', $this_year) }}"><span class="badge @if (request('status') == '') bg-green @else bg-default @endif">{{ trans('general.all') }}</span></a>
<a href="{{ url('reports/tax-summary') }}?status=paid&year={{ request('year', $this_year) }}"><span class="badge @if (request('status') == 'paid') bg-green @else bg-default @endif">{{ trans('invoices.paid') }}</span></a> <a href="{{ url('reports/tax-summary') }}?status=paid&year={{ request('year', $this_year) }}"><span class="badge @if (request('status') == 'paid') bg-green @else bg-default @endif">{{ trans('invoices.paid') }}</span></a>
<a href="{{ url('reports/tax-summary') }}?status=upcoming&year={{ request('year', $this_year) }}"><span class="badge @if (request('status') == 'upcoming') bg-green @else bg-default @endif">{{ trans('dashboard.receivables') }}</span></a> <a href="{{ url('reports/tax-summary') }}?status=upcoming&year={{ request('year', $this_year) }}"><span class="badge @if (request('status') == 'upcoming') bg-green @else bg-default @endif">{{ trans('general.upcoming') }}</span></a>
</div> </div>
{!! Form::open(['url' => 'reports/tax-summary', 'role' => 'form', 'method' => 'GET']) !!} {!! Form::open(['url' => 'reports/tax-summary', 'role' => 'form', 'method' => 'GET']) !!}
<div class="pull-right"> <div class="pull-right">