diff --git a/application/helpers/locale_helper.php b/application/helpers/locale_helper.php index a623a2b7a..5d6515637 100644 --- a/application/helpers/locale_helper.php +++ b/application/helpers/locale_helper.php @@ -5,6 +5,7 @@ const DEFAULT_LANGUAGE_CODE = 'en-US'; define('NOW', time()); define('MAX_PRECISION', 1e14); +define('DEFAULT_PRECISION', 2); define('DEFAULT_DATE', mktime(0, 0, 0, 1, 1, 2010)); define('DEFAULT_DATETIME', mktime(0, 0, 0, 1, 1, 2010)); @@ -386,7 +387,7 @@ function to_quantity_decimals($number) return to_decimals($number, 'quantity_decimals'); } -function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL) +function to_decimals($number, $decimals=NULL, $type=\NumberFormatter::DECIMAL) { // ignore empty strings and return // NOTE: do not change it to empty otherwise tables will show a 0 with no decimal nor currency symbol @@ -397,8 +398,9 @@ function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL) $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->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 0); + $fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, empty($decimals) ? DEFAULT_PRECISION : $config->item($decimals)); + if(empty($config->item('thousands_separator'))) { $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); @@ -446,8 +448,6 @@ function parse_decimals($number, $decimals = NULL) $fmt = new \NumberFormatter($config->item('number_locale'), \NumberFormatter::DECIMAL); - $fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $decimals); - if(empty($config->item('thousands_separator'))) { $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php index 4b7a0d931..d67c05e5d 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -167,7 +167,7 @@ if (isset($success)) ?>
- 'discount', 'class'=>'form-control input-sm', 'value'=>$item['discount_type'] ? to_currency_no_money($item['discount']) : to_decimals($item['discount'], 0), 'onClick'=>'this.select();')); ?> + 'discount', 'class'=>'form-control input-sm', 'value'=>$item['discount_type'] ? to_currency_no_money($item['discount']) : to_decimals($item['discount']), 'onClick'=>'this.select();')); ?> 'discount_toggle', 'name'=>'discount_toggle', 'value'=>1, 'data-toggle'=>"toggle",'data-size'=>'small', 'data-onstyle'=>'success', 'data-on'=>''.$this->config->item('currency_symbol').'', 'data-off'=>'%', 'data-line'=>$line, 'checked'=>$item['discount_type'])); ?> diff --git a/application/views/sales/invoice.php b/application/views/sales/invoice.php index c62e4c43f..276cc1c61 100755 --- a/application/views/sales/invoice.php +++ b/application/views/sales/invoice.php @@ -139,7 +139,7 @@ $(document).ready(function() - + 0): ?> diff --git a/application/views/sales/invoice_email.php b/application/views/sales/invoice_email.php index 02c8f752a..0706e509b 100644 --- a/application/views/sales/invoice_email.php +++ b/application/views/sales/invoice_email.php @@ -92,7 +92,7 @@ if(isset($error_message)) - + 0): ?> diff --git a/application/views/sales/quote.php b/application/views/sales/quote.php index b439a2f7c..7bb2df179 100644 --- a/application/views/sales/quote.php +++ b/application/views/sales/quote.php @@ -127,7 +127,7 @@ if (isset($error_message)) - + 0): ?> diff --git a/application/views/sales/quote_email.php b/application/views/sales/quote_email.php index e370852cd..5826c366a 100644 --- a/application/views/sales/quote_email.php +++ b/application/views/sales/quote_email.php @@ -95,7 +95,7 @@ - + 0): ?> diff --git a/application/views/sales/receipt_default.php b/application/views/sales/receipt_default.php index a3095479d..19a6445af 100644 --- a/application/views/sales/receipt_default.php +++ b/application/views/sales/receipt_default.php @@ -118,7 +118,7 @@ elseif($item['discount_type'] == PERCENT) { ?> - lang->line("sales_discount_included") ?> + lang->line("sales_discount_included") ?> diff --git a/application/views/sales/receipt_email.php b/application/views/sales/receipt_email.php index 9451b74cf..0a905e4a1 100644 --- a/application/views/sales/receipt_email.php +++ b/application/views/sales/receipt_email.php @@ -96,7 +96,7 @@ elseif($item['discount_type'] == PERCENT) { ?> - lang->line("sales_discount_included") ?> + lang->line("sales_discount_included") ?> diff --git a/application/views/sales/receipt_short.php b/application/views/sales/receipt_short.php index 69aa26fff..283c3a5c6 100644 --- a/application/views/sales/receipt_short.php +++ b/application/views/sales/receipt_short.php @@ -98,7 +98,7 @@ elseif($item['discount_type'] == PERCENT) { ?> - lang->line("sales_discount_included") ?> + lang->line("sales_discount_included") ?> diff --git a/application/views/sales/register.php b/application/views/sales/register.php index 5ed2c9ac5..1f3f97ee8 100644 --- a/application/views/sales/register.php +++ b/application/views/sales/register.php @@ -195,7 +195,7 @@ if(isset($success))
- 'discount', 'class'=>'form-control input-sm', 'value'=>$item['discount_type'] ? to_currency_no_money($item['discount']) : to_decimals($item['discount'], 0), 'tabindex'=>++$tabindex, 'onClick'=>'this.select();')); ?> + 'discount', 'class'=>'form-control input-sm', 'value'=>$item['discount_type'] ? to_currency_no_money($item['discount']) : to_decimals($item['discount']), 'tabindex'=>++$tabindex, 'onClick'=>'this.select();')); ?> 'discount_toggle', 'name'=>'discount_toggle', 'value'=>1, 'data-toggle'=>"toggle",'data-size'=>'small', 'data-onstyle'=>'success', 'data-on'=>''.$this->config->item('currency_symbol').'', 'data-off'=>'%', 'data-line'=>$line, 'checked'=>$item['discount_type'])); ?> diff --git a/application/views/sales/tax_invoice.php b/application/views/sales/tax_invoice.php index 732f3a857..e400bfe4d 100644 --- a/application/views/sales/tax_invoice.php +++ b/application/views/sales/tax_invoice.php @@ -139,7 +139,7 @@ $(document).ready(function() - + 0): ?> diff --git a/application/views/sales/work_order.php b/application/views/sales/work_order.php index cf482c5e2..884ff2ee2 100644 --- a/application/views/sales/work_order.php +++ b/application/views/sales/work_order.php @@ -123,7 +123,7 @@ if(isset($error_message)) - + diff --git a/application/views/sales/work_order_email.php b/application/views/sales/work_order_email.php index d646ef336..73b9dd104 100644 --- a/application/views/sales/work_order_email.php +++ b/application/views/sales/work_order_email.php @@ -84,7 +84,7 @@ - +