Improved ADSL Billing Review
This commit is contained in:
@@ -17,27 +17,41 @@ class Model_ADSL_Supplier extends ORM_OSB {
|
||||
'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Return a list of plans that this supplier makes available
|
||||
*/
|
||||
public function plans($active=TRUE) {
|
||||
return $active ? $this->adsl_supplier_plan->where_active() : $this->adsl_supplier_plan;
|
||||
}
|
||||
protected $_form = array('id'=>'id','value'=>'name');
|
||||
|
||||
/**
|
||||
* Return a list of plans that we provide by this supplier
|
||||
* @deprecated
|
||||
*/
|
||||
public function adsl_plans($active=TRUE) {
|
||||
public function plans($active=TRUE) {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->plans($active)->find_all() as $po)
|
||||
foreach ($this->find_plans($active)->find_all() as $po)
|
||||
foreach ($po->adsl_plan->find_all() as $apo)
|
||||
$result[$apo->id] = $apo;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class that takes care of processing invoices
|
||||
*/
|
||||
public function billing() {
|
||||
$b = Kohana::classname('ADSL_Billing_'.$this->name);
|
||||
|
||||
if (! class_exists($b))
|
||||
throw HTTP_Exception::factory(501,'Billing class doesnt exist for :name',array(':name'=>$this->name));
|
||||
|
||||
return new $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of plans that this supplier makes available
|
||||
*/
|
||||
public function find_plans($active=TRUE) {
|
||||
return $active ? $this->adsl_supplier_plan->where_active() : $this->adsl_supplier_plan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of services for this supplier
|
||||
*
|
||||
@@ -46,7 +60,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
|
||||
public function services($active=TRUE) {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->plans(FALSE)->find_all() as $aspo) {
|
||||
foreach ($this->find_plans(FALSE)->find_all() as $aspo) {
|
||||
foreach ($aspo->adsl_plan->find_all() as $apo) {
|
||||
foreach ($apo->products(FALSE)->find_all() as $po) {
|
||||
foreach ($po->services($active)->find_all() as $so) {
|
||||
|
@@ -25,14 +25,16 @@ class Model_ADSL_Supplier_Plan extends ORM_OSB {
|
||||
return sprintf('%s/%s',$this->base_down_peak+$this->base_up_peak,$this->base_down_offpeak+$this->base_up_offpeak);
|
||||
}
|
||||
|
||||
public function tax() {
|
||||
// @todo This should be taken from the users session
|
||||
// @todo rounding should be a system default
|
||||
return round($this->base_cost*.1,2);
|
||||
}
|
||||
|
||||
public function name() {
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
public function tax() {
|
||||
return Tax::amount($this->base_cost);
|
||||
}
|
||||
|
||||
public function total($format=FALSE) {
|
||||
return $format ? Currency::display($this->base_cost+$this->tax()) : Currency::round($this->base_cost+$this->tax());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user