1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Working on ledger balances

This commit is contained in:
David Bomba 2023-11-08 15:43:08 +11:00
parent 7328a2ff7a
commit 7325a66c47
2 changed files with 5 additions and 2 deletions

View File

@ -290,7 +290,7 @@ class BaseRepository
/* Perform model specific tasks */ /* Perform model specific tasks */
if ($model instanceof Invoice) { if ($model instanceof Invoice) {
if ($model->status_id != Invoice::STATUS_DRAFT && ($state['starting_amount'] != $state['finished_amount'])) { if ($model->status_id != Invoice::STATUS_DRAFT) {
$model->service()->updateStatus()->save(); $model->service()->updateStatus()->save();
$model->client->service()->calculateBalance(); $model->client->service()->calculateBalance();
$model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount']), "Update adjustment for invoice {$model->number}"); $model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount']), "Update adjustment for invoice {$model->number}");

View File

@ -36,7 +36,9 @@ class LedgerService
// $hash = sha1($adjustment.$notes.$this->entity->status_id.$this->entity->client_id.$this->entity->amount.$this->entity->balance.$this->entity->company_id.Activity::UPDATE_INVOICE); // $hash = sha1($adjustment.$notes.$this->entity->status_id.$this->entity->client_id.$this->entity->amount.$this->entity->balance.$this->entity->company_id.Activity::UPDATE_INVOICE);
// $hash = sha1($hash); // $hash = sha1($hash);
// $hash = sha1("{$this->entity->amount}.{$this->entity->balance}"); // $hash = sha1("{$this->entity->amount}.{$this->entity->balance}");
$hash = "{$this->entity->amount}.{$this->entity->balance}"; $hash = "{$adjustment}.{$this->entity->amount}.{$this->entity->balance}";
usleep(10000000);
$exists = CompanyLedger::query() $exists = CompanyLedger::query()
->where('client_id', $this->entity->client_id) ->where('client_id', $this->entity->client_id)
@ -49,6 +51,7 @@ class LedgerService
->exists(); ->exists();
if($exists) { if($exists) {
nlog("Collision {$adjustment} {$notes}");
return $this; return $this;
} }