diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html
index 47feb71b..4be8b48e 100644
--- a/kfet/templates/kfet/kpsul.html
+++ b/kfet/templates/kfet/kpsul.html
@@ -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
// -----