diff --git a/kfet/static/kfet/css/kpsul.css b/kfet/static/kfet/css/kpsul.css index 2631d333..16f33922 100644 --- a/kfet/static/kfet/css/kpsul.css +++ b/kfet/static/kfet/css/kpsul.css @@ -430,11 +430,12 @@ input[type=number]::-webkit-outer-spin-button { color:#FFF; } -.basket_summary table { +.basket_summary { margin: 0 auto; + text-align: right; } -.basket_summary table tr td:first-child { +.basket_summary .name { padding-right: 15px; font-weight: bold; } diff --git a/kfet/static/kfet/js/kfet.api.js b/kfet/static/kfet/js/kfet.api.js index 1fb62eb5..0d1652df 100644 --- a/kfet/static/kfet/js/kfet.api.js +++ b/kfet/static/kfet/js/kfet.api.js @@ -945,7 +945,7 @@ class PurchaseBasket extends Purchase { let reduc_divisor = 1; if (kpsul.account_manager.account.is_cof) reduc_divisor += Config.get('subvention_cof') / 100; - return amount_ukf / reduc_divisor; + return Math.round((amount_ukf / reduc_divisor)*100)/100; } } @@ -1808,7 +1808,7 @@ class ArticleFormatter extends Formatter { * s.price converted to UKF. */ static prop_price(s) { - return amountToUKF(s.price, true); + return amountToUKF(s.price); } static get _data_stock() { @@ -1895,7 +1895,7 @@ class OpegroupFormatter extends HistoryGroupFormatter { * a.amount displayed according to a.is_cof and a.trigramme values. */ static prop_amount(a) { - return amountDisplay(a.amount, a.is_cof, a.trigramme); + return amountDisplay(a.amount, a.is_cof, a.trigramme, false); } } @@ -1943,7 +1943,7 @@ class OperationFormatter extends Formatter { * a.amount displayed according to a.is_cof and a.trigramme values. */ static prop_amount(a) { - return amountDisplay(a.amount, a.opegroup.is_cof, a.opegroup.trigramme); + return amountDisplay(a.amount, a.opegroup.is_cof, a.opegroup.trigramme, false); } /** @@ -1982,7 +1982,7 @@ class PurchaseFormatter extends OperationFormatter { */ static prop_addcost(a) { if (a.addcost_for) { - return '('+amountDisplay(a.addcost_amount, a.opegroup.is_cof) + return '('+amountDisplay(a.addcost_amount, a.opegroup.is_cof, a.addcost_for, false) +'UKF pour '+a.addcost_for+')'; } else { return ''; @@ -2014,6 +2014,7 @@ class SpecialOpeFormatter extends OperationFormatter { static prop_infos2(a) { return SpecialOperation.verbose_types[a.type] || ''; } + } /** @@ -2047,7 +2048,7 @@ class ItemBasketFormatter extends Formatter { static prop_amount(o) { let account = kpsul.account_manager.account; - return amountDisplay(o.amount, account.is_cof, account.trigramme); + return amountDisplay(o.amount, account.is_cof, account.trigramme, false); } } diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index 0c979bf6..268de3b9 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -240,10 +240,10 @@ function dateUTCToParis(date) { return moment.tz(date, 'UTC').tz('Europe/Paris'); } -function amountDisplay(amount, is_cof=false, tri='') { +function amountDisplay(amount, is_cof=false, tri='', account=true) { if (tri == 'LIQ') return (- amount).toFixed(2) +'€'; - return amountToUKF(amount, is_cof); + return amountToUKF(amount, is_cof, account).toString(); } function amountToUKF(amount, is_cof=false, account=false) { diff --git a/kfet/static/kfet/js/kpsul.js b/kfet/static/kfet/js/kpsul.js index 37c46fa3..cde350ff 100644 --- a/kfet/static/kfet/js/kpsul.js +++ b/kfet/static/kfet/js/kpsul.js @@ -707,7 +707,7 @@ class BasketManager { let total = 0; for (let ope of this.data.roots) total += ope.amount; - return total; + return Number(Math.round(total*100)/100); } add_purchase(article, nb) { @@ -782,29 +782,48 @@ class BasketSummary { } update_infos() { - let html = ''; + let items = []; + if (!this.basket.is_empty() && !kpsul.account_manager.is_empty()) { let account = kpsul.account_manager.account; let amount = this.basket.total_amount(); - html += ''; + + let total_str = amountDisplay(amount, account.is_cof, account.trigramme, false); + items.push(['Total', total_str]); + if (account.trigramme == "LIQ") { let abs_amount = Math.abs(amount); for (let given of [5, 10, 20]) if (abs_amount < given) - html += this.rendu(abs_amount, given); + items.push(this.rendu(abs_amount, given)); } else { let new_balance = account.balance + amount; - html += ''; + + let new_balance_str = amountDisplay( + new_balance, account.is_cof, account.trigramme); + items.push(['Nouveau solde', new_balance_str]); + if (new_balance < 0) - html += ''; + items.push(['Manque', (- new_balance).toFixed(2)+'€']); } } - html += '
Total' + amountDisplay(amount, account.is_cof, account.trigramme) + '
Nouveau solde' + amountDisplay(new_balance, account.is_cof) + '
Manque' + (- new_balance).toFixed(2) + '€
'; - this._$container.html(html); + + this._$container.html(this._$render(items)); } rendu(amount, given) { - return 'Sur ' + given.toString() +'€' + (given - amount).toFixed(2) + '€'; + return [given.toString()+'€', (given - amount).toFixed(2)+'€']; + } + + _$render(items) { + let $elt = $(''); + for (let item of items) + this._$render_item(item[0], item[1]).appendTo($elt); + return $elt; + } + + _$render_item(name, value) { + return $(''); } }
'+name+''+value+'