diff --git a/app/Http/Controllers/Reports/TaxSummary.php b/app/Http/Controllers/Reports/TaxSummary.php index ac81ec6e6..45e74ab60 100644 --- a/app/Http/Controllers/Reports/TaxSummary.php +++ b/app/Http/Controllers/Reports/TaxSummary.php @@ -66,26 +66,26 @@ class TaxSummary extends Controller switch ($status) { case 'paid': // 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'); // 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'); break; case 'upcoming': // 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'); // 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'); break; default: // 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'); // 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'); break; } @@ -106,11 +106,7 @@ class TaxSummary extends Controller $date = Date::parse($row->$date_field)->format('M'); if ($date_field == 'paid_at') { - if (!$row->invoice instanceof Invoice) { - continue; - } - - $row_totals = $row->invoice->totals; + $row_totals = $row->$type->totals; } else { $row_totals = $row->totals; } diff --git a/resources/views/reports/tax_summary/index.blade.php b/resources/views/reports/tax_summary/index.blade.php index 1cfbbcc09..ce1f2554c 100644 --- a/resources/views/reports/tax_summary/index.blade.php +++ b/resources/views/reports/tax_summary/index.blade.php @@ -13,7 +13,7 @@
{{ trans('general.all') }} {{ trans('invoices.paid') }} - {{ trans('dashboard.receivables') }} + {{ trans('general.upcoming') }}
{!! Form::open(['url' => 'reports/tax-summary', 'role' => 'form', 'method' => 'GET']) !!}