Open Source Billing
This commit is contained in:
14
modules/tax/classes/Model/Invoice/Item/Tax.php
Normal file
14
modules/tax/classes/Model/Invoice/Item/Tax.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports tax calculations
|
||||
*
|
||||
* @package Tax
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Invoice_Item_Tax extends ORM_OSB {
|
||||
}
|
||||
?>
|
14
modules/tax/classes/Model/Tax.php
Normal file
14
modules/tax/classes/Model/Tax.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports tax calculations
|
||||
*
|
||||
* @package Tax
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Tax extends ORM_OSB {
|
||||
}
|
||||
?>
|
58
modules/tax/classes/Tax.php
Normal file
58
modules/tax/classes/Tax.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides a tax information
|
||||
*
|
||||
* @package Tax
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Tax {
|
||||
/**
|
||||
* Return array of taxes
|
||||
*
|
||||
* @param $cid
|
||||
* @param $zone
|
||||
* @param $value
|
||||
* @return array Tax Information
|
||||
*/
|
||||
public static function detail($cid,$zone,$value=0) {
|
||||
$tax = ORM::factory('Tax')
|
||||
->where('country_id','=',$cid)
|
||||
->and_where('zone','=',$zone)
|
||||
->find_all();
|
||||
|
||||
$taxes = array();
|
||||
foreach ($tax as $to) {
|
||||
$total = array();
|
||||
|
||||
$total['id'] = $to->id;
|
||||
$total['description'] = $to->description;
|
||||
$total['amount'] = $to->rate*$value;
|
||||
$total['rate'] = $to->rate;
|
||||
|
||||
array_push($taxes,$total);
|
||||
}
|
||||
|
||||
return $taxes;
|
||||
}
|
||||
|
||||
// Calculate the tax amount
|
||||
public static function total($cid,$zone,$value) {
|
||||
$total = 0;
|
||||
|
||||
foreach (static::detail($cid,$zone,$value) as $tax)
|
||||
$total += $tax['amount'];
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public static function add($value) {
|
||||
// @todo Tax details should come from session
|
||||
// @todo Rounding should be a global config
|
||||
return round($value+static::total(61,NULL,$value),2);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user