Revamping invoice PDF rendering and standardisation work
This commit is contained in:
@@ -51,10 +51,10 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
0=>'Product/Service', // * Line Charge Topic on Invoice.
|
||||
1=>'Hardware', // *
|
||||
2=>'Service Relocation Fee', // * Must have corresponding SERVICE_ID
|
||||
3=>'Service Change Fee', // * Must have corresponding SERVICE_ID
|
||||
4=>'Service Connection Fee', // * Must have corresponding SERVICE_ID
|
||||
3=>'Service Change', // * Must have corresponding SERVICE_ID
|
||||
4=>'Service Connection', // * Must have corresponding SERVICE_ID
|
||||
5=>'Excess Usage', // * Excess Service Item, of item 0, must have corresponding SERVICE_ID
|
||||
6=>'Service Cancellation Fee', // * Must have corresponding SERVICE_ID
|
||||
6=>'Service Cancellation', // * Must have corresponding SERVICE_ID
|
||||
7=>'Extra Product/Service Charge', // * Service Billing in advance, Must have corresponding SERVICE_ID
|
||||
8=>'Product Addition', // * Additional Product Customisation, Must have corresponding SERVICE_ID
|
||||
120=>'Credit/Debit Transfer', // * SERVICE_ID is NULL, MODULE_ID is NULL, MODULE_REF is NULL : INVOICE_ID is NOT NULL
|
||||
@@ -72,10 +72,13 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
|
||||
switch ($this->item_type) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return sprintf('%s: %s',$this->product->name($variable),$this->service->namesub($variable));
|
||||
case 124:
|
||||
return StaticList_ItemType::get($this->item_type);
|
||||
default:
|
||||
return sprintf('Unknown [%s-%s]',$this->item_type,$this->id);
|
||||
}
|
||||
@@ -88,8 +91,12 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
switch ($this->item_type) {
|
||||
case 0:
|
||||
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->period());
|
||||
case 2:
|
||||
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->_module() ? $this->_module()->display('date_charge') : $this->period());
|
||||
case 3:
|
||||
case 4:
|
||||
case 6:
|
||||
return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),($this->_module()->attributes ? $this->_module()->namesub($variable) : $this->_module()->display('date_charge')));
|
||||
case 5:
|
||||
return $this->_module()->namesub($variable);
|
||||
default:
|
||||
@@ -109,7 +116,7 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
/**
|
||||
* Module assocated with the invoice item
|
||||
*/
|
||||
public function _module() {
|
||||
private function _module() {
|
||||
if (! $this->module_id OR ! $this->module_ref)
|
||||
return NULL;
|
||||
|
||||
@@ -164,10 +171,18 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
switch ($this->item_type) {
|
||||
case 0:
|
||||
// @todo Validate if module_id = charge and module_ref corresponds with the line item
|
||||
if (! $this->service_id OR ! $this->product_id OR ($this->module_id AND $this->module_id != 30 AND ! is_null($this>module_id)) OR $this->product_name OR is_null($this->recurring_schedule))
|
||||
if (! $this->service_id OR ! $this->product_id OR ($this->module_id AND $this->module_id != 30 AND ! is_null($this>module_ref)) OR $this->product_name OR is_null($this->recurring_schedule))
|
||||
return FALSE;
|
||||
break;
|
||||
case 1:
|
||||
if (! $this->product_id OR $this->module_id OR $this->module_ref OR $this->product_name OR ! is_null($this->recurring_schedule))
|
||||
return FALSE;
|
||||
break;
|
||||
// These items come from the charge module, so we should have a charge module_id and ref
|
||||
case 2:
|
||||
if (! $this->service_id OR ! $this->product_id OR ($this->module_id AND $this->module_id != 30 AND ! is_null($this>module_ref)) OR $this->product_name OR ! is_null($this->recurring_schedule))
|
||||
return FALSE;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
if (! $this->service_id OR ! $this->product_id OR ! $this->module_id OR ! $this->module_ref OR $this->product_name OR ! is_null($this->recurring_schedule))
|
||||
@@ -178,65 +193,23 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
if (! $this->service_id OR ! $this->product_id OR ! $this->module_id OR ! $this->module_ref OR $this->product_name OR ! is_null($this->recurring_schedule))
|
||||
return FALSE;
|
||||
break;
|
||||
case 124:
|
||||
if ($this->service_id OR $this->product_id OR $this->module_id OR $this->module_ref OR $this->product_name OR ! is_null($this->recurring_schedule))
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
// If we get here, assume it is valid
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The line that will be printed on an invoice
|
||||
*
|
||||
* @todo This method includes some database format validation routines, which can be removed when the database
|
||||
* is completly transformed.
|
||||
*/
|
||||
public function invoice_line() {
|
||||
$ii = NULL;
|
||||
|
||||
// Our module is responsible for rending the invoice line
|
||||
$ii = ($this->module_id AND method_exists($this->module(),'invoice_item')) ? $this->module()->invoice_item($this->item_type) : StaticList_ItemType::get($this->item_type);
|
||||
|
||||
switch ($this->item_type) {
|
||||
// Service Charges
|
||||
case 0:
|
||||
return ((! $this->service_id OR $this->product_id OR $this->product_name OR ! $this->recurring_schedule OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii.' '.$this->period();
|
||||
case 1:
|
||||
// @todo
|
||||
return $this->product_name;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
return ((! $this->service_id OR $this->product_id OR $this->product_name OR $this->recurring_schedule OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii;
|
||||
|
||||
case 7:
|
||||
return ((! $this->service_id OR $this->product_id OR $this->product_name OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii.' '.$this->period();
|
||||
|
||||
case 8:
|
||||
return $this->product_name;
|
||||
|
||||
case 124:
|
||||
case 125:
|
||||
case 126:
|
||||
case 127:
|
||||
// @todo
|
||||
return $ii;
|
||||
|
||||
// @todo DB records to fix.
|
||||
default:
|
||||
throw HTTP_Exception::factory(501,'Unable to render invoice item :id',array(':id'=>$this->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the Model of this charge
|
||||
*/
|
||||
|
||||
public function module() {
|
||||
return $this->_module();
|
||||
}
|
||||
|
||||
// Display the period that a transaction applies
|
||||
public function period() {
|
||||
return ($this->date_start == $this->date_stop) ? Site::Date($this->date_start) : sprintf('%s -> %s',Site::Date($this->date_start),Site::Date($this->date_stop));
|
||||
@@ -322,23 +295,5 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
|
||||
return $format ? Currency::display($result) : Currency::round($result);
|
||||
}
|
||||
|
||||
// Display a transaction number
|
||||
public function trannum() {
|
||||
return sprintf('%03s-%06s',$this->item_type,$this->id);
|
||||
}
|
||||
|
||||
public function invoice_detail_items() {
|
||||
switch ($this->item_type) {
|
||||
case 0:
|
||||
return $this->service->details('invoice_detail_items');
|
||||
case 4:
|
||||
return array('Charge'=>_('Service Connection Fee'));
|
||||
case 5:
|
||||
return $this->charge->details('invoice_detail_items');
|
||||
default:
|
||||
return array('Item'=>$this->item_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user