mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-16 04:50:09 -04:00
Little locale_helper improvement and regen database scripts (#458)
This commit is contained in:
@@ -6,22 +6,22 @@
|
||||
|
||||
function currency_side()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$fmt = new \NumberFormatter($CI->config->item('number_locale'), \NumberFormatter::CURRENCY);
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $CI->config->item('currency_symbol'));
|
||||
$config = get_instance()->config;
|
||||
$fmt = new \NumberFormatter($config->item('number_locale'), \NumberFormatter::CURRENCY);
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
|
||||
return !preg_match('/^¤/', $fmt->getPattern());
|
||||
}
|
||||
|
||||
function quantity_decimals()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->config->item('quantity_decimals') ? $CI->config->item('quantity_decimals') : 0;
|
||||
$config = get_instance()->config;
|
||||
return $config->item('quantity_decimals') ? $config->item('quantity_decimals') : 0;
|
||||
}
|
||||
|
||||
function totals_decimals()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 0;
|
||||
$config = get_instance()->config;
|
||||
return $config->item('currency_decimals') ? $config->item('currency_decimals') : 0;
|
||||
}
|
||||
|
||||
function to_currency($number, $escape = FALSE)
|
||||
@@ -36,10 +36,6 @@ function to_currency_no_money($number)
|
||||
|
||||
function to_tax_decimals($number)
|
||||
{
|
||||
if (empty($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
return to_decimals($number, 'tax_decimals');
|
||||
}
|
||||
|
||||
@@ -50,25 +46,32 @@ function to_quantity_decimals($number)
|
||||
|
||||
function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$fmt = new \NumberFormatter($CI->config->item('number_locale'), $type);
|
||||
$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'));
|
||||
// ignore empty strings and return
|
||||
if(empty($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
|
||||
$config = get_instance()->config;
|
||||
$fmt = new \NumberFormatter($config->item('number_locale'), $type);
|
||||
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
|
||||
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $config->item($decimals));
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
|
||||
return $fmt->format($number);
|
||||
}
|
||||
|
||||
function parse_decimals($number)
|
||||
{
|
||||
// ignore empty strings as they are just for empty input
|
||||
if (empty($number))
|
||||
// ignore empty strings and return
|
||||
if(empty($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
$CI =& get_instance();
|
||||
$fmt = new \NumberFormatter( $CI->config->item('number_locale'), \NumberFormatter::DECIMAL );
|
||||
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $CI->config->item('quantity_decimals'));
|
||||
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $CI->config->item('quantity_decimals'));
|
||||
|
||||
$config = get_instance()->config;
|
||||
$fmt = new \NumberFormatter( $config->item('number_locale'), \NumberFormatter::DECIMAL );
|
||||
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item('quantity_decimals'));
|
||||
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $config->item('quantity_decimals'));
|
||||
return $fmt->parse($number);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
('dateformat', 'm/d/Y'),
|
||||
('timeformat', 'H:i:s'),
|
||||
('currency_symbol', '$'),
|
||||
('number_locale', 'en_US'),
|
||||
('currency_decimals', '2'),
|
||||
('tax_decimals', '2'),
|
||||
('quantity_decimals', '0'),
|
||||
|
||||
@@ -60,7 +60,7 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
('dateformat', 'm/d/Y'),
|
||||
('timeformat', 'H:i:s'),
|
||||
('currency_symbol', '$'),
|
||||
('decimal_point', '.'),
|
||||
('number_locale', 'en_US'),
|
||||
('currency_decimals', '2'),
|
||||
('tax_decimals', '2'),
|
||||
('quantity_decimals', '0'),
|
||||
|
||||
Reference in New Issue
Block a user