forked from DGNum/gestioCOF
Merge branch 'Aufinal/fix_amounts' into 'k-fet'
K-Psul: - fix #163: different rounding for UKF accounts balances / UKF articles prices See merge request !171
This commit is contained in:
commit
1a684471c2
2 changed files with 11 additions and 10 deletions
|
@ -37,9 +37,10 @@ function amountDisplay(amount, is_cof=false, tri='') {
|
|||
return amountToUKF(amount, is_cof);
|
||||
}
|
||||
|
||||
function amountToUKF(amount, is_cof=false) {
|
||||
function amountToUKF(amount, is_cof=false, account=false) {
|
||||
var rounding = account ? Math.floor : Math.round ;
|
||||
var coef_cof = is_cof ? 1 + settings['subvention_cof'] / 100 : 1;
|
||||
return Math.round(amount * coef_cof * 10);
|
||||
return rounding(amount * coef_cof * 10);
|
||||
}
|
||||
|
||||
function isValidTrigramme(trigramme) {
|
||||
|
|
|
@ -221,7 +221,7 @@ $(document).ready(function() {
|
|||
function displayAccountData() {
|
||||
var balance = account_data['trigramme'] != 'LIQ' ? account_data['balance'] : '';
|
||||
if (balance != '')
|
||||
balance = amountToUKF(account_data['balance'], account_data['is_cof']);
|
||||
balance = amountToUKF(account_data['balance'], account_data['is_cof'], true);
|
||||
var is_cof = account_data['trigramme'] ? account_data['is_cof'] : '';
|
||||
if (is_cof !== '')
|
||||
is_cof = is_cof ? '<b>COF</b>' : '<b>Non-COF</b>';
|
||||
|
@ -616,7 +616,7 @@ $(document).ready(function() {
|
|||
for (var elem in article) {
|
||||
article_html.find('.'+elem).text(article[elem])
|
||||
}
|
||||
article_html.find('.price').text(amountToUKF(article['price'], false));
|
||||
article_html.find('.price').text(amountToUKF(article['price'], false, false));
|
||||
var category_html = articles_container
|
||||
.find('#data-category-'+article['category_id']);
|
||||
if (category_html.length == 0) {
|
||||
|
@ -834,7 +834,7 @@ $(document).ready(function() {
|
|||
.attr('data-opeindex', index)
|
||||
.find('.number').text(nb).end()
|
||||
.find('.name').text(article_data[0]).end()
|
||||
.find('.amount').text(amountToUKF(amount_euro, account_data['is_cof']));
|
||||
.find('.amount').text(amountToUKF(amount_euro, account_data['is_cof'], false));
|
||||
basket_container.prepend(article_basket_html);
|
||||
updateBasketRel();
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ $(document).ready(function() {
|
|||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text(text).end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof'], false));
|
||||
basket_container.prepend(deposit_basket_html);
|
||||
updateBasketRel();
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ $(document).ready(function() {
|
|||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text('Retrait').end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof'], false));
|
||||
basket_container.prepend(withdraw_basket_html);
|
||||
updateBasketRel();
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ $(document).ready(function() {
|
|||
var amount = $(this).find('#id_form-'+opeindex+'-amount');
|
||||
if (!deleted && type == "purchase")
|
||||
amount.val(amountEuroPurchase(article_id, article_nb));
|
||||
basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof']));
|
||||
basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof'], false));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -922,9 +922,9 @@ $(document).ready(function() {
|
|||
basketrel_html += '<div>Sur 20€: '+ (20-amount).toFixed(2) +' €</div>';
|
||||
} else if (account_data['trigramme'] != '' && !isBasketEmpty()) {
|
||||
var amount = getAmountBasket();
|
||||
var amountUKF = amountToUKF(amount, account_data['is_cof']);
|
||||
var amountUKF = amountToUKF(amount, account_data['is_cof'], false);
|
||||
var newBalance = account_data['balance'] + amount;
|
||||
var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof']);
|
||||
var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof'], true);
|
||||
basketrel_html += '<div>Total: '+amountUKF+'</div>';
|
||||
basketrel_html += '<div>Nouveau solde: '+newBalanceUKF+'</div>';
|
||||
if (newBalance < 0)
|
||||
|
|
Loading…
Reference in a new issue