From e9775242aa00e33dabab64ca26105640c8808aeb Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 8 Feb 2017 17:29:57 +0100 Subject: [PATCH] =?utf8?q?Kontoauszug=20verbuchen:=20Beleg/Memo=20bei=20?= =?utf8?q?=C2=BBAlle=20Buchungen=C2=AB=20angeben=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/BankTransaction.pm | 23 ++-- js/kivi.BankTransaction.js | 19 +++- .../_payment_suggestion.html | 10 ++ .../webpages/bank_transactions/invoices.html | 39 +++++-- .../webpages/bank_transactions/tabs/all.html | 105 ++++++++++++------ 5 files changed, 138 insertions(+), 58 deletions(-) create mode 100644 templates/webpages/bank_transactions/_payment_suggestion.html diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index f2f16b551..13b65b798 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -337,18 +337,15 @@ sub action_ajax_payment_suggestion { my @select_options = $invoice->get_payment_select_options_for_bank_transaction($::form->{bt_id}); my $html; - $html .= SL::Presenter->input_tag('invoice_ids.' . $::form->{bt_id} . '[]', $::form->{prop_id} , type => 'hidden'); - $html .= SL::Presenter->escape(t8('Invno.') . ': ' . $invoice->invnumber . ' '); - $html .= SL::Presenter->escape(t8('Open amount') . ': ' . $::form->format_amount(\%::myconfig, $invoice->open_amount, 2) . ' '); - $html .= SL::Presenter->select_tag('invoice_skontos.' . $::form->{bt_id} . '[]', - \@select_options, - value_key => 'payment_type', - title_key => 'display' ) - if @select_options; - $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 }); + $html = $self->render( + 'bank_transactions/_payment_suggestion', { output => 0 }, + bt_id => $::form->{bt_id}, + prop_id => $::form->{prop_id}, + invoice => $invoice, + SELECT_OPTIONS => \@select_options, + ); + + $self->render(\ SL::JSON::to_json( { 'html' => "$html" } ), { layout => 0, type => 'json', process => 0 }); }; sub action_filter_drafts { @@ -521,6 +518,8 @@ sub save_invoices { push @{ $self->problems }, $self->save_single_bank_transaction( bank_transaction_id => $bank_transaction_id, invoice_ids => $invoice_ids, + sources => [ map { $::form->{"sources_${bank_transaction_id}_${_}"} } @{ $invoice_ids } ], + memos => [ map { $::form->{"memos_${bank_transaction_id}_${_}"} } @{ $invoice_ids } ], ); $count += scalar( @{$invoice_ids} ); } diff --git a/js/kivi.BankTransaction.js b/js/kivi.BankTransaction.js index a4779465a..838b98aff 100644 --- a/js/kivi.BankTransaction.js +++ b/js/kivi.BankTransaction.js @@ -13,20 +13,31 @@ namespace('kivi.BankTransaction', function(ns) { }; ns.add_invoices = function(bank_transaction_id, proposal_id) { - $('[data-proposal-id=' + proposal_id + ']').hide(); $.ajax({ 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); + $('#assigned_invoices_' + bank_transaction_id + "_" + proposal_id).html(data.html); + $('#sources_' + bank_transaction_id + "_" + proposal_id + ',' + + '#memos_' + bank_transaction_id + "_" + proposal_id).show(); + $('[data-proposal-id=' + proposal_id + ']').hide(); + ns.update_invoice_amount(bank_transaction_id); } }); }; ns.delete_invoice = function(bank_transaction_id, proposal_id) { - $( "#" + bank_transaction_id + "\\." + proposal_id ).remove(); + var $inputs = $('#sources_' + bank_transaction_id + "_" + proposal_id + ',' + + '#memos_' + bank_transaction_id + "_" + proposal_id); + $('[data-proposal-id=' + proposal_id + ']').show(); + $('#assigned_invoices_' + bank_transaction_id + "_" + proposal_id).html(''); + $('#extra_row_' + bank_transaction_id + '_' + proposal_id).remove(); + + $inputs.hide(); + $inputs.val(''); + ns.update_invoice_amount(bank_transaction_id); }; @@ -59,7 +70,7 @@ namespace('kivi.BankTransaction', function(ns) { $.ajax({ url: url, success: function(new_html) { - $('#assigned_invoices_' + bank_transaction_id).append(new_html); + $('#bt_rows_' + bank_transaction_id).append(new_html); $('#assign_invoice_window').dialog('close'); ns.update_invoice_amount(bank_transaction_id); } diff --git a/templates/webpages/bank_transactions/_payment_suggestion.html b/templates/webpages/bank_transactions/_payment_suggestion.html new file mode 100644 index 000000000..94df64c71 --- /dev/null +++ b/templates/webpages/bank_transactions/_payment_suggestion.html @@ -0,0 +1,10 @@ +[%- USE P -%][%- USE HTML -%][%- USE LxERP -%] + + [% P.hidden_tag("invoice_ids." _ bt_id _ "[]", prop_id) %] + [% LxERP.t8("Invno.") %]: [% HTML.escape(invoice.invnumber) %] + [% LxERP.t8("Open amount") %]: [% LxERP.format_amount(invoice.open_amount, 2) %] + [% IF SELECT_OPTIONS.size %] + [% P.select_tag("invoice_skontos." _ bt_id _ "[]", SELECT_OPTIONS, value_key="payment_type", title_key="display") %] + [% END %] + [% P.link("#", "x", onclick="kivi.BankTransaction.delete_invoice(" _ bt_id _ "," _ prop_id _ ")") %] + diff --git a/templates/webpages/bank_transactions/invoices.html b/templates/webpages/bank_transactions/invoices.html index 4605a60a7..3dbfb4931 100644 --- a/templates/webpages/bank_transactions/invoices.html +++ b/templates/webpages/bank_transactions/invoices.html @@ -1,11 +1,32 @@ -[% USE L %] -[% USE T8 %] -[% USE LxERP %][%- USE HTML -%] +[%- USE HTML -%][%- USE LxERP -%][%- USE P -%] +[% SET debug=1 %] [% 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) %] - x -
+ + + + + + [% P.hidden_tag("invoice_ids." _ bt_id _"[]", invoice.id) %] + [% LxERP.t8("Invno.") %]: [% HTML.escape(invoice.invnumber) %] + [% LxERP.t8("Open amount") %]: [% LxERP.format_amount(invoice.open_amount, 2) %] + [% P.link("#", "x", onclick="kivi.BankTransaction.delete_invoice(" _ bt_id _ "," _ invoice.id _ ")") %] + + + [% P.input_tag("sources_" _ bt_id _ "_" _ invoice.id, "") %] + [% P.input_tag("memos_" _ bt_id _ "_" _ invoice.id, "") %] + [% IF debug %] + + [% END %] + + + + + + + + + + + + [% END %] diff --git a/templates/webpages/bank_transactions/tabs/all.html b/templates/webpages/bank_transactions/tabs/all.html index c7038b0ff..247b51a12 100644 --- a/templates/webpages/bank_transactions/tabs/all.html +++ b/templates/webpages/bank_transactions/tabs/all.html @@ -1,4 +1,12 @@ -[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%] +[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%][%- USE P -%] + +[% BLOCK proposal_div %] +
+ ←[% HTML.escape(prop.invnumber)%] +
+[% END %] [% SET debug=1 %]
@@ -13,7 +21,9 @@ - [% 'Assigned invoices' | $T8 %] [% 'with amount' | $T8 %] + [% LxERP.t8("Assigned invoices with amount") %] + [% LxERP.t8("Source") %] + [% LxERP.t8("Memo") %] [% IF debug %] [% 'Score' | $T8 %] [% END %] @@ -80,37 +90,66 @@ - - [%- FOREACH bt = BANK_TRANSACTIONS %] - - [% 'Assign invoice' | $T8 %] - [% 'Create invoice' | $T8 %] - - [% IF debug %] - [% bt.agreement %] - [% END %] - - [% FOREACH prop = bt.proposals %] -
- ←[% HTML.escape(prop.invnumber)%]
- [% END %] - - [% bt.transdate_as_date %] - [% LxERP.format_amount(bt.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) %] - [% HTML.escape(bt.remote_account_number) %] - [% HTML.escape(bt.remote_bank_code) %] - [% bt.valutadate_as_date %] - [% HTML.escape(bt.currency.name) %] - - [%- END %] - + [%- FOREACH bt = BANK_TRANSACTIONS %] + + [% FOREACH prop = bt.proposals %] + [% IF loop.first %] + + [% 'Assign invoice' | $T8 %] + [% 'Create invoice' | $T8 %] + + [% P.input_tag("sources_" _ bt.id _ "_" _ prop.id, "", class="hidden") %] + [% P.input_tag("memos_" _ bt.id _ "_" _ prop.id, "", class="hidden") %] + [% IF debug %] + [% bt.agreement %] + [% END %] + + [% PROCESS proposal_div %] + + [% bt.transdate_as_date %] + [% LxERP.format_amount(bt.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) %] + [% HTML.escape(bt.remote_account_number) %] + [% HTML.escape(bt.remote_bank_code) %] + [% bt.valutadate_as_date %] + [% HTML.escape(bt.currency.name) %] + + [% ELSE # loop.first %] + + + + + [% P.input_tag("sources_" _ bt.id _ "_" _ prop.id, "", class="hidden") %] + [% P.input_tag("memos_" _ bt.id _ "_" _ prop.id, "", class="hidden") %] + [% IF debug %] + + [% END %] + + [% PROCESS proposal_div %] + + + + + + + + + + + + + [% END # loop.first %] + [% END # FOREACH proposal %] + + [%- END %] -[% L.submit_tag('action_save_invoices', LxERP.t8('Save invoices')) %] + +

+ [% L.submit_tag('action_save_invoices', LxERP.t8('Save invoices')) %] + [% L.button_tag('kivi.BankTransaction.show_set_all_sources_memos_dialog("#list_all_form [name^=\\"sources_\\"]:visible", "#list_all_form [name^=\\"memos_\\"]:visible")', LxERP.t8('Set all source and memo fields')) %] +

-- 2.20.1