mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-02-26 20:07:28 -05:00
Add thousands separator option (#458)
Fix adding payment with comma as decimal separator (#740)
This commit is contained in:
@@ -18,10 +18,5 @@ script:
|
||||
- docker-compose up -d
|
||||
|
||||
after_success:
|
||||
- >
|
||||
'[ -n ${DOCKER_USERNAME} ] &&
|
||||
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" &&
|
||||
docker tag opensourcepos_php_1 jekkos/opensourcepos:$TRAVIS_BRANCH &&
|
||||
docker tag opensourcepos_sqlscript_1 jekkos/opensourcepos:sqlscript &&
|
||||
docker push jekkos/opensourcepos:master && docker push jekkos/opensourcepos:sqlscript'
|
||||
- '[ -n ${DOCKER_USERNAME} ] && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && docker tag opensourcepos_php jekkos/opensourcepos:${TRAVIS_BRANCH} && docker tag opensourcepos_sqlscript jekkos/opensourcepos:sqlscript && docker push jekkos/opensourcepos:master && docker push jekkos/opensourcepos:sqlscript'
|
||||
|
||||
|
||||
@@ -97,6 +97,6 @@ FAQ
|
||||
---
|
||||
* If a blank page (HTTP status 500) shows after search completion or receipt generation, then double check php5-gd presence in your php installation. On windows check in php.ini whether the lib is installed. On Ubuntu issue `sudo apt-get install php5-gd`. Also have a look at the Dockerfile for a complete list of recommended packages.
|
||||
|
||||
* If following error is sene in sales module `Message: Class 'NumberFormatter' not found` then you don't have `php5-intl` extension installed. Please check the [wiki](https://github.com/jekkos/opensourcepos/wiki/Localisation-support#php5-intl-extension-installation) to resolve this issue on your platform.
|
||||
* If the following error is seen in sales module `Message: Class 'NumberFormatter' not found` then you don't have `php5-intl` extension installed. Please check the [wiki](https://github.com/jekkos/opensourcepos/wiki/Localisation-support#php5-intl-extension-installation) to resolve this issue on your platform.
|
||||
|
||||
ca
|
||||
|
||||
@@ -142,9 +142,18 @@ class Config extends Secure_Controller
|
||||
$number_locale = $this->input->post('number_locale');
|
||||
$fmt = new \NumberFormatter($number_locale, \NumberFormatter::CURRENCY);
|
||||
$currency_symbol = empty($this->input->post('currency_symbol')) ? $fmt->getSymbol(\NumberFormatter::CURRENCY_SYMBOL) : $this->input->post('currency_symbol');
|
||||
if ($this->input->post('thousands_separator') == "false")
|
||||
{
|
||||
$fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
|
||||
}
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $currency_symbol);
|
||||
$number_local_example = $fmt->format(1234567890.12300);
|
||||
echo json_encode(array('success' => $number_local_example != FALSE, 'number_locale_example' => $number_local_example, 'currency_symbol' => $currency_symbol));
|
||||
echo json_encode(array(
|
||||
'success' => $number_local_example != FALSE,
|
||||
'number_locale_example' => $number_local_example,
|
||||
'currency_symbol' => $currency_symbol,
|
||||
'thousands_separator' => $fmt->getAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL) != ''
|
||||
));
|
||||
}
|
||||
|
||||
public function save_locale()
|
||||
@@ -155,7 +164,8 @@ class Config extends Secure_Controller
|
||||
'timezone' => $this->input->post('timezone'),
|
||||
'dateformat' => $this->input->post('dateformat'),
|
||||
'timeformat' => $this->input->post('timeformat'),
|
||||
'number_locale' => $this->input->post('number_locale'),
|
||||
'thousands_separator' => $this->input->post('thousands_separator'),
|
||||
'number_locale' => $this->input->post('number_locale'),
|
||||
'currency_decimals' => $this->input->post('currency_decimals'),
|
||||
'tax_decimals' => $this->input->post('tax_decimals'),
|
||||
'quantity_decimals' => $this->input->post('quantity_decimals'),
|
||||
|
||||
@@ -101,7 +101,7 @@ class Receivings extends Secure_Controller
|
||||
|
||||
function numeric($str)
|
||||
{
|
||||
return parse_decimals($str, 2);
|
||||
return parse_decimals($str, 3);
|
||||
}
|
||||
|
||||
public function edit_item($item_id)
|
||||
|
||||
@@ -224,7 +224,7 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$amount_tendered = parse_decimals($this->input->post('amount_tendered'));
|
||||
$amount_tendered = $this->input->post('amount_tendered');
|
||||
|
||||
$this->sale_lib->add_payment($payment_type, $amount_tendered);
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class Sales extends Secure_Controller
|
||||
|
||||
function numeric($str)
|
||||
{
|
||||
return parse_decimals($str, 2);
|
||||
return parse_decimals($str, 3);
|
||||
}
|
||||
|
||||
public function edit_item($item_id)
|
||||
|
||||
@@ -64,6 +64,10 @@ function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL)
|
||||
$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));
|
||||
if (empty($config->item('thousands_separator')))
|
||||
{
|
||||
$fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
|
||||
}
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
|
||||
return $fmt->format($number);
|
||||
}
|
||||
|
||||
@@ -4,17 +4,6 @@
|
||||
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
|
||||
<ul id="locale_error_message_box" class="error_message_box"></ul>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_currency_symbol'), 'currency_symbol', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-1'>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'currency_symbol',
|
||||
'id' => 'currency_symbol',
|
||||
'class' => 'form-control input-sm number_locale',
|
||||
'value'=>$this->config->item('currency_symbol'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_number_locale'), 'number_locale', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='row'>
|
||||
@@ -34,6 +23,28 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_thousands_separator'), 'thousands_separator', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php echo form_checkbox(array(
|
||||
'name' => 'thousands_separator',
|
||||
'id' => 'thousands_separator',
|
||||
'value' => 'thousands_separator',
|
||||
'checked'=>$this->config->item('thousands_separator'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_currency_symbol'), 'currency_symbol', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-1'>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'currency_symbol',
|
||||
'id' => 'currency_symbol',
|
||||
'class' => 'form-control input-sm number_locale',
|
||||
'value'=>$this->config->item('currency_symbol'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_currency_decimals'), 'currency_decimals', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
@@ -269,11 +280,16 @@ $(document).ready(function()
|
||||
type: "POST"
|
||||
};
|
||||
|
||||
$("#currency_symbol").change(function() {
|
||||
$("#currency_symbol, #thousands_separator").change(function() {
|
||||
var field = $(this).attr('id');
|
||||
var value = $(this).is(":checkbox") ? $(this).is(":checked") : $(this).val();
|
||||
var data =
|
||||
{
|
||||
number_locale: $("#number_locale").val()
|
||||
};
|
||||
data[field] = value;
|
||||
$.post($.extend(number_locale_params, {
|
||||
data: $.extend(csrf_form_base(), {
|
||||
"currency_symbol": $("#currency_symbol").val()
|
||||
}),
|
||||
data: $.extend(csrf_form_base(), data),
|
||||
success: function(response) {
|
||||
$("#number_locale_example").text(response.number_locale_example);
|
||||
}
|
||||
@@ -292,12 +308,16 @@ $(document).ready(function()
|
||||
"number_locale" : function() {
|
||||
return $("#number_locale").val();
|
||||
},
|
||||
"thousands_separator": function() {
|
||||
return $("#thousands_separator").is(":checked");
|
||||
}
|
||||
}),
|
||||
dataFilter: function(data, dataType) {
|
||||
setup_csrf_token();
|
||||
var response = JSON.parse(data);
|
||||
$("#number_locale_example").text(response.number_locale_example);
|
||||
$("#currency_symbol").val(response.currency_symbol);
|
||||
$("#thousands_separator").prop('checked', response.thousands_separator);
|
||||
return response.success;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -61,6 +61,7 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
('timeformat', 'H:i:s'),
|
||||
('currency_symbol', '$'),
|
||||
('number_locale', 'en_US'),
|
||||
('thousands_separator', '1'),
|
||||
('currency_decimals', '2'),
|
||||
('tax_decimals', '2'),
|
||||
('quantity_decimals', '0'),
|
||||
|
||||
Reference in New Issue
Block a user