Misc fixes for ADSL excess traffic and strtotime() functions for last month

This commit is contained in:
Deon George 2013-12-31 17:18:49 +11:00
parent e19518c505
commit 82c51de550
11 changed files with 27 additions and 15 deletions

View File

@ -20,6 +20,7 @@ class StaticList_ItemType extends StaticList {
5=>_('Excess Usage'), // Excess Service Item, of item 0
6=>_('Service Cancellation Fee'),
7=>_('Extra Product/Service Charge'), // Service Billing in advance
8=>_('Product Addition'), // Additional Product Customisation
124=>_('Late Payment Fee'),
125=>_('Payment Fee'), // Payment processing fee
126=>_('Other'),

View File

@ -124,7 +124,7 @@ class Controller_Admin_Adsl extends Controller_Adsl {
$a = 0;
foreach (array_reverse($traffic) as $i) {
if ($i < $so->plugin()->traffic_month(strtotime('last month'),TRUE))
if ($i < $so->plugin()->traffic_month(strtotime('first day of last month'),TRUE))
break;
$a = $i;

View File

@ -72,7 +72,7 @@ class Controller_Reseller_Service_Adsl extends Controller_Service {
'product->plugin()->supplier_plan->speed'=>'Speed',
'product->plugin()->allowance(array(),TRUE,TRUE,TRUE)'=>'Allowance',
'plugin()->traffic_month(strtotime("yesterday"),TRUE,TRUE)'=>'This Month',
'plugin()->traffic_month(strtotime("last month"),TRUE,TRUE)'=>'Last Month',
'plugin()->traffic_month(strtotime("first day of last month"),TRUE,TRUE)'=>'Last Month',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Price',
'account->accnum()'=>'Cust ID',

View File

@ -135,8 +135,15 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
if (! isset($data[$k]))
$data[$k] = 0;
if ($over)
$data[$k] = $invert ? $this->{$k} : $data[$k]-$this->{$k};
if ($over) {
// @todo This is an ugly hack - if our data has been passed it, it is assumed it has been reduced by $this->metric
$z = $this->metric ? round($this->{$k}/$this->metric,2) : $this->{$k};
$data[$k] = $invert ? $z : $data[$k]-$z;
// We need to return this back to base units as later, we'll return it back to metric
$data[$k] = $this->metric ? $data[$k]*$this->metric : $data[$k];
}
// Do we charge for extra, or merge it to another field
if (! is_null($this->{$v})) {

View File

@ -15,7 +15,7 @@ class Task_Adsl_Trafficalert extends Minion_Task {
);
protected function _execute(array $params) {
$date = strtotime('last month');
$date = strtotime('first day of last month');
$c = array();
// @todo Pick up services that are no longer active, but were inactive < 30 days ago.

View File

@ -15,7 +15,7 @@ class Task_Adsl_Trafficcharge extends Minion_Task {
);
protected function _execute(array $params) {
$date = strtotime('last month');
$date = strtotime('first day of last month');
$c = array();
// @todo Pick up services that are no longer active, but were inactive < 30 days ago.

View File

@ -41,7 +41,7 @@
<div class="dl-horizontal">
<dt>Last Month</dt>
<dd>&nbsp;<?php echo $o->traffic_month(strtotime('last month'),TRUE,TRUE); ?></dd>
<dd>&nbsp;<?php echo $o->traffic_month(strtotime('first day of last month'),TRUE,TRUE); ?></dd>
<dt>This Month</dt>
<dd>&nbsp;<?php echo $o->traffic_month(strtotime('yesterday'),TRUE,TRUE); ?></dd>

View File

@ -12,6 +12,7 @@
class Model_Charge extends ORM_OSB implements Invoicable {
protected $_belongs_to = array(
'account'=>array(),
'product'=>array(),
'service'=>array(),
);
protected $_has_one = array(

View File

@ -1,4 +1,4 @@
<fieldset class="span5">
<fieldset>
<legend>Service Details</legend>
<div class="dl-horizontal">

View File

@ -1,4 +1,4 @@
<fieldset class="span5">
<fieldset>
<legend>Service Details</legend>
<div class="dl-horizontal">

View File

@ -61,7 +61,7 @@ class Model_Invoice_Item extends ORM_OSB {
case 1:
// @todo
return $ii;
return $this->product_name;
case 2:
case 3:
@ -70,6 +70,9 @@ class Model_Invoice_Item extends ORM_OSB {
case 6:
return ((! $this->service_id OR $this->product_id OR $this->charge_id OR $this->product_name OR $this->recurring_schedule OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii;
case 8:
return $this->product_name;
case 124:
case 125:
case 126: