This commit is contained in:
David Bomba 2023-01-15 08:24:48 +11:00
parent f68d9ad37d
commit a19a48ac92

View File

@ -53,9 +53,9 @@ class ClientLedgerBalanceUpdate implements ShouldQueue
CompanyLedger::where('balance', 0)->where('client_id', $this->client->id)->orderBy('updated_at', 'ASC')->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) { if ($company_ledger->balance > 0) {
return;
}
}
else {
$last_record = CompanyLedger::where('client_id', $company_ledger->client_id) $last_record = CompanyLedger::where('client_id', $company_ledger->client_id)
->where('company_id', $company_ledger->company_id) ->where('company_id', $company_ledger->company_id)
->where('balance', '!=', 0) ->where('balance', '!=', 0)
@ -69,12 +69,10 @@ class ClientLedgerBalanceUpdate implements ShouldQueue
->first(); ->first();
} }
// nlog("Updating Balance NOW");
$company_ledger->balance = $last_record->balance + $company_ledger->adjustment; $company_ledger->balance = $last_record->balance + $company_ledger->adjustment;
$company_ledger->save(); $company_ledger->save();
}
}); });
// nlog("Updating company ledger for client ". $this->client->id);
} }
} }