Minor work on ADSL/Domain/Hosting and other minor fixes

This commit is contained in:
Deon George
2011-10-11 10:38:21 +11:00
parent 0f45467ec8
commit 50a096e22a
12 changed files with 110 additions and 28 deletions

View File

@@ -18,7 +18,7 @@ class Model_Invoice extends ORMOSB {
);
protected $_has_many = array(
'invoice_item'=>array('far_key'=>'id'),
'invoice_item_tax'=>array(),
'invoice_item_tax'=>array('through'=>'invoice_item'),
'service'=>array('through'=>'invoice_item'),
'payment'=>array('through'=>'payment_item'),
'payment_item'=>array('far_key'=>'id'),
@@ -112,7 +112,11 @@ class Model_Invoice extends ORMOSB {
$result = 0;
foreach ($this->items() as $ito)
$result += $ito->tax_amt;
$result += $ito->tax();
// @todo This should eventually be removed.
if (! $result AND $this->tax_amt)
$result = $this->tax_amt;
return $format ? Currency::display($result) : $result;
}
@@ -188,7 +192,7 @@ class Model_Invoice extends ORMOSB {
*
* @param int Service ID
*/
private function items_service($sid) {
private function list_items_service($sid) {
return $this->invoice_item->where('service_id','=',$sid)->find_all();
}
@@ -198,7 +202,7 @@ class Model_Invoice extends ORMOSB {
public function items_service_total($sid) {
$total = 0;
foreach ($this->items_service($sid) as $ito)
foreach ($this->list_items_service($sid) as $ito)
$total += $ito->total();
return $total;
@@ -206,16 +210,19 @@ class Model_Invoice extends ORMOSB {
/**
* Calculate the tax of items for a service
* @todo This can be optimised
*/
public function items_service_tax($sid) {
$total = 0;
foreach ($this->items_service($sid) as $ito)
foreach ($this->list_items_service($sid) as $ito)
$total += $ito->tax_amt;
return $total;
}
// @todo Add discounts
/**
* Return a list of items based on a sort criteria
*/
@@ -242,6 +249,7 @@ class Model_Invoice extends ORMOSB {
/**
* Return a list of taxes used on this invoice
* @todo Move some of this to invoice_item_tax.
*/
public function tax_summary() {
$summary = array();
@@ -255,6 +263,10 @@ class Model_Invoice extends ORMOSB {
}
}
// @todo This should be removed eventually
if (! $summary AND $this->tax_amt)
$summary[1] = $this->tax_amt;
return $summary;
}