forked from DGNum/gestioCOF
functions to change purchase amount
This commit is contained in:
parent
5492ecf534
commit
437233fd10
1 changed files with 26 additions and 0 deletions
|
@ -886,6 +886,26 @@ $(document).ready(function() {
|
|||
updateBasketRel();
|
||||
}
|
||||
|
||||
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;
|
||||
if (type == 'purchase') {
|
||||
if (nb_after == 0) {
|
||||
deleteFromBasket(opeindex);
|
||||
} else if (nb_after > 0 && nb_after <= 25) {
|
||||
amountEuro_after = amountEuroPurchase(id, nb_after);
|
||||
amountUKF_after = amountToUKF(amountEuro_after, account_data['is_cof']);
|
||||
basket_container.find('[data-opeindex='+opeindex+']')
|
||||
.find('.amount').text(amountUKF_after).end()
|
||||
.find('.number').text(nb_after).end() ;
|
||||
updateExistingFormset(opeindex, nb_after, amountEuro_after);
|
||||
updateBasketRel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetBasket() {
|
||||
basket_container.find('tr').remove();
|
||||
mngmt_total_forms = 1;
|
||||
|
@ -1022,6 +1042,12 @@ $(document).ready(function() {
|
|||
formset_container.find('#id_form-'+opeindex+'-DELETE').prop('checked', true);
|
||||
}
|
||||
|
||||
function updateExistingFormset(opeindex, nb, amount) {
|
||||
formset_container
|
||||
.find('#id_form-'+opeindex+'-amount').val((parseFloat(amount)).toFixed(2)).end()
|
||||
.find('#id_form-'+opeindex+'-article_nb').val(nb);
|
||||
}
|
||||
|
||||
// -----
|
||||
// History
|
||||
// -----
|
||||
|
|
Loading…
Reference in a new issue