diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 4398ce711..8c003f4d6 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -58,9 +58,9 @@ class Config extends Secure_Controller { $batch_save_data = array( 'default_tax_1_rate' => parse_decimals($this->input->post('default_tax_1_rate')), - 'default_tax_1_name' => parse_decimals($this->input->post('default_tax_1_name')), + 'default_tax_1_name' => $this->input->post('default_tax_1_name'), 'default_tax_2_rate' => parse_decimals($this->input->post('default_tax_2_rate')), - 'default_tax_2_name' => parse_decimals($this->input->post('default_tax_2_name')), + 'default_tax_2_name' => $this->input->post('default_tax_2_name'), 'tax_included' => $this->input->post('tax_included') != NULL, 'receiving_calculate_average_price' => $this->input->post('receiving_calculate_average_price') != NULL, 'lines_per_page' => $this->input->post('lines_per_page'), diff --git a/application/controllers/Items.php b/application/controllers/Items.php index f0c9d8b25..f2ab2f9d7 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -370,9 +370,10 @@ class Items extends Secure_Controller $count = count($tax_percents); for ($k = 0; $k < $count; ++$k) { - if(is_numeric($tax_percents[$k])) + $tax_percentage = parse_decimals($tax_percents[$k]); + if(is_numeric($tax_percentage)) { - $items_taxes_data[] = array('name' => $tax_names[$k], 'percent' => parse_decimals($tax_percents[$k])); + $items_taxes_data[] = array('name' => $tax_names[$k], 'percent' => $tax_percentage); } } $success &= $this->Item_taxes->save($items_taxes_data, $item_id); diff --git a/application/controllers/Receivings.php b/application/controllers/Receivings.php index 427d17694..c24935ab3 100644 --- a/application/controllers/Receivings.php +++ b/application/controllers/Receivings.php @@ -101,7 +101,7 @@ class Receivings extends Secure_Controller function numeric($str) { - return (bool) preg_match('/^[\-+]?([0-9]*[\.,])*?[0-9]+$/', $str); + return parse_decimals($str, 2); } public function edit_item($item_id) diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index 099fa9ea4..daf301988 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -282,7 +282,7 @@ class Sales extends Secure_Controller function numeric($str) { - return (bool) preg_match('/^[\-+]?([0-9]*[\.,])*?[0-9]+$/', $str); + return parse_decimals($str, 2); } public function edit_item($item_id) diff --git a/application/helpers/locale_helper.php b/application/helpers/locale_helper.php index 04132c793..d8ac76d1a 100644 --- a/application/helpers/locale_helper.php +++ b/application/helpers/locale_helper.php @@ -36,6 +36,10 @@ function to_currency_no_money($number) function to_tax_decimals($number) { + if (empty($number)) + { + return $number; + } return to_decimals($number, 'tax_decimals'); } @@ -51,7 +55,7 @@ function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL) $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $CI->config->item($decimals)); $fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $CI->config->item($decimals)); $fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $CI->config->item('currency_symbol')); - return $fmt->format(floatval($number)); + return $fmt->format($number); } function parse_decimals($number) diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 80d9e023d..6fc5697ff 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -17,7 +17,7 @@