Consistent use of return , payment refund handling

This commit is contained in:
Deon George
2013-04-05 23:50:08 +11:00
parent 43dfd88bce
commit 52d9005b64
30 changed files with 255 additions and 210 deletions

View File

@@ -33,13 +33,13 @@ class Model_Adsl_Supplier extends ORM_OSB {
* Return a list of plans that we provide by this supplier
*/
public function adsl_plans($active=TRUE) {
$return = array();
$result = array();
foreach ($this->plans($active)->find_all() as $po)
foreach ($po->adsl_plan->find_all() as $apo)
$return[$apo->id] = $apo;
$result[$apo->id] = $apo;
return $return;
return $result;
}
/**

View File

@@ -111,23 +111,23 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
* Calculate the total traffic used in a month
*/
private function get_traffic_data_month($period=NULL,$cache=NULL) {
$return = array();
$result = array();
foreach ($this->get_traffic_data_daily($period,TRUE,$cache) as $tdata)
foreach ($tdata as $k => $v)
if (isset($return[$k]))
$return[$k] += $v;
if (isset($result[$k]))
$result[$k] += $v;
else
$return[$k] = $v;
$result[$k] = $v;
return $return;
return $result;
}
/**
* Return an array of the data used in a month by day
*/
public function get_traffic_data_daily($period=NULL,$bydate=FALSE,$cache=NULL) {
$return = array();
$result = array();
// @temp - caching is broken?
$cache=0;
@@ -144,20 +144,20 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
$day = date('d',strtotime($to->date));
if ($bydate)
$return[$day] = $to->traffic($this->service->product->plugin());
$result[$day] = $to->traffic($this->service->product->plugin());
else
foreach ($to->traffic($this->service->product->plugin()) as $k => $v)
$return[$k][$day] = $v;
$result[$k][$day] = $v;
}
return $return;
return $result;
}
/**
* Return an array of the data used in a year by month
*/
public function get_traffic_data_monthly($period=NULL,$bydate=FALSE) {
$return = array();
$result = array();
if (is_null($period))
$period = strtotime('yesterday');
@@ -177,12 +177,12 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
foreach ($t->find_all() as $to)
if ($bydate)
$return[$to->month] = $to->traffic($this->service->product->plugin());
$result[$to->month] = $to->traffic($this->service->product->plugin());
else
foreach ($to->traffic($this->service->product->plugin()) as $k => $v)
$return[$k][$to->month] = $v;
$result[$k][$to->month] = $v;
return $return;
return $result;
}
public function traffic_month($month,$string=TRUE,$cache=NULL) {
@@ -200,7 +200,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
}
public function traffic_lastmonth_exceed($all=FALSE,$date=NULL) {
$return = array();
$result = array();
if (is_null($date))
$date = strtotime('last month')-86400;
@@ -208,16 +208,16 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
foreach ($this->traffic_month($date,FALSE,0) as $k => $v) {
// We shouldnt need to eval for nulls, since the traffic calc does that
if ($all OR ($v > $this->service->product->plugin()->$k)) {
$return[$k]['allowance'] = $this->service->product->plugin()->$k;
$return[$k]['used'] = $v;
$return[$k]['shaped'] = (! empty($this->service->product->plugin()->extra_shaped) AND $this->service->product->plugin()->extra_shaped AND $v > $this->service->product->plugin()->$k) ? TRUE : FALSE;
$return[$k]['excess'] = (! empty($this->service->product->plugin()->extra_charged) AND $this->service->product->plugin()->extra_charged AND $v > $this->service->product->plugin()->$k) ? $v-$this->service->product->plugin()->$k : 0;
$return[$k]['rate'] = $this->service->product->plugin()->{ADSL::map($k)};
$return[$k]['charge'] = ceil(($return[$k]['excess'])/1000)*$return[$k]['rate'];
$result[$k]['allowance'] = $this->service->product->plugin()->$k;
$result[$k]['used'] = $v;
$result[$k]['shaped'] = (! empty($this->service->product->plugin()->extra_shaped) AND $this->service->product->plugin()->extra_shaped AND $v > $this->service->product->plugin()->$k) ? TRUE : FALSE;
$result[$k]['excess'] = (! empty($this->service->product->plugin()->extra_charged) AND $this->service->product->plugin()->extra_charged AND $v > $this->service->product->plugin()->$k) ? $v-$this->service->product->plugin()->$k : 0;
$result[$k]['rate'] = $this->service->product->plugin()->{ADSL::map($k)};
$result[$k]['charge'] = ceil(($result[$k]['excess'])/1000)*$result[$k]['rate'];
}
}
return $return;
return $result;
}
public function template_variables($array) {
@@ -228,7 +228,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
'cumulative_base_down_offpeak'=>'Total OffPeak',
);
$return = array();
$result = array();
if ($this->service->product->prod_plugin_file != 'ADSL')
throw new Kohana_Exception('Huh? How did this get called, for a non ADSL product (:ppf)',array(':ppf'=>$this->service_id));
@@ -280,10 +280,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
$value = '';
}
$return[$item] = $value;
$result[$item] = $value;
}
return $return;
return $result;
}
/**