Kontoauszug verbuchen: Beleg/Memo bei »Alle Buchungen« angeben können
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 8 Feb 2017 16:29:57 +0000 (17:29 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 8 Feb 2017 16:31:01 +0000 (17:31 +0100)
SL/Controller/BankTransaction.pm
js/kivi.BankTransaction.js
templates/webpages/bank_transactions/_payment_suggestion.html [new file with mode: 0644]
templates/webpages/bank_transactions/invoices.html
templates/webpages/bank_transactions/tabs/all.html

index f2f16b5..13b65b7 100644 (file)
@@ -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} );
     }
index a477946..838b98a 100644 (file)
@@ -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 (file)
index 0000000..94df64c
--- /dev/null
@@ -0,0 +1,10 @@
+[%- USE P -%][%- USE HTML -%][%- USE LxERP -%]
+<span id="[% HTML.escape(bt_id) %].[% HTML.escape(prop_id) %]" data-invoice-amount="[% HTML.escape(invoice.open_amount * 1) %]">
+ [% 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 _ ")") %]
+</span>
index 4605a60..3dbfb49 100644 (file)
@@ -1,11 +1,32 @@
-[% USE L %]
-[% USE T8 %]
-[% USE LxERP %][%- USE HTML -%]
+[%- USE HTML -%][%- USE LxERP -%][%- USE P -%]
+[% SET debug=1 %]
 [% FOREACH invoice = INVOICES %]
-  <div id="[% bt_id %].[% invoice.id %]" data-invoice-amount="[% HTML.escape(invoice.open_amount * 1) %]">
-    [% L.hidden_tag('invoice_ids.' _ bt_id _'[]', invoice.id) %]
-    [% 'Invno.' | $T8 %]: [% invoice.invnumber %]
-    [% 'Open amount' | $T8 %]: [% LxERP.format_amount(invoice.open_amount, 2) %]
-    <a href=# onclick="kivi.BankTransaction.delete_invoice([% bt_id %], [% invoice.id %])">x</a>
-  </div>
+ <tr id="extra_row_[% HTML.escape(bt_id) %]_[% HTML.escape(invoice.id) %]">
+  <td></td>
+  <td></td>
+  <td id="assigned_invoices_[% bt.id %]_[% invoice.id %]">
+   <span id="[% bt_id %].[% invoice.id %]" data-invoice-amount="[% HTML.escape(invoice.open_amount * 1) %]">
+    [% 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 _ ")") %]
+   </span>
+  </td>
+  <td>[% P.input_tag("sources_" _ bt_id _ "_" _ invoice.id, "") %]</td>
+  <td>[% P.input_tag("memos_" _ bt_id _ "_" _ invoice.id, "") %]</td>
+  [% IF debug %]
+  <td></td>
+  [% END %]
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+  <td></td>
+ </tr>
 [% END %]
index c7038b0..247b51a 100644 (file)
@@ -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 %]
+        <div data-proposal-id="[% prop.id %]">
+         <a href=# onclick="kivi.BankTransaction.add_invoices('[% bt.id %]', '[% prop.id %]');"
+            title="<table><tr><th></th><th>[% 'Suggested invoice' | $T8 %][% IF !prop.is_sales %] ([% 'AP' | $T8 %])[% END %]</th><th>[% 'Bank transaction' | $T8 %]</th></tr><tr><th>[% 'Amount' | $T8 %]</th><td>[% prop.realamount %] ([% 'open' | $T8 %]: [% LxERP.format_amount(prop.open_amount, 2) %])</td><td>[% LxERP.format_amount(bt.amount, 2) %]</td></tr>[% IF prop.skonto_date %]<tr><th>[% 'Payment terms' | $T8 %]</th><td>[% LxERP.format_amount(prop.amount_less_skonto, 2) %] [% 'until' | $T8 %] [% HTML.escape(prop.skonto_date.to_kivitendo) %] ([% prop.percent_skonto * 100 %] %)</td><td></td></tr>[% END %]<tr><th>[% 'Customer/Vendor' | $T8 %]</th><td>[% HTML.escape(prop.customer.displayable_name) %][% HTML.escape(prop.vendor.displayable_name) %]</td><td>[% HTML.escape(bt.remote_name) %]</td></tr><tr><th>[% 'Invoice Date' | $T8 %]</th><td>[% HTML.escape(prop.transdate_as_date) %]</td><td>[% HTML.escape(bt.transdate_as_date) %] ([% HTML.escape(bt.transdate.utc_rd_days - prop.transdate.utc_rd_days) %])</td></tr><tr><th>[% 'Invoice Number' | $T8 %]</th><td>[% HTML.escape(prop.invnumber) %]</td><td>[% HTML.escape(bt.purpose) %]</td></tr></table>"
+              class="[% IF bt.agreement >= 5 %]green[% ELSIF bt.agreement < 5 and bt.agreement >= 3 %]orange[% ELSE %]red[% END %] tooltipster-html">&larr;[% HTML.escape(prop.invnumber)%]</a>
+        </div>
+[% END %]
 
 [% SET debug=1 %]
 <form method="post" id="list_all_form">
