From f0b9bb3673c574b1e41da54949810b3cc8324c49 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 13 Oct 2022 20:28:50 +1100 Subject: [PATCH] Minor fixes for company ledger --- app/Console/Commands/CheckData.php | 3 ++- app/Jobs/Ledger/ClientLedgerBalanceUpdate.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 36f0f9d8dd..8d6f4c65a6 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -712,6 +712,7 @@ class CheckData extends Command ->pluck('p') ->first(); + $over_payment = $over_payment*-1; $this->logMessage("# {$client->id} # {$client->name} {$client->balance} is invalid should be {$over_payment}"); @@ -719,7 +720,7 @@ class CheckData extends Command $this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." Fixing {$client->balance} to 0"); - $client->balance = $over_payment * -1; + $client->balance = $over_payment; $client->save(); } diff --git a/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php index 36055d693d..19db1c8290 100644 --- a/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php +++ b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php @@ -51,7 +51,7 @@ class ClientLedgerBalanceUpdate implements ShouldQueue MultiDB::setDb($this->company->db); - CompanyLedger::where('balance', 0)->where('client_id', $this->client->id)->cursor()->each(function ($company_ledger) { + CompanyLedger::where('balance', 0)->where('client_id', $this->client->id)->orderBy('updated_at', 'ASC')->cursor()->each(function ($company_ledger) { if ($company_ledger->balance > 0) { return; }