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; }