internationalise currency in order screen
This commit is contained in:
parent
dddd11d8f0
commit
c31e864c73
2 changed files with 12 additions and 11 deletions
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
var modified = false // indicates if anything has been clicked on this page
|
var modified = false // indicates if anything has been clicked on this page
|
||||||
var groupBalance = 0; // available group money
|
var groupBalance = 0; // available group money
|
||||||
var decimalSeparator = "."; // default decimal separator
|
var currencySeparator = "."; // default decimal separator
|
||||||
|
var currencyPrecision = 2; // default digits behind comma
|
||||||
|
var currencyUnit = "€"; // default currency
|
||||||
var toleranceIsCostly = true; // default tolerance behaviour
|
var toleranceIsCostly = true; // default tolerance behaviour
|
||||||
var isStockit = false; // Wheter the order is from stock oder normal supplier
|
var isStockit = false; // Wheter the order is from stock oder normal supplier
|
||||||
|
|
||||||
|
@ -20,8 +22,10 @@ var toleranceOthers = new Array();
|
||||||
var itemsAllocated = new Array(); // how many items the group has been allocated and should definitely get
|
var itemsAllocated = new Array(); // how many items the group has been allocated and should definitely get
|
||||||
var quantityAvailable = new Array(); // stock_order. how many items are currently in stock
|
var quantityAvailable = new Array(); // stock_order. how many items are currently in stock
|
||||||
|
|
||||||
function setDecimalSeparator(character) {
|
function setCurrencyFormat(separator, precision, unit) {
|
||||||
decimalSeparator = character;
|
currencySeparator = separator;
|
||||||
|
currencyPrecision = precision;
|
||||||
|
currencyUnit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setToleranceBehaviour(value) {
|
function setToleranceBehaviour(value) {
|
||||||
|
@ -129,7 +133,7 @@ function update(item, quantity, tolerance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function asMoney(amount) {
|
function asMoney(amount) {
|
||||||
return String(amount.toFixed(2)).replace(/\./, ",");
|
return String(amount.toFixed(currencyPrecision)).replace(/\./, currencySeparator) + ' ' + currencyUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcUnits(unitSize, quantity, tolerance) {
|
function calcUnits(unitSize, quantity, tolerance) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
#{data_to_js(@ordering_data)}
|
#{data_to_js(@ordering_data)}
|
||||||
setGroupBalance(#{@ordering_data[:available_funds]});
|
setGroupBalance(#{@ordering_data[:available_funds]});
|
||||||
setDecimalSeparator(",");
|
setCurrencyFormat("#{t('number.currency.format.separator')}", #{t('number.currency.format.precision')}, "#{t('number.currency.format.unit')}");
|
||||||
setToleranceBehaviour(#{FoodsoftConfig[:tolerance_is_costly]});
|
setToleranceBehaviour(#{FoodsoftConfig[:tolerance_is_costly]});
|
||||||
setStockit(#{@order.stockit?});
|
setStockit(#{@order.stockit?});
|
||||||
});
|
});
|
||||||
|
@ -97,8 +97,7 @@
|
||||||
%input{type: 'button', value: '-', 'data-decrease_tolerance' => order_article.id}
|
%input{type: 'button', value: '-', 'data-decrease_tolerance' => order_article.id}
|
||||||
|
|
||||||
%td{id: "td_price_#{order_article.id}", style: "text-align:right; padding-right:10px; width:4em"}
|
%td{id: "td_price_#{order_article.id}", style: "text-align:right; padding-right:10px; width:4em"}
|
||||||
%span{id: "price_#{order_article.id}_display"}= number_to_currency(@ordering_data[:order_articles][order_article.id][:total_price], unit: "")
|
%span{id: "price_#{order_article.id}_display"}= number_to_currency(@ordering_data[:order_articles][order_article.id][:total_price])
|
||||||
€
|
|
||||||
.article-info
|
.article-info
|
||||||
.article-name= order_article.article.name
|
.article-name= order_article.article.name
|
||||||
.pull-right
|
.pull-right
|
||||||
|
@ -125,8 +124,7 @@
|
||||||
%tr
|
%tr
|
||||||
%td= t('.total_sum_amount') + ':'
|
%td= t('.total_sum_amount') + ':'
|
||||||
%td.currency
|
%td.currency
|
||||||
%span#total_price= @group_order.price
|
%span#total_price= number_to_currency(@group_order.price)
|
||||||
€
|
|
||||||
%tr
|
%tr
|
||||||
%td= t('.available_funds') + ':'
|
%td= t('.available_funds') + ':'
|
||||||
%td.currency= number_to_currency(@ordering_data[:available_funds])
|
%td.currency= number_to_currency(@ordering_data[:available_funds])
|
||||||
|
@ -134,8 +132,7 @@
|
||||||
%td= t('.new_funds') + ':'
|
%td= t('.new_funds') + ':'
|
||||||
%td.currency
|
%td.currency
|
||||||
%strong
|
%strong
|
||||||
%span#new_balance= @ordering_data[:available_funds] - @group_order.price
|
%span#new_balance= number_to_currency(@ordering_data[:available_funds] - @group_order.price)
|
||||||
€
|
|
||||||
#order-button
|
#order-button
|
||||||
= submit_tag( t('.action_save'), id: 'submit_button', class: 'btn btn-primary' )
|
= submit_tag( t('.action_save'), id: 'submit_button', class: 'btn btn-primary' )
|
||||||
#{link_to t('ui.or_cancel'), group_orders_path}
|
#{link_to t('ui.or_cancel'), group_orders_path}
|
||||||
|
|
Loading…
Reference in a new issue