forked from DGNum/gestioCOF
bugfix
This commit is contained in:
parent
2394a5e5d2
commit
99d04fb75e
1 changed files with 30 additions and 17 deletions
|
@ -989,27 +989,39 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addExistingPurchase(opeindex, nb) {
|
function addExistingPurchase(opeindex, nb) {
|
||||||
type = formset_container.find("#id_form-"+opeindex+"-type").val();
|
var type = formset_container.find("#id_form-"+opeindex+"-type").val();
|
||||||
id = formset_container.find("#id_form-"+opeindex+"-article").val();
|
var id = formset_container.find("#id_form-"+opeindex+"-article").val();
|
||||||
nb_before = formset_container.find("#id_form-"+opeindex+"-article_nb").val();
|
var nb_before = formset_container.find("#id_form-"+opeindex+"-article_nb").val();
|
||||||
nb_after = parseInt(nb_before) + parseInt(nb);
|
var nb_after = parseInt(nb_before) + parseInt(nb);
|
||||||
|
var amountEuro_after = amountEuroPurchase(id, nb_after);
|
||||||
|
var amountUKF_after = amountToUKF(amountEuro_after, account_data['is_cof']);
|
||||||
|
|
||||||
if (type == 'purchase') {
|
if (type == 'purchase') {
|
||||||
if (nb_after == 0) {
|
if (nb_after == 0) {
|
||||||
deleteFromBasket(opeindex);
|
deleteFromBasket(opeindex);
|
||||||
} else if (nb_after > 0 && nb_after <= 25) {
|
} else if (nb_after > 0 && nb_after <= 25) {
|
||||||
amountEuro_after = amountEuroPurchase(id, nb_after);
|
if (nb_before > 0) {
|
||||||
amountUKF_after = amountToUKF(amountEuro_after, account_data['is_cof']);
|
var article_html = basket_container.find('[data-opeindex='+opeindex+']');
|
||||||
var article_html = basket_container.find('[data-opeindex='+opeindex+']');
|
article_html.find('.amount').text(amountUKF_after).end()
|
||||||
article_html.find('.amount').text(amountUKF_after).end()
|
.find('.number').text(nb_after+'/'+article_data[4]).end() ;
|
||||||
.find('.number').text(nb_after+'/'+article_data[4]).end() ;
|
|
||||||
|
|
||||||
if (is_low_stock(id, nb_after))
|
} else {
|
||||||
article_html.find('.lowstock')
|
article_html = $(item_basket_default_html);
|
||||||
.show();
|
article_html
|
||||||
else
|
.attr('data-opeindex', opeindex)
|
||||||
article_html.find('.lowstock')
|
.find('.number').text('('+nb_after+'/'+article_data[4]+')').end()
|
||||||
.hide();
|
.find('.name').text(article_data[0]).end()
|
||||||
|
.find('.amount').text(amountUKF_after);
|
||||||
|
basket_container.prepend(article_basket_html);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_low_stock(id, nb_after))
|
||||||
|
article_html.find('.lowstock')
|
||||||
|
.show();
|
||||||
|
else
|
||||||
|
article_html.find('.lowstock')
|
||||||
|
.hide();
|
||||||
updateExistingFormset(opeindex, nb_after, amountEuro_after);
|
updateExistingFormset(opeindex, nb_after, amountEuro_after);
|
||||||
updateBasketRel();
|
updateBasketRel();
|
||||||
}
|
}
|
||||||
|
@ -1150,13 +1162,14 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteFromFormset(opeindex) {
|
function deleteFromFormset(opeindex) {
|
||||||
formset_container.find('#id_form-'+opeindex+'-DELETE').prop('checked', true);
|
updateExistingFormset(opeindex, 0, '0.00');
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateExistingFormset(opeindex, nb, amount) {
|
function updateExistingFormset(opeindex, nb, amount) {
|
||||||
formset_container
|
formset_container
|
||||||
.find('#id_form-'+opeindex+'-amount').val((parseFloat(amount)).toFixed(2)).end()
|
.find('#id_form-'+opeindex+'-amount').val((parseFloat(amount)).toFixed(2)).end()
|
||||||
.find('#id_form-'+opeindex+'-article_nb').val(nb);
|
.find('#id_form-'+opeindex+'-article_nb').val(nb).end()
|
||||||
|
.find('#id_form-'+opeindex+'-DELETE').prop('checked', !nb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
Loading…
Reference in a new issue