one line by article id

This commit is contained in:
Ludovic Stephan 2016-12-13 01:13:16 -02:00
parent 9443f86298
commit 711ef7e97b

View file

@ -774,6 +774,16 @@ $(document).ready(function() {
}
function addPurchase(id, nb) {
var existing = false;
formset_container.find('[data-opeindex]').each(function () {
var opeindex = $(this).attr('data-opeindex');
var article_id = $(this).find('#id_form-'+opeindex+'-article').val();
if (article_id == id) {
existing = true ;
addExistingPurchase(opeindex, nb);
}
});
if (!existing) {
var amount_euro = amountEuroPurchase(id, nb).toFixed(2);
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
article_basket_html = $(item_basket_default_html);
@ -785,6 +795,7 @@ $(document).ready(function() {
basket_container.prepend(article_basket_html);
updateBasketRel();
}
}
function addDeposit(amount, is_checkout=1) {
var deposit_basket_html = $(item_basket_default_html);
@ -903,8 +914,8 @@ $(document).ready(function() {
function addExistingPurchase(opeindex, nb) {
type = formset_container.find("#id_form-"+opeindex+"-type").val();
id = formset_container.find("#id_form-"+opeindex+"-article").val();
nb_before = parseInt(formset_container.find("#id_form-"+opeindex+"-article_nb").val());
nb_after = nb_before + nb;
nb_before = formset_container.find("#id_form-"+opeindex+"-article_nb").val();
nb_after = parseInt(nb_before) + parseInt(nb);
if (type == 'purchase') {
if (nb_after == 0) {
deleteFromBasket(opeindex);