mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Bug fixes
This commit is contained in:
parent
4a0906a92c
commit
dede870fed
@ -194,13 +194,17 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
|
||||
public function updatePaidStatus($save = true)
|
||||
{
|
||||
if ($this->isPaid() && $this->balance > 0) {
|
||||
$this->invoice_status_id = ($this->balance == $this->amount ? INVOICE_STATUS_SENT : INVOICE_STATUS_PARTIAL);
|
||||
if ($save) {
|
||||
$this->save();
|
||||
$statusId = false;
|
||||
if ($this->amount > 0 && $this->balance == 0) {
|
||||
$statusId = INVOICE_STATUS_PAID;
|
||||
} elseif ($this->balance > 0 && $this->balance < $this->amount) {
|
||||
$statusId = INVOICE_STATUS_PARTIAL;
|
||||
} elseif ($this->isPartial() && $this->balance > 0) {
|
||||
$statusId = ($this->balance == $this->amount ? INVOICE_STATUS_SENT : INVOICE_STATUS_PARTIAL);
|
||||
}
|
||||
} elseif ($this->invoice_status_id && $this->amount > 0 && $this->balance == 0 && $this->invoice_status_id != INVOICE_STATUS_PAID) {
|
||||
$this->invoice_status_id = INVOICE_STATUS_PAID;
|
||||
|
||||
if ($statusId && $statusId != $this->invoice_status_id) {
|
||||
$this->invoice_status_id = $statusId;
|
||||
if ($save) {
|
||||
$this->save();
|
||||
}
|
||||
@ -263,6 +267,11 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return $this->invoice_status_id >= INVOICE_STATUS_VIEWED;
|
||||
}
|
||||
|
||||
public function isPartial()
|
||||
{
|
||||
return $this->invoice_status_id >= INVOICE_STATUS_PARTIAL;
|
||||
}
|
||||
|
||||
public function isPaid()
|
||||
{
|
||||
return $this->invoice_status_id >= INVOICE_STATUS_PAID;
|
||||
|
Loading…
x
Reference in New Issue
Block a user