app\models\Invoice::updatePaidStatus PHP Method

updatePaidStatus() public method

public updatePaidStatus ( boolean $save = true )
$save boolean
    public function updatePaidStatus($save = true)
    {
        $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;
        }
        if ($statusId && $statusId != $this->invoice_status_id) {
            $this->invoice_status_id = $statusId;
            if ($save) {
                $this->save();
            }
        }
    }