/** * Return paid amount * * @param boolean $cache * @return float */ function getPaidAmount($cache = true) { if ($cache == false || $this->paid_amount === false) { $this->paid_amount = InvoicePayments::sumByInvoice($this); } // if return $this->paid_amount; }