2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides charge item capabilities.
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package Charge
|
2010-11-29 22:41:08 +00:00
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
2010-11-29 22:41:08 +00:00
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2012-12-10 21:48:30 +00:00
|
|
|
class Model_Charge extends ORM_OSB {
|
2011-10-14 05:44:12 +00:00
|
|
|
// Charge doesnt use the update column
|
|
|
|
protected $_updated_column = FALSE;
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2012-06-26 14:28:18 +00:00
|
|
|
protected $_serialize_column = array(
|
|
|
|
'attributes',
|
|
|
|
);
|
2011-10-14 05:44:12 +00:00
|
|
|
|
|
|
|
protected $_belongs_to = array(
|
|
|
|
'account'=>array(),
|
|
|
|
);
|
|
|
|
|
2011-07-14 09:09:03 +00:00
|
|
|
protected $_display_filters = array(
|
2011-10-14 05:44:12 +00:00
|
|
|
'date_orig'=>array(
|
|
|
|
array('Config::date',array(':value')),
|
|
|
|
),
|
2011-07-14 09:09:03 +00:00
|
|
|
'amount'=>array(
|
2011-10-14 05:44:12 +00:00
|
|
|
array('Currency::display',array(':value')),
|
2011-07-14 09:09:03 +00:00
|
|
|
),
|
2010-11-29 22:41:08 +00:00
|
|
|
);
|
2011-08-02 06:48:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render some details for specific calls, eg: invoice
|
|
|
|
*/
|
|
|
|
public function details($type) {
|
|
|
|
switch ($type) {
|
2011-10-14 05:44:12 +00:00
|
|
|
case 'invoice_detail_items':
|
|
|
|
return array('Other Charge'=>sprintf('%s (%s@%s)',$this->description,$this->quantity,Currency::display($this->amount)));
|
2011-08-02 06:48:41 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
?>
|