From: Jan Büren Date: Thu, 14 Mar 2019 12:37:18 +0000 (+0100) Subject: Kontoauszug verbuchen: Zugewiesen abzgl. Skonto berechnen X-Git-Tag: release-3.5.4~96 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=798aed3910f163ca86feb909e43dd9747615b4bf;p=kivitendo-erp.git Kontoauszug verbuchen: Zugewiesen abzgl. Skonto berechnen Oberflächen-Kosmetik, damit der Benutzer klarer sieht, was am Ende der Bankbewegung auf Skonto und von der Bankbewegung abgezogen wird. --- diff --git a/js/kivi.BankTransaction.js b/js/kivi.BankTransaction.js index a0a0f0fe4..b75621721 100644 --- a/js/kivi.BankTransaction.js +++ b/js/kivi.BankTransaction.js @@ -82,7 +82,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 +151,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); }; }); diff --git a/templates/webpages/bank_transactions/_payment_suggestion.html b/templates/webpages/bank_transactions/_payment_suggestion.html index 8f2e736ce..d48162108 100644 --- a/templates/webpages/bank_transactions/_payment_suggestion.html +++ b/templates/webpages/bank_transactions/_payment_suggestion.html @@ -1,12 +1,16 @@ [%- USE P -%][%- USE HTML -%][%- USE LxERP -%] - +[% SELECT_OPTIONS = invoice.get_payment_select_options_for_bank_transaction(bt_id) %] +[% is_skonto_pt = SELECT_OPTIONS.1.selected %] +[% formatted_skonto_amount = LxERP.format_amount(invoice.skonto_amount, 2) %] +[% formatted_skonto_amount_selected = is_skonto_pt ? $formatted_skonto_amount : LxERP.format_amount(0, 2) %] + [% P.hidden_tag("invoice_ids." _ bt_id _ "[]", invoice.id) %] - [% SELECT_OPTIONS = invoice.get_payment_select_options_for_bank_transaction(bt_id) %] - [% formatted_skonto_amount_selected = SELECT_OPTIONS.1.selected ? LxERP.format_amount(invoice.skonto_amount, 2) : LxERP.format_amount(0, 2) %] - [% formatted_skonto_amount = LxERP.format_amount(invoice.skonto_amount, 2) %] + [% P.hidden_tag("skonto_pt." _ bt_id _ "." _ invoice.id _ "", is_skonto_pt) %] [% LxERP.t8("Invno.") %]: [% HTML.escape(invoice.invnumber) %]
[% LxERP.t8("Open amount") %]: [% LxERP.format_amount(invoice.open_amount, 2) %]
[% P.select_tag("invoice_skontos." _ bt_id _ "[]", SELECT_OPTIONS, value_key="payment_type", title_key="display", onChange="kivi.BankTransaction.update_skonto(this, " _ bt_id _ ", " _ invoice.id _ ", '$formatted_skonto_amount')" ) %]
- [% LxERP.t8("Skonto amount") %]: [% P.input_tag("free_skonto_amount." _ bt_id _ "." _ invoice.id _ "", "$formatted_skonto_amount_selected", default=0, style=style, disabled=1, size=4, class='numeric') %] + [% LxERP.t8("Skonto amount") %]: [% P.input_tag("free_skonto_amount." _ bt_id _ "." _ invoice.id _ "", "$formatted_skonto_amount_selected", default=0, style=style, disabled=1, size=4, class='numeric', onblur="kivi.BankTransaction.update_invoice_amount(" _ bt_id _ ", 0, this)") %] [% P.link_tag("#", "x", onclick="kivi.BankTransaction.delete_invoice(" _ bt_id _ "," _ invoice.id _ ")") %]