1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Refactor to use increments

This commit is contained in:
David Bomba 2022-03-09 14:44:05 +11:00
parent b2b937f9ad
commit 7dbb8154f5
3 changed files with 20 additions and 7 deletions

View File

@ -737,7 +737,7 @@ ORDER BY clients.id;
$this->logMessage($client_object->present()->name.' - '.$client_object->id." - calculated client balances do not match Invoice Balances = {$invoice_balance} - Client Balance = ".rtrim($client['client_balance'], '0'). " Ledger balance = {$ledger->balance}");
if($this->option('client_balance')){
if($this->option('ledger_balance')){
$this->logMessage("# {$client_object->id} " . $client_object->present()->name.' - '.$client_object->number." Fixing {$client_object->balance} to {$invoice_balance}");
$client_object->balance = $invoice_balance;

View File

@ -28,21 +28,27 @@ class ClientService
public function updateBalance(float $amount)
{
$this->client->balance += $amount;
// $this->client->balance += $amount;
$this->client->increment('balance', $amount);
return $this;
}
public function updatePaidToDate(float $amount)
{
$this->client->paid_to_date += $amount;
// $this->client->paid_to_date += $amount;
$this->client->increment('paid_to_date', $amount);
return $this;
}
public function adjustCreditBalance(float $amount)
{
$this->client->credit_balance += $amount;
// $this->client->credit_balance += $amount;
$this->client->increment('credit_balance', $amount);
return $this;
}

View File

@ -145,8 +145,11 @@ class InvoiceService
return $this;
}
$this->invoice->balance += $balance_adjustment;
// $this->invoice->balance += $balance_adjustment;
$this->invoice->increment('balance', $balance_adjustment);
if (round($this->invoice->balance,2) == 0 && !$is_draft) {
$this->invoice->status_id = Invoice::STATUS_PAID;
}
@ -160,7 +163,10 @@ class InvoiceService
public function updatePaidToDate($adjustment)
{
$this->invoice->paid_to_date += $adjustment;
// $this->invoice->paid_to_date += $adjustment;
$this->invoice->increment('paid_to_date', $adjustment);
return $this;
}
@ -381,7 +387,8 @@ class InvoiceService
/*Update the partial amount of a invoice*/
public function updatePartial($amount)
{
$this->invoice->partial += $amount;
// $this->invoice->partial += $amount;
$this->invoice->increment('partial', $amount);
return $this;
}