From 6bcca461ef60546b5d464bcb74a648cf1f705e96 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 21 Sep 2021 22:50:44 +1000 Subject: [PATCH] Fixes for statements --- app/Services/Client/Statement.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index ea8f491e79dd..98cc4f798a99 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -279,10 +279,13 @@ class Statement private function getAgingAmount($range) { $ranges = $this->calculateDateRanges($range); -nlog($ranges); + $from = $ranges[0]; $to = $ranges[1]; +nlog("from ".$from->format("Y-m-d")); +nlog("to ".$to->format("Y-m-d")); + $client = Client::where('id', $this->client->id)->first(); $amount = Invoice::where('company_id', $this->client->company->id) @@ -291,7 +294,7 @@ nlog($ranges); ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) ->where('is_deleted', 0) - ->whereBetween('date', [$from, $to]) + ->whereBetween('date', [$to, $from]) ->sum('balance'); return Number::formatMoney($amount, $client);