Updates to invoice display

This commit is contained in:
Deon George
2011-08-02 16:20:11 +10:00
parent c8c4c5176d
commit 41eec89afa
11 changed files with 137 additions and 11 deletions

View File

@@ -21,7 +21,9 @@ class Model_Payment extends ORMOSB {
'checkout'=>array('foreign_key'=>'checkout_plugin_id'),
);
protected $_sorting = array('date_payment'=>'DESC');
protected $_sorting = array(
'date_payment'=>'DESC'
);
protected $_display_filters = array(
'date_payment'=>array(
@@ -42,4 +44,32 @@ class Model_Payment extends ORMOSB {
->where('date_payment','>=',time()-$start*86400)
->find_all();
}
/**
* Calculate the remaining balance available for this payment
*/
public function balance($format=FALSE) {
$t = 0;
foreach ($this->payment_item->find_all() as $pio)
$t += $pio->alloc_amt;
return $format ? Currency::display($this->total_amt-$t) : $this->total_amt-$t;
}
/**
* Return a list of invoices that this payment is applied to
*/
public function invoices() {
$invoices = array();
foreach ($this->payment_item->find_all() as $pio)
array_push($invoices,$pio->invoice);
return $invoices;
}
public function invoicelist() {
return join(',',$this->invoices());
}
}