2013-10-10 02:44:53 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides charge item capabilities.
|
|
|
|
*
|
|
|
|
* @package Charge
|
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
|
|
|
class Model_Charge extends ORM_OSB {
|
2013-09-06 05:39:56 +00:00
|
|
|
protected $_belongs_to = array(
|
|
|
|
'account'=>array(),
|
|
|
|
);
|
2013-10-09 05:43:41 +00:00
|
|
|
protected $_has_one = array(
|
|
|
|
'invoice_item'=>array('far_key'=>'id'),
|
|
|
|
);
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-09-06 05:39:56 +00:00
|
|
|
protected $_nullifempty = array(
|
2013-10-10 02:44:53 +00:00
|
|
|
'attributes',
|
|
|
|
);
|
|
|
|
|
2013-09-06 05:39:56 +00:00
|
|
|
protected $_serialize_column = array(
|
|
|
|
'attributes',
|
2013-10-10 02:44:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
protected $_display_filters = array(
|
2013-10-09 05:43:41 +00:00
|
|
|
'amount'=>array(
|
|
|
|
array('Currency::display',array(':value')),
|
|
|
|
),
|
2013-10-10 02:44:53 +00:00
|
|
|
'date_orig'=>array(
|
|
|
|
array('Config::date',array(':value')),
|
|
|
|
),
|
2013-09-06 05:39:56 +00:00
|
|
|
'date_charge'=>array(
|
|
|
|
array('Config::date',array(':value')),
|
|
|
|
),
|
2013-10-09 05:43:41 +00:00
|
|
|
'processed'=>array(
|
2013-11-08 11:02:32 +00:00
|
|
|
array('StaticList_YesNo::get',array(':value',TRUE)),
|
2013-10-09 05:43:41 +00:00
|
|
|
),
|
|
|
|
'sweep_type'=>array(
|
|
|
|
array('StaticList_SweepType::get',array(':value')),
|
|
|
|
),
|
|
|
|
'void'=>array(
|
|
|
|
array('StaticList_YesNo::get',array(':value')),
|
2013-10-10 02:44:53 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render some details for specific calls, eg: invoice
|
|
|
|
*/
|
|
|
|
public function details($type) {
|
|
|
|
switch ($type) {
|
|
|
|
case 'invoice_detail_items':
|
|
|
|
return array('Other Charge'=>sprintf('%s (%s@%s)',$this->description,$this->quantity,Currency::display($this->amount)));
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
|
|
|
|
}
|
|
|
|
}
|
2013-06-04 11:50:41 +00:00
|
|
|
|
|
|
|
public function total($format=FALSE) {
|
|
|
|
$result = $this->quantity * $this->amount;
|
|
|
|
|
|
|
|
if ($this->taxable)
|
|
|
|
$result = Tax::add($result);
|
|
|
|
|
|
|
|
return $format ? Currency::display($result) : $result;
|
|
|
|
}
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
?>
|