Updated charge, Invoice improvements and other minor fixes

This commit is contained in:
Deon George
2013-09-06 15:39:56 +10:00
parent 2322a802de
commit ab3735914b
52 changed files with 748 additions and 560 deletions

View File

@@ -11,27 +11,11 @@
*/
class Controller_Reseller_Account extends Controller_Account {
protected $secure_actions = array(
'ajaxlist'=>TRUE,
'list'=>TRUE,
'listlog'=>TRUE,
'view'=>TRUE,
);
/**
* Used by AJAX calls to find accounts
* @note list_autocomplete() will limit to authorised accounts
*/
public function action_ajaxlist() {
$result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term']))
$result += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
$this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($result)));
}
/**
* Show a list of accounts
*/
@@ -138,7 +122,7 @@ class Controller_Reseller_Account extends Controller_Account {
->title(sprintf('Next Invoice Items for Account: %s',$ao->accnum()))
->title_icon('icon-info-sign')
->span(6)
->body($i->render('html','body'));
->body($i->render('html','body',array('noid'=>TRUE)));
}
}
?>

View File

@@ -41,7 +41,7 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
// @todo To rework
public function after() {
$dc = 'u/welcome/index';
$dc = URL::link('user','welcome/index');
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);

View File

@@ -21,12 +21,12 @@ class Controller_User_Search extends Controller_Search {
$result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>'r/account/view/')));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>'u/invoice/view/')));
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>URL::link('reseller','account/view/'))));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>URL::link('user','invoice/view/'))));
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service_name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
}
$this->response->headers('Content-Type','application/json');

View File

