forked from DGNum/gestioCOF
one line by article id
This commit is contained in:
parent
9443f86298
commit
711ef7e97b
1 changed files with 23 additions and 12 deletions
|
@ -774,6 +774,16 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPurchase(id, nb) {
|
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 amount_euro = amountEuroPurchase(id, nb).toFixed(2);
|
||||||
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
||||||
article_basket_html = $(item_basket_default_html);
|
article_basket_html = $(item_basket_default_html);
|
||||||
|
@ -785,6 +795,7 @@ $(document).ready(function() {
|
||||||
basket_container.prepend(article_basket_html);
|
basket_container.prepend(article_basket_html);
|
||||||
updateBasketRel();
|
updateBasketRel();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addDeposit(amount, is_checkout=1) {
|
function addDeposit(amount, is_checkout=1) {
|
||||||
var deposit_basket_html = $(item_basket_default_html);
|
var deposit_basket_html = $(item_basket_default_html);
|
||||||
|
@ -903,8 +914,8 @@ $(document).ready(function() {
|
||||||
function addExistingPurchase(opeindex, nb) {
|
function addExistingPurchase(opeindex, nb) {
|
||||||
type = formset_container.find("#id_form-"+opeindex+"-type").val();
|
type = formset_container.find("#id_form-"+opeindex+"-type").val();
|
||||||
id = formset_container.find("#id_form-"+opeindex+"-article").val();
|
id = formset_container.find("#id_form-"+opeindex+"-article").val();
|
||||||
nb_before = parseInt(formset_container.find("#id_form-"+opeindex+"-article_nb").val());
|
nb_before = formset_container.find("#id_form-"+opeindex+"-article_nb").val();
|
||||||
nb_after = nb_before + nb;
|
nb_after = parseInt(nb_before) + parseInt(nb);
|
||||||
if (type == 'purchase') {
|
if (type == 'purchase') {
|
||||||
if (nb_after == 0) {
|
if (nb_after == 0) {
|
||||||
deleteFromBasket(opeindex);
|
deleteFromBasket(opeindex);
|
||||||
|
|
Loading…
Reference in a new issue