From e0e0c238c675091810e5c67f5cda6d55bfad662d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 24 Jul 2023 07:42:55 +1000 Subject: [PATCH] Add totals for AR Summary Reports --- app/Services/Report/ARSummaryReport.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Services/Report/ARSummaryReport.php b/app/Services/Report/ARSummaryReport.php index ebbb891cfee7..0fd0d5b83dfb 100644 --- a/app/Services/Report/ARSummaryReport.php +++ b/app/Services/Report/ARSummaryReport.php @@ -19,7 +19,6 @@ use App\Models\Invoice; use App\Utils\Ninja; use App\Utils\Number; use App\Utils\Traits\MakesDates; -use Carbon\Carbon; use Illuminate\Support\Facades\App; use League\Csv\Writer; @@ -33,6 +32,8 @@ class ARSummaryReport extends BaseExport public Client $client; + private float $total = 0; + public array $report_keys = [ 'client_name', 'client_number', @@ -101,7 +102,7 @@ class ARSummaryReport extends BaseExport { $this->client = $client; - return [ + $row = [ $this->client->present()->name(), $this->client->number, $this->client->id_number, @@ -111,7 +112,12 @@ class ARSummaryReport extends BaseExport $this->getAgingAmount('90'), $this->getAgingAmount('120'), $this->getAgingAmount('120+'), + Number::formatMoney($this->total, $this->client), ]; + + $this->total = 0; + + return $row; } private function getCurrent(): string @@ -128,6 +134,8 @@ class ARSummaryReport extends BaseExport }) ->sum('balance'); + $this->total += $amount; + return Number::formatMoney($amount, $this->client); } @@ -153,6 +161,8 @@ class ARSummaryReport extends BaseExport ->whereBetween('due_date', [$to, $from]) ->sum('balance'); + $this->total += $amount; + return Number::formatMoney($amount, $this->client); }