@@ -10,11 +10,17 @@
* @license http://dev.osbill.net/license.html
*/
abstract class Minion_Task extends Kohana_Minion_Task {
protected $_options = array(
protected $_sysoptions = array(
'site'=>NULL,
'id'=>NULL,
'force'=>FALSE,
'verbose'=>FALSE,
);
/**
* Override our __construct so that we can specify options in each class file
*/
protected function __construct() {
// Populate $_accepted_options based on keys from $_options
$this->_accepted_options = array_keys(Arr::merge($this->_sysoptions,$this->_options));
}
}
?>

View File

@@ -14,6 +14,10 @@ class Model_Country extends ORM_OSB {
'currency'=>array('far_key'=>'id'),
);
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
public static function icon() {

View File

@@ -10,6 +10,10 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Currency extends ORM_OSB {
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
}
?>

View File

@@ -10,6 +10,10 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Language extends ORM_OSB {
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
}
?>

View File

@@ -27,6 +27,11 @@ abstract class ORM_OSB extends ORM {
// Our attribute values that need to be stored as serialized
protected $_serialize_column = array();
// If we need to load any sub items on loading this model
protected $_sub_items = array();
protected $_sub_items_load = array();
protected $_sub_items_sorted = FALSE;
// Rules to assist with site ID and getting next record ID for inserts.
public function rules() {
return array(
@@ -101,6 +106,25 @@ abstract class ORM_OSB extends ORM {
return parent::__get($column);
}
/**
* Intercept our object load, so that we can load our subitems
*/
protected function _load_values(array $values) {
parent::_load_values($values);
$sort = FALSE;
if ($this->_loaded AND $this->_sub_items_load AND count($this->_sub_items_load) == 1)
foreach ($this->_sub_items_load as $item => $sort)
$this->_sub_items = $this->$item->find_all()->as_array();
if ($sort) {
Sort::MAsort($this->_sub_items,$sort);
$this->_sub_items_sorted = TRUE;
}
return $this;
}
/**
* If a column is marked to be nullified if it is empty, this is where it is done.
*/
@@ -266,7 +290,7 @@ abstract class ORM_OSB extends ORM {
if ($this->_form AND array_intersect(array('id','value'),$this->_form))
foreach ($this->find_all() as $o)
$result[$o->{$this->_form['id']}] = $o->{$this->_form['value']};
$result[$o->{$this->_form['id']}] = $o->resolve($this->_form['value']);
return $result;
}

View File

@@ -12,8 +12,15 @@
class StaticList_ItemType extends StaticList {
protected function _table() {
return array(
0=>'MAIN', // Line Charge Topic on Invoice, eg: Service Name
5=>'EXCESS', // Excess Service Item, of item 0
0=>_('Product/Service Charge'), // Line Charge Topic on Invoice, eg: Service Name
1=> _('Hardware'),
2=> _('Service Relocation Fee'),
3=> _('Service Change Fee'),
4=> _('Service Connection Fee'),
5=>_('Excess Usage'), // Excess Service Item, of item 0
125=>_('Payment Fee'), // Payment processing fee
126=> _('Rounding'),
127=> _('Late Payment Fee'),
);
}

View File

@@ -4,7 +4,6 @@
* OSB Configuration - Authentication
*
* @package OSB
* @subpackage Authentication
* @category Configuration
* @author Deon George
* @copyright (c) 2010 Open Source Billing

View File

@@ -4,7 +4,6 @@
* OSB Caching
*
* @package OSB
* @subpackage System
* @category Configuration
* @author Deon George
* @copyright (c) 2010 Open Source Billing

View File

@@ -4,7 +4,6 @@
* OSB Configuration - System Default Configurable Items.
*
* @package OSB
* @subpackage System
* @category Configuration
* @author Deon George
* @copyright (c) 2010 Open Source Billing

View File

@@ -4,7 +4,6 @@
* OSB Configuration - Database Driver
*
* @package OSB
* @subpackage Database
* @category Configuration
* @author Deon George
* @copyright (c) 2010 Open Source Billing

View File

@@ -4,7 +4,6 @@
* OSB Configuration - Debug Settings
*
* @package OSB
* @subpackage Debug
* @category Configuration
* @author Deon George
* @copyright (c) 2010 Open Source Billing

View File

@@ -4,7 +4,6 @@
* OSB Configuration - PWGen Configuration
*
* @package OSB
* @subpackage PWGen
* @category PWGen
* @author Deon George
* @copyright (c) 2010 Open Source Billing

View File

@@ -0,0 +1,187 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Test that PeriodTest is doing as expected
*
* @group osb
* @group osb.helpers
*/
class PeriodTest extends UnitTest_TestCase {
private $DATE = '2012-07-20'; // Fri (5)
private $TIME;
public function __construct() {
parent::__construct();
$this->TIME = strtotime($this->DATE);
$this->w = date('w',$this->TIME);
}
// Weekly
public function test_weekly() {
# +7 week
foreach (array(0,2,6) as $x) {
$p = Period::details(0,NULL,$this->TIME+86400*$x,TRUE,FALSE);
$this->assertEquals(date('d-M-Y',$this->TIME+86400*(7+$x-1)),$p['end']);
}
# +7 week, SUN
foreach (array(0,2,6) as $x) {
$p = Period::details(0,0,$this->TIME+86400*$x,TRUE,FALSE);
$this->assertEquals(date('d-M-Y',$this->TIME+86400*(7-($this->w+$x)%7+$x-1)),$p['end']); // Sat
}
# +7 week, TUE
foreach (array(0,2,6) as $x) {
$p = Period::details(0,2,$this->TIME+86400*$x,TRUE,FALSE);
$this->assertEquals(date('d-M-Y',$this->TIME+86400*(7-($this->w+$x)%7+$x-1+2)),$p['end']); // Sat
}
}
public function test_monthly() {
# +1 month
$p = Period::details(1,NULL,strtotime('2012-07-20'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-08-19')),$p['end']);
$p = Period::details(1,NULL,strtotime('2012-07-01'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
$p = Period::details(1,NULL,strtotime('2012-07-31'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-08-30')),$p['end']);
# +1 month, 1st of the month
$p = Period::details(1,1,strtotime('2012-07-20'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
$p = Period::details(1,1,strtotime('2012-07-01'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
$p = Period::details(1,1,strtotime('2012-07-31'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
# +1 month, 15th of the month
$p = Period::details(1,15,strtotime('2012-07-20'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-08-14')),$p['end']);
$p = Period::details(1,15,strtotime('2012-02-20'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-03-14')),$p['end']);
$p = Period::details(1,15,strtotime('2012-02-14'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-02-14')),$p['end']);
$p = Period::details(1,15,strtotime('2012-02-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-03-14')),$p['end']);
# +1 month, 1st of the month, strict doesnt have any affect
$p = Period::details(1,1,strtotime('2012-07-20'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
$p = Period::details(1,1,strtotime('2012-07-01'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
$p = Period::details(1,1,strtotime('2012-07-31'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
}
public function test_quarterly() {
# +3 months
$p = Period::details(2,NULL,strtotime('2012-02-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-05-14')),$p['end']);
$p = Period::details(2,NULL,strtotime('2012-11-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2013-02-14')),$p['end']);
$p = Period::details(2,NULL,strtotime('2012-08-20'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-11-19')),$p['end']);
# +3 months, 1st of the month
$p = Period::details(2,1,strtotime('2012-08-20'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-10-31')),$p['end']);
$p = Period::details(2,1,strtotime('2012-11-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2013-01-31')),$p['end']);
# +3 months, 1st of the month, strict JAN-MAR,APR-JUN,JUL-SEP,OCT-DEC
$p = Period::details(2,1,strtotime('2012-11-15'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-12-31')),$p['end']);
$p = Period::details(2,1,strtotime('2013-01-01'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2013-03-31')),$p['end']);
}
public function test_halfyearly() {
# +6 months
$p = Period::details(3,NULL,strtotime('2012-02-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-08-14')),$p['end']);
$p = Period::details(3,NULL,strtotime('2011-09-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-03-14')),$p['end']);
# +6 months, 1st of the month
$p = Period::details(3,1,strtotime('2012-02-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-07-31')),$p['end']);
$p = Period::details(3,1,strtotime('2011-09-15'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2012-02-29')),$p['end']);
# +6 months, 1st of the month, strict JAN-JUN,JUL-DEC
$p = Period::details(3,1,strtotime('2012-02-15'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-06-30')),$p['end']);
$p = Period::details(3,1,strtotime('2012-01-01'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-06-30')),$p['end']);
}
public function test_yearly() {
# +1 year
$p = Period::details(4,NULL,strtotime('2012-02-29'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2013-02-28')),$p['end']);
# +1 year, 1st of the month
$p = Period::details(4,1,strtotime('2012-02-29'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2013-01-31')),$p['end']);
$p = Period::details(4,1,strtotime('2012-02-01'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2013-01-31')),$p['end']);
# +1 year, 1st of the month, strict JAN-DEC
$p = Period::details(4,1,strtotime('2012-02-29'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-12-31')),$p['end']);
$p = Period::details(4,1,strtotime('2012-12-31'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2012-12-31')),$p['end']);
$p = Period::details(4,1,strtotime('2013-02-28'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2013-12-31')),$p['end']);
$p = Period::details(4,1,strtotime('2013-12-31'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2013-12-31')),$p['end']);
}
public function test_twoyear() {
# +2 year
$p = Period::details(5,NULL,strtotime('2012-02-29'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2014-02-28')),$p['end']);
# +2 year, 1st of the month
$p = Period::details(5,1,strtotime('2012-02-29'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2014-01-31')),$p['end']);
$p = Period::details(5,1,strtotime('2012-02-01'),TRUE,FALSE);
$this->assertEquals(date('d-M-Y',strtotime('2014-01-31')),$p['end']);
# +2 year, 1st of the month, strict JAN/YEAR%2
$p = Period::details(5,1,strtotime('2012-02-29'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2013-12-31')),$p['end']);
$p = Period::details(5,1,strtotime('2012-01-31'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2013-12-31')),$p['end']);
$p = Period::details(5,1,strtotime('2013-01-31'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2014-12-31')),$p['end']);
$p = Period::details(5,1,strtotime('2012-12-31'),TRUE,TRUE);
$this->assertEquals(date('d-M-Y',strtotime('2013-12-31')),$p['end']);
}
}
?>

View File

@@ -9,11 +9,9 @@
<?php echo Form::input('email',$o->display('email'),array('label'=>'Email','class'=>'input-xxlarge','placeholder'=>'Email Address','type'=>'email','required')); ?>
<div class="row">
<div class="span1">
<?php echo Form::select('title',StaticList_Title::table(),$o->display('title'),array('class'=>'input-small','label'=>'Title','required')); ?>
</div>
<?php echo Form::select('title',StaticList_Title::table(),$o->display('title'),array('class'=>'input-small','label'=>'Title','required')); ?>
<div class="row">
<div class="span2">
<?php echo Form::input('first_name',$o->display('first_name'),array('label'=>'','class'=>'input-medium','placeholder'=>'First Name','required')); ?>
</div>
@@ -21,7 +19,6 @@
<div class="span3">
<?php echo Form::input('last_name',$o->display('last_name'),array('label'=>'','class'=>'input-large','placeholder'=>'Last Name','required')); ?>
</div>
</div>
<?php echo Form::input('company',$o->display('company'),array('label'=>'Company','class'=>'input-xxlarge','placeholder'=>'Company Name')); ?>