public function getAmountPaid($calculate = false)
{
if ($this->isType(INVOICE_TYPE_QUOTE) || $this->is_recurring) {
return 0;
}
if ($calculate) {
$amount = 0;
foreach ($this->payments as $payment) {
if ($payment->payment_status_id == PAYMENT_STATUS_VOIDED || $payment->payment_status_id == PAYMENT_STATUS_FAILED) {
continue;
}
$amount += $payment->getCompletedAmount();
}
return $amount;
} else {
return $this->amount - $this->balance;
}
}