update account_data[] to account_manager.account.

This commit is contained in:
Aurélien Delobelle 2017-02-13 00:41:41 +01:00
parent 890be9b343
commit d9fc683525

View file

@ -630,7 +630,7 @@ $(document).ready(function() {
// Event listener
checkoutInput.on('change', function() {
retrieveCheckoutData(checkoutInput.val());
if (account_data['trigramme']) {
if (account_manager.account.trigramme) {
articleSelect.focus().select();
} else {
account_manager._$input_trigramme.focus().select();
@ -1000,10 +1000,10 @@ $(document).ready(function() {
function amountEuroPurchase(article_data, nb) {
var cfg = Config.getAll();
var amount_euro = - article_data[3] * nb ;
if (cfg.addcost_for && cfg.addcost_amount && account_data['trigramme'] != cfg.addcost_for)
if (cfg.addcost_for && cfg.addcost_amount && account_manager.account.trigramme != cfg.addcost_for)
amount_euro -= cfg.addcost_amount * nb;
var reduc_divisor = 1;
if (account_data['is_cof'])
if (account_manager.account.is_cof)
reduc_divisor = 1 + cfg.subvention_cof / 100;
return amount_euro / reduc_divisor;
}
@ -1021,7 +1021,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_manager.account.is_cof));
basket_container.prepend(article_basket_html);
updateBasketRel();
}
@ -1035,7 +1035,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_manager.account.is_cof));
basket_container.prepend(deposit_basket_html);
updateBasketRel();
}
@ -1048,7 +1048,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_manager.account.is_cof));
basket_container.prepend(withdraw_basket_html);
updateBasketRel();
}
@ -1090,7 +1090,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_manager.account.is_cof));
});
}
@ -1098,7 +1098,9 @@ $(document).ready(function() {
function updateBasketRel() {
var basketrel_html = '';
if (account_data['trigramme'] == 'LIQ' && !isBasketEmpty()) {
var trigramme = account_manager.account.trigramme;
var is_cof = account_manager.account.is_cof;
if (trigramme == 'LIQ' && !isBasketEmpty()) {
var amount = - getAmountBasket();
basketrel_html += '<div>Total: '+amount.toFixed(2)+' €</div>';
if (amount < 5)
@ -1107,11 +1109,11 @@ $(document).ready(function() {
basketrel_html += '<div>Sur 10€: '+ (10-amount).toFixed(2) +' €</div>';
if (amount < 20)
basketrel_html += '<div>Sur 20€: '+ (20-amount).toFixed(2) +' €</div>';
} else if (account_data['trigramme'] != '' && !isBasketEmpty()) {
} else if (trigramme != '' && !isBasketEmpty()) {
var amount = getAmountBasket();
var amountUKF = amountToUKF(amount, account_manager.account.is_cof);
var amountUKF = amountToUKF(amount, is_cof);
var newBalance = account_manager.account.balance + amount;
var newBalanceUKF = amountToUKF(newBalance, account_manager.account.is_cof);
var newBalanceUKF = amountToUKF(newBalance, is_cof);
basketrel_html += '<div>Total: '+amountUKF+'</div>';
basketrel_html += '<div>Nouveau solde: '+newBalanceUKF+'</div>';
if (newBalance < 0)