Reports include deleted payments

This commit is contained in:
Hillel Coren 2017-07-11 09:31:06 +03:00
parent 93eb4c63cd
commit 05e5ae1167

View File

@ -22,7 +22,7 @@ class ProfitAndLossReport extends AbstractReport
$payments = Payment::scope() $payments = Payment::scope()
->orderBy('payment_date', 'desc') ->orderBy('payment_date', 'desc')
->with('client.contacts') ->with('client.contacts', 'invoice')
->withArchived() ->withArchived()
->excludeFailed() ->excludeFailed()
->where('payment_date', '>=', $this->startDate) ->where('payment_date', '>=', $this->startDate)
@ -30,6 +30,10 @@ class ProfitAndLossReport extends AbstractReport
foreach ($payments->get() as $payment) { foreach ($payments->get() as $payment) {
$client = $payment->client; $client = $payment->client;
$invoice = $payment->invoice;
if ($client->is_deleted || $invoice->is_deleted) {
continue;
}
$this->data[] = [ $this->data[] = [
trans('texts.payment'), trans('texts.payment'),
$client ? ($this->isExport ? $client->getDisplayName() : $client->present()->link) : '', $client ? ($this->isExport ? $client->getDisplayName() : $client->present()->link) : '',