From 05e5ae11677a261566e9e44cd550976dab898ebb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 11 Jul 2017 09:31:06 +0300 Subject: [PATCH] Reports include deleted payments --- app/Ninja/Reports/ProfitAndLossReport.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Ninja/Reports/ProfitAndLossReport.php b/app/Ninja/Reports/ProfitAndLossReport.php index 4cd0a47c9bfd..9370d91dfbd7 100644 --- a/app/Ninja/Reports/ProfitAndLossReport.php +++ b/app/Ninja/Reports/ProfitAndLossReport.php @@ -22,7 +22,7 @@ class ProfitAndLossReport extends AbstractReport $payments = Payment::scope() ->orderBy('payment_date', 'desc') - ->with('client.contacts') + ->with('client.contacts', 'invoice') ->withArchived() ->excludeFailed() ->where('payment_date', '>=', $this->startDate) @@ -30,6 +30,10 @@ class ProfitAndLossReport extends AbstractReport foreach ($payments->get() as $payment) { $client = $payment->client; + $invoice = $payment->invoice; + if ($client->is_deleted || $invoice->is_deleted) { + continue; + } $this->data[] = [ trans('texts.payment'), $client ? ($this->isExport ? $client->getDisplayName() : $client->present()->link) : '',