Revamping invoice PDF rendering and standardisation work

This commit is contained in:
Deon George
2016-08-10 16:07:00 +10:00
parent a560c5f4fa
commit 24bb4a701b
27 changed files with 229 additions and 475 deletions

View File

@@ -116,6 +116,15 @@ class Model_Service extends ORM_OSB {
return $this->_plugin;
}
/**
* Get the attributes of the service
*
* @return an array of attributes
*/
public function attributes($variable=NULL) {
return ($this->_plugin()) ? $this->_plugin()->attributes() : array();
}
/**
* Get the additional charges associated with this service
*/
@@ -178,13 +187,6 @@ class Model_Service extends ORM_OSB {
return time()+$days*86400 > $this->expire();
}
/**
* Display the service number
*/
public function id() {
return sprintf('%05s',$this->id);
}
/**
* List invoices for this service
*/
@@ -291,10 +293,6 @@ class Model_Service extends ORM_OSB {
return $this->price(TRUE)*$multiple;
}
public function service_change() {
return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
}
/**
* Return the service charge
*/
@@ -313,19 +311,8 @@ class Model_Service extends ORM_OSB {
return $format ? Currency::display($p) : $p;
}
/**
* Render some details for specific calls, eg: invoice
*/
public function details($type) {
$plugin = $this->plugin();
switch ($type) {
case 'invoice_detail_items':
return is_null($plugin) ? array() : $plugin->_details($type);
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
public function service_change() {
return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
}
public function service_view() {
@@ -368,7 +355,6 @@ class Model_Service extends ORM_OSB {
public function list_byplugin($plugin) {
return $this
->join('product')
->on($this->table_name().'.site_id','=','product.site_id') // @todo This should be automatic
->on($this->table_name().'.product_id','=','product.id')
->where('prod_plugin_file','=',$plugin)
->and_where('service.status','=',TRUE)
@@ -417,12 +403,5 @@ class Model_Service extends ORM_OSB {
->where('date_next_invoice','<',time()+(ORM::factory('Invoice')->config('GEN_DAYS')+$days)*86400)
->find_all();
}
/**
* List services that need to be provisioned
*/
public function list_provision() {
return $this->_where_active()->where('queue','=','PROVISION');
}
}
?>