@@ -13,7 +21,9 @@
    <tr class="listheading">
     <th></th>
     <th></th>
-    <th>[% 'Assigned invoices' | $T8 %] [% 'with amount' | $T8 %]</th>
+    <th>[% LxERP.t8("Assigned invoices with amount") %]</th>
+    <th style="width: 100px">[% LxERP.t8("Source") %]</th>
+    <th style="width: 100px">[% LxERP.t8("Memo") %]</th>
     [% IF debug %]
     <th>[% 'Score' | $T8 %]</th>
     [% END %]
    </tr>
   </thead>
 
-  <tbody>
-   [%- FOREACH bt = BANK_TRANSACTIONS %]
-    <tr class="listrow" id="bt_id_[% bt.id %]">
-     <td><a href=# onclick="kivi.BankTransaction.assign_invoice('[% bt.id %]'); return false;">[% 'Assign invoice' | $T8 %]</a></td>
-     <td><a href=# onclick="kivi.BankTransaction.create_invoice('[% bt.id %]'); return false;">[% 'Create invoice' | $T8 %]</a></td>
-     <td id="assigned_invoices_[% bt.id %]" nowrap></td>
-     [% IF debug %]
-     <td class="tooltipster-html" title="[% FOREACH match = bt.rule_matches %] [% match %]<br> [% END %]">[% bt.agreement %]</td>
-     [% END %]
-     <td>
-      [% FOREACH prop = bt.proposals %]
-        <div data-proposal-id="[% prop.id %]">
-         <a href=# onclick="kivi.BankTransaction.add_invoices('[% bt.id %]', '[% prop.id %]');"
-            title="<table><tr><th></th><th>[% 'Suggested invoice' | $T8 %][% IF !prop.is_sales %] ([% 'AP' | $T8 %])[% END %]</th><th>[% 'Bank transaction' | $T8 %]</th></tr><tr><th>[% 'Amount' | $T8 %]</th><td>[% prop.realamount %] ([% 'open' | $T8 %]: [% LxERP.format_amount(prop.open_amount, 2) %])</td><td>[% LxERP.format_amount(bt.amount, 2) %]</td></tr>[% IF prop.skonto_date %]<tr><th>[% 'Payment terms' | $T8 %]</th><td>[% LxERP.format_amount(prop.amount_less_skonto, 2) %] [% 'until' | $T8 %] [% HTML.escape(prop.skonto_date.to_kivitendo) %] ([% prop.percent_skonto * 100 %] %)</td><td></td></tr>[% END %]<tr><th>[% 'Customer/Vendor' | $T8 %]</th><td>[% HTML.escape(prop.customer.displayable_name) %][% HTML.escape(prop.vendor.displayable_name) %]</td><td>[% HTML.escape(bt.remote_name) %]</td></tr><tr><th>[% 'Invoice Date' | $T8 %]</th><td>[% HTML.escape(prop.transdate_as_date) %]</td><td>[% HTML.escape(bt.transdate_as_date) %] ([% HTML.escape(bt.transdate.utc_rd_days - prop.transdate.utc_rd_days) %])</td></tr><tr><th>[% 'Invoice Number' | $T8 %]</th><td>[% HTML.escape(prop.invnumber) %]</td><td>[% HTML.escape(bt.purpose) %]</td></tr></table>"
-              class="[% IF bt.agreement >= 5 %]green[% ELSIF bt.agreement < 5 and bt.agreement >= 3 %]orange[% ELSE %]red[% END %] tooltipster-html">&larr;[% HTML.escape(prop.invnumber)%]</a></div>
-      [% END %]
-     </td>
-     <td align=right>[% bt.transdate_as_date %]</td>
-     <td align=right>[% LxERP.format_amount(bt.amount, 2) %]</td>
-     <td align=right id="invoice_amount_[% HTML.escape(bt.id) %]" data-invoice-amount="[% HTML.escape(bt.invoice_amount) %]">[% HTML.escape(LxERP.format_amount(bt.invoice_amount, 2)) %]</td>
-     <td>[% HTML.escape(bt.remote_name) %]</td>
-     <td>[% HTML.escape(bt.purpose) %]</td>
-     <td>[% HTML.escape(bt.transaction_text) %]</td>
-     <td>[% HTML.escape(bt.remote_account_number) %]</td>
-     <td>[% HTML.escape(bt.remote_bank_code) %]</td>
-     <td align=right>[% bt.valutadate_as_date %]</td>
-     <td align=center>[% HTML.escape(bt.currency.name) %]</td>
-    </tr>
-    [%- END %]
-  </tbody>
+  [%- FOREACH bt = BANK_TRANSACTIONS %]
+   <tbody class="listrow" id="bt_rows_[% HTML.escape(bt.id) %]">
+    [% FOREACH prop = bt.proposals %]
+     [% IF loop.first %]
+      <tr id="bt_id_[% bt.id %]">
+       <td><a href=# onclick="kivi.BankTransaction.assign_invoice('[% bt.id %]'); return false;">[% 'Assign invoice' | $T8 %]</a></td>
+       <td><a href=# onclick="kivi.BankTransaction.create_invoice('[% bt.id %]'); return false;">[% 'Create invoice' | $T8 %]</a></td>
+       <td id="assigned_invoices_[% bt.id %]_[% prop.id %]"></td>
+       <td>[% P.input_tag("sources_" _ bt.id _ "_" _ prop.id, "", class="hidden") %]</td>
+       <td>[% P.input_tag("memos_" _ bt.id _ "_" _ prop.id, "", class="hidden") %]</td>
+       [% IF debug %]
+       <td class="tooltipster-html" title="[% FOREACH match = bt.rule_matches %] [% match %]<br> [% END %]">[% bt.agreement %]</td>
+       [% END %]
+       <td>
+        [% PROCESS proposal_div %]
+       </td>
+       <td align="right">[% bt.transdate_as_date %]</td>
+       <td align="right">[% LxERP.format_amount(bt.amount, 2) %]</td>
+       <td align="right" id="invoice_amount_[% HTML.escape(bt.id) %]" data-invoice-amount="[% HTML.escape(bt.invoice_amount) %]">[% HTML.escape(LxERP.format_amount(bt.invoice_amount, 2)) %]</td>
+       <td>[% HTML.escape(bt.remote_name) %]</td>
+       <td>[% HTML.escape(bt.purpose) %]</td>
+       <td>[% HTML.escape(bt.transaction_text) %]</td>
+       <td>[% HTML.escape(bt.remote_account_number) %]</td>
+       <td>[% HTML.escape(bt.remote_bank_code) %]</td>
+       <td align="right">[% bt.valutadate_as_date %]</td>
+       <td align="center">[% HTML.escape(bt.currency.name) %]</td>
+      </tr>
+     [% ELSE # loop.first %]
+      <tr>
+       <td></td>
+       <td></td>
+       <td id="assigned_invoices_[% bt.id %]_[% prop.id %]"></td>
+       <td>[% P.input_tag("sources_" _ bt.id _ "_" _ prop.id, "", class="hidden") %]</td>
+       <td>[% P.input_tag("memos_" _ bt.id _ "_" _ prop.id, "", class="hidden") %]</td>
+       [% IF debug %]
+       <td></td>
+       [% END %]
+       <td>
+        [% PROCESS proposal_div %]
+       </td>
+       <td></td>
+       <td></td>
+       <td></td>
+       <td></td>
+       <td></td>
+       <td></td>
+       <td></td>
+       <td></td>
+       <td></td>
+       <td></td>
+      </tr>
+     [% END # loop.first %]
+    [% END # FOREACH proposal %]
+   </tbody>
+  [%- END %]
  </table>
-[% L.submit_tag('action_save_invoices', LxERP.t8('Save invoices')) %]
+
+ <p>
+  [% 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')) %]
+ </p>
 
 </form>