X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.BankTransaction.js;h=2441aa1dc5199e0abe35326cb77da14225a2af10;hb=23d55c8535d9eecc415791d42ec05a7d9cb5c8e0;hp=a0a0f0fe4c9479e5dbb1f0a250d5c6e0bdc945f7;hpb=6c0095f1ec3bff00c172cc2c7649e757960da9fd;p=kivitendo-erp.git diff --git a/js/kivi.BankTransaction.js b/js/kivi.BankTransaction.js index a0a0f0fe4..2441aa1dc 100644 --- a/js/kivi.BankTransaction.js +++ b/js/kivi.BankTransaction.js @@ -42,14 +42,17 @@ namespace('kivi.BankTransaction', function(ns) { }; ns.create_invoice = function(bank_transaction_id) { + $.post('controller.pl?action=BankTransaction/create_invoice', + '&bt_id=' + bank_transaction_id + "&filter.bank_account=" + $('#filter_bank_account').val() + '&filter.fromdate=' + $('#filter_fromdate').val() + '&filter.todate=' + $('#filter_todate').val(), + kivi.eval_json_result); + }; + + ns.show_create_invoice_dialog = function(dialog_html) { kivi.popup_dialog({ - url: 'controller.pl?action=BankTransaction/create_invoice', - data: '&bt_id=' + bank_transaction_id + "&filter.bank_account=" + $('#filter_bank_account').val() + '&filter.fromdate=' + $('#filter_fromdate').val() + '&filter.todate=' + $('#filter_todate').val(), - type: 'POST', + html: dialog_html, id: 'create_invoice_window', dialog: { title: kivi.t8('Create invoice') } }); - return true; }; @@ -82,7 +85,17 @@ namespace('kivi.BankTransaction', function(ns) { var amount = $container.data('invoice-amount') * 1; $('[id^="' + bank_transaction_id + '."]').each(function(idx, elt) { - amount += $(elt).data('invoice-amount'); + if ($("input[name='skonto_pt." + elt.id + "']").val() == 1) { + // skonto payment term + amount += $(elt).data('invoice-amount-less-skonto'); + } else { + // normal amount + amount += $(elt).data('invoice-amount'); + //subtract free skonto if checked (no check for number!) + if ($("input[name='skonto_pt." + elt.id + "']").val() == 'free_skonto') { + amount -= $("input[name='free_skonto_amount." + elt.id + "']").val(); + } + } }); $container.html(kivi.format_amount(amount, 2)); @@ -141,19 +154,25 @@ namespace('kivi.BankTransaction', function(ns) { }); }; ns.update_skonto = function(caller, bt_id, prop_id, formatted_amount_with_skonto_pt) { + if (caller.value === 'free_skonto') { $('#free_skonto_amount_' + bt_id + '_' + prop_id).val(""); $('#free_skonto_amount_' + bt_id + '_' + prop_id).prop('disabled', false); + $("input[name='skonto_pt." + bt_id + '.' + prop_id + "']").val('free_skonto'); $('#free_skonto_amount_' + bt_id + '_' + prop_id).focus(); } if (caller.value === 'without_skonto') { $('#free_skonto_amount_' + bt_id + '_' + prop_id).val(kivi.format_amount(0,2)); $('#free_skonto_amount_' + bt_id + '_' + prop_id).prop('disabled', true); + $("input[name='skonto_pt." + bt_id + '.' + prop_id + "']").val(0); } if (caller.value === 'with_skonto_pt') { $('#free_skonto_amount_' + bt_id + '_' + prop_id).val(formatted_amount_with_skonto_pt); $('#free_skonto_amount_' + bt_id + '_' + prop_id).prop('disabled', true); + $("input[name='skonto_pt." + bt_id + '.' + prop_id + "']").val(1); } + // recalc assigned amount + ns.update_invoice_amount(bt_id); }; });