From 8a1142e69615a211a7f26ee4e2307ef94e232250 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 7 Feb 2017 09:17:42 +0200 Subject: [PATCH] Fix date range in profit/loss report --- app/Ninja/Reports/ProfitAndLossReport.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Ninja/Reports/ProfitAndLossReport.php b/app/Ninja/Reports/ProfitAndLossReport.php index c936feaf9f0f..919c57153792 100644 --- a/app/Ninja/Reports/ProfitAndLossReport.php +++ b/app/Ninja/Reports/ProfitAndLossReport.php @@ -23,7 +23,9 @@ class ProfitAndLossReport extends AbstractReport $payments = Payment::scope() ->with('client.contacts') ->withArchived() - ->excludeFailed(); + ->excludeFailed() + ->where('payment_date', '>=', $this->startDate) + ->where('payment_date', '<=', $this->endDate); foreach ($payments->get() as $payment) { $client = $payment->client; @@ -42,7 +44,9 @@ class ProfitAndLossReport extends AbstractReport $expenses = Expense::scope() ->with('client.contacts') - ->withArchived(); + ->withArchived() + ->where('expense_date', '>=', $this->startDate) + ->where('expense_date', '<=', $this->endDate); foreach ($expenses->get() as $expense) { $client = $expense->client;