mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
clean up
This commit is contained in:
parent
f68d9ad37d
commit
a19a48ac92
@ -53,28 +53,26 @@ class ClientLedgerBalanceUpdate implements ShouldQueue
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
$last_record = CompanyLedger::where('client_id', $company_ledger->client_id)
|
||||
->where('company_id', $company_ledger->company_id)
|
||||
->where('balance', '!=', 0)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
|
||||
if (! $last_record) {
|
||||
else {
|
||||
$last_record = CompanyLedger::where('client_id', $company_ledger->client_id)
|
||||
->where('company_id', $company_ledger->company_id)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
->where('company_id', $company_ledger->company_id)
|
||||
->where('balance', '!=', 0)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
|
||||
if (! $last_record) {
|
||||
$last_record = CompanyLedger::where('client_id', $company_ledger->client_id)
|
||||
->where('company_id', $company_ledger->company_id)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
}
|
||||
|
||||
// nlog("Updating Balance NOW");
|
||||
|
||||
$company_ledger->balance = $last_record->balance + $company_ledger->adjustment;
|
||||
$company_ledger->save();
|
||||
$company_ledger->balance = $last_record->balance + $company_ledger->adjustment;
|
||||
$company_ledger->save();
|
||||
}
|
||||
});
|
||||
|
||||
// nlog("Updating company ledger for client ". $this->client->id);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user