From 33d579af2747e8427fab0e31625871a83cff75e9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 30 Jan 2017 14:24:00 +0100 Subject: [PATCH] =?utf8?q?Kontoauszug=20verbuchen:=20Spalte=20=C2=BBZugewi?= =?utf8?q?esen=C2=AB=20bei=20Zuweisungs=C3=A4nderung=20neu=20berechnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/BankTransaction.pm | 4 ++-- js/kivi.BankTransaction.js | 15 +++++++++++++++ .../webpages/bank_transactions/invoices.html | 4 ++-- .../webpages/bank_transactions/tabs/all.html | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index f413b736e..e41699857 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -337,8 +337,8 @@ sub action_ajax_payment_suggestion { value_key => 'payment_type', title_key => 'display' ) if @select_options; - $html .= 'x'; - $html = SL::Presenter->html_tag('div', $html, id => $::form->{bt_id} . '.' . $::form->{prop_id}); + $html .= SL::Presenter->html_tag('a', 'x', href => '#', onclick => "kivi.BankTransaction.delete_invoice(" . $::form->{bt_id} . ',' . $::form->{prop_id} . ")"); + $html = SL::Presenter->html_tag('div', $html, id => $::form->{bt_id} . '.' . $::form->{prop_id}, 'data-invoice-amount' => $invoice->open_amount * 1); $self->render(\ SL::JSON::to_json( { 'html' => $html } ), { layout => 0, type => 'json', process => 0 }); }; diff --git a/js/kivi.BankTransaction.js b/js/kivi.BankTransaction.js index 08f51334c..7e3fb2e35 100644 --- a/js/kivi.BankTransaction.js +++ b/js/kivi.BankTransaction.js @@ -19,6 +19,7 @@ namespace('kivi.BankTransaction', function(ns) { url: 'controller.pl?action=BankTransaction/ajax_payment_suggestion&bt_id=' + bank_transaction_id + '&prop_id=' + proposal_id, success: function(data) { $('#assigned_invoices_' + bank_transaction_id).append(data.html); + ns.update_invoice_amount(bank_transaction_id); } }); }; @@ -26,6 +27,7 @@ namespace('kivi.BankTransaction', function(ns) { ns.delete_invoice = function(bank_transaction_id, proposal_id) { $( "#" + bank_transaction_id + "\\." + proposal_id ).remove(); $('[data-proposal-id=' + proposal_id + ']').show(); + ns.update_invoice_amount(bank_transaction_id); }; ns.create_invoice = function(bank_transaction_id) { @@ -59,12 +61,25 @@ namespace('kivi.BankTransaction', function(ns) { success: function(new_html) { $('#assigned_invoices_' + bank_transaction_id).append(new_html); $('#assign_invoice_window').dialog('close'); + ns.update_invoice_amount(bank_transaction_id); } }); } + ns.update_invoice_amount = function(bank_transaction_id) { + var $container = $('#invoice_amount_' + bank_transaction_id); + var amount = $container.data('invoice-amount') * 1; + + $('[id^="' + bank_transaction_id + '."]').each(function(idx, elt) { + amount += $(elt).data('invoice-amount'); + }); + + $container.html(kivi.format_amount(amount, 2)); + }; + ns.init_list = function(ui_tab) { $('#check_all').checkall('INPUT[name^="proposal_ids"]'); + $('.sort_link').each(function() { var _href = $(this).attr("href"); $(this).attr("href", _href + "&filter.fromdate=" + $('#filter_fromdate').val() + "&filter.todate=" + $('#filter_todate').val()); diff --git a/templates/webpages/bank_transactions/invoices.html b/templates/webpages/bank_transactions/invoices.html index 6f251f922..4605a60a7 100644 --- a/templates/webpages/bank_transactions/invoices.html +++ b/templates/webpages/bank_transactions/invoices.html @@ -1,8 +1,8 @@ [% USE L %] [% USE T8 %] -[% USE LxERP %] +[% USE LxERP %][%- USE HTML -%] [% FOREACH invoice = INVOICES %] -
+
[% L.hidden_tag('invoice_ids.' _ bt_id _'[]', invoice.id) %] [% 'Invno.' | $T8 %]: [% invoice.invnumber %] [% 'Open amount' | $T8 %]: [% LxERP.format_amount(invoice.open_amount, 2) %] diff --git a/templates/webpages/bank_transactions/tabs/all.html b/templates/webpages/bank_transactions/tabs/all.html index 529b1dc63..c7c3b8dc5 100644 --- a/templates/webpages/bank_transactions/tabs/all.html +++ b/templates/webpages/bank_transactions/tabs/all.html @@ -99,7 +99,7 @@ [% bt.transdate_as_date %] [% LxERP.format_amount(bt.amount, 2) %] - [% LxERP.format_amount(bt.invoice_amount, 2) %] + [% HTML.escape(LxERP.format_amount(bt.invoice_amount, 2)) %] [% HTML.escape(bt.remote_name) %] [% HTML.escape(bt.purpose) %] [% HTML.escape(bt.transaction_text) %] -- 2.20.1