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:
parent
7dbb8154f5
commit
26ef7c7c0d
@ -167,21 +167,24 @@ class CreditService
|
||||
|
||||
public function adjustBalance($adjustment)
|
||||
{
|
||||
$this->credit->balance += $adjustment;
|
||||
// $this->credit->balance += $adjustment;
|
||||
$this->credit->increment('balance', $adjustment);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function updatePaidToDate($adjustment)
|
||||
{
|
||||
$this->credit->paid_to_date += $adjustment;
|
||||
// $this->credit->paid_to_date += $adjustment;
|
||||
$this->credit->increment('paid_to_date', $adjustment);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function updateBalance($adjustment)
|
||||
{
|
||||
$this->credit->balance -= $adjustment;
|
||||
// $this->credit->balance -= $adjustment;
|
||||
$this->credit->decrement('balance', $adjustment);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -34,17 +34,20 @@ class UpdateBalance extends AbstractService
|
||||
if ($this->invoice->is_deleted) {
|
||||
return $this->invoice;
|
||||
}
|
||||
nlog("invoice id = {$this->invoice->id}");
|
||||
nlog("invoice balance = {$this->invoice->balance}");
|
||||
nlog("invoice adjustment = {$this->balance_adjustment}");
|
||||
|
||||
$this->invoice->balance += floatval($this->balance_adjustment);
|
||||
nlog("invoice id = {$this->invoice->id}");
|
||||
nlog("invoice balance = {$this->invoice->balance}");
|
||||
nlog("invoice adjustment = {$this->balance_adjustment}");
|
||||
|
||||
// $this->invoice->balance += floatval($this->balance_adjustment);
|
||||
|
||||
$this->invoice->increment('balance', floatval($this->balance_adjustment));
|
||||
|
||||
if ($this->invoice->balance == 0 && !$this->is_draft) {
|
||||
$this->invoice->status_id = Invoice::STATUS_PAID;
|
||||
}
|
||||
|
||||
nlog("final balance = {$this->invoice->balance}");
|
||||
nlog("final balance = {$this->invoice->balance}");
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user