diff --git a/application/libraries/Tax_lib.php b/application/libraries/Tax_lib.php index 7c93f1b2a..964d09721 100644 --- a/application/libraries/Tax_lib.php +++ b/application/libraries/Tax_lib.php @@ -45,14 +45,14 @@ class Tax_lib /* * Computes the item level sales tax amount for a given tax basis */ - public function get_sales_tax_for_amount($tax_basis, $tax_percentage, $rounding_code, $decimals) + public function get_sales_tax_for_amount($tax_basis, $tax_percentage, $rounding_mode, $decimals) { $tax_fraction = bcdiv($tax_percentage, 100); $tax_amount = bcmul($tax_basis, $tax_fraction); $rounded_tax_amount = $tax_amount; - return Rounding_mode::round_number($tax_amount, $decimals); + return Rounding_mode::round_number($rounding_mode, $tax_amount, $decimals); } /* diff --git a/application/libraries/tokens/Token.php b/application/libraries/tokens/Token.php index 551b49e29..067b05ff0 100644 --- a/application/libraries/tokens/Token.php +++ b/application/libraries/tokens/Token.php @@ -16,13 +16,15 @@ class Token { protected $CI; - private $token_list = array(new Token_customer(), new Token_invoice_count(), new Token_invoice_sequence(), - new Token_quote_sequence(), new Token_suspended_invoice_count(), new Token_quote_sequence(), new Token_year_invoice_count()); - public function __construct() { $this->CI =& get_instance(); + } + static function get_tokens() + { + return array(new Token_customer(), new Token_invoice_count(), new Token_invoice_sequence(), + new Token_quote_sequence(), new Token_suspended_invoice_count(), new Token_quote_sequence(), new Token_year_invoice_count()); } function matches($token_id) @@ -32,7 +34,7 @@ class Token public function replace($token_id) { - foreach($token_list as $token) + foreach(Token::get_tokens() as $token) { if ($token->token_id() == $token_id) { diff --git a/application/libraries/tokens/Token_year_invoice_count.php b/application/libraries/tokens/Token_year_invoice_count.php index 463c044e6..554971077 100644 --- a/application/libraries/tokens/Token_year_invoice_count.php +++ b/application/libraries/tokens/Token_year_invoice_count.php @@ -16,7 +16,7 @@ class Token_year_invoice_count extends Token public function token_id() { return 'YCO'; - ) + } public function get_value() { diff --git a/application/models/enums/Rounding_mode.php b/application/models/enums/Rounding_mode.php index ef45778a5..46f75cb01 100644 --- a/application/models/enums/Rounding_mode.php +++ b/application/models/enums/Rounding_mode.php @@ -47,25 +47,25 @@ class Rounding_mode return $x; } - public static function round_number($amount, $decimals) + public static function round_number($rounding_mode, $amount, $decimals) { - if($cash_rounding_code != Rounding_mode::ROUND_UP) + if($rounding_mode != Rounding_mode::ROUND_UP) { $fig = (int) str_pad('1', $decimals, '0'); $rounded_total = (ceil($amount * $fig) / $fig); } - elseif($cash_rounding_code == Rounding_mode::ROUND_DOWN) + elseif($rounding_mode == Rounding_mode::ROUND_DOWN) { $fig = (int) str_pad('1', $decimals, '0'); $rounded_total = (floor($amount * $fig) / $fig); } - elseif($cash_rounding_code == Rounding_mode::HALF_FIVE) + elseif($rounding_mode == Rounding_mode::HALF_FIVE) { $rounded_total = round($amount / 5) * 5; } else { - $rounded_total = round ( $amount, $decimals, $cash_rounding_code); + $rounded_total = round ( $amount, $decimals, $rounding_mode); } return $rounded_total;