Kontoauszug verbuchen: »Beleg«/»Memo« bei Vorschlägen angeben können
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 8 Feb 2017 09:18:19 +0000 (10:18 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 8 Feb 2017 16:31:01 +0000 (17:31 +0100)
SL/Controller/BankTransaction.pm
SL/DB/Helper/Payment.pm
js/kivi.BankTransaction.js
js/locale/de.js
locale/de/all
templates/webpages/bank_transactions/list.html
templates/webpages/bank_transactions/tabs/all.html
templates/webpages/bank_transactions/tabs/automatic.html

index 8b0c921..f2f16b5 100644 (file)
@@ -511,6 +511,8 @@ sub save_invoices {
       push @{ $self->problems }, $self->save_single_bank_transaction(
         bank_transaction_id => $bank_transaction_id,
         invoice_ids         => $invoice_ids,
+        sources             => ($::form->{sources} // {})->{$_},
+        memos               => ($::form->{memos}   // {})->{$_},
       );
       $count += scalar( @{$invoice_ids} );
     }
@@ -537,6 +539,7 @@ sub action_save_invoices {
 
 sub action_save_proposals {
   my ($self) = @_;
+
   if ( $::form->{proposal_ids} ) {
     my $propcount = scalar(@{ $::form->{proposal_ids} });
     if ( $propcount > 0 ) {
@@ -620,6 +623,8 @@ sub save_single_bank_transaction {
     my $n_invoices   = 0;
 
     foreach my $invoice (@{ $data{invoices} }) {
+      my $source = ($data{sources} // [])->[$n_invoices];
+      my $memo   = ($data{memos}   // [])->[$n_invoices];
 
       $n_invoices++ ;
 
@@ -665,6 +670,8 @@ sub save_single_bank_transaction {
                               trans_id     => $invoice->id,
                               amount       => $open_amount,
                               payment_type => $payment_type,
+                              source       => $source,
+                              memo         => $memo,
                               transdate    => $bank_transaction->transdate->to_kivitendo);
       } elsif ( $invoice->is_sales && $invoice->type eq 'credit_note' ) {
         # no check for overpayment/multiple payments
@@ -672,6 +679,8 @@ sub save_single_bank_transaction {
                               trans_id     => $invoice->id,
                               amount       => $invoice->open_amount,
                               payment_type => $payment_type,
+                              source       => $source,
+                              memo         => $memo,
                               transdate    => $bank_transaction->transdate->to_kivitendo);
       } else { # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary
         my $overpaid_amount = $amount_of_transaction - $invoice->open_amount;
@@ -679,6 +688,8 @@ sub save_single_bank_transaction {
                               trans_id     => $invoice->id,
                               amount       => $amount_of_transaction,
                               payment_type => $payment_type,
+                              source       => $source,
+                              memo         => $memo,
                               transdate    => $bank_transaction->transdate->to_kivitendo);
         $bank_transaction->invoice_amount($bank_transaction->amount);
         $amount_of_transaction = 0;
index d371e11..89fc6e4 100644 (file)
@@ -112,8 +112,8 @@ sub pay_invoice {
   my $reference_account = $self->reference_account;
   croak "can't find reference account (link = AR/AP) for invoice" unless ref $reference_account;
 
-  my $memo   = $params{'memo'}   || '';
-  my $source = $params{'source'} || '';
+  my $memo   = $params{memo}   // '';
+  my $source = $params{source} // '';
 
   my $rounded_params_amount = _round( $params{amount} ); # / $exchangerate);
   my $fx_gain_loss_amount = 0; # for fx_gain and fx_loss
index 7e3fb2e..a477946 100644 (file)
@@ -87,4 +87,36 @@ namespace('kivi.BankTransaction', function(ns) {
 
     $.cookie('jquery_ui_tab_bt_tabs', ui_tab);
   };
+
+  ns.show_set_all_sources_memos_dialog = function(sources_selector, memos_selector) {
+    var dlg_id = 'set_all_sources_memos_dialog';
+    var $dlg   = $('#' + dlg_id);
+
+    $dlg.data('sources-selector', sources_selector);
+    $dlg.data('memos-selector',   memos_selector);
+
+    $('#set_all_sources').val('');
+    $('#set_all_memos').val('');
+
+    kivi.popup_dialog({
+      id: dlg_id,
+      dialog: {
+        title: kivi.t8('Set all source and memo fields')
+      }
+    });
+  };
+
+  ns.set_all_sources_memos = function(sources_selector, memos_selector) {
+    var $dlg = $('#set_all_sources_memos_dialog');
+
+    ['sources', 'memos'].forEach(function(type) {
+      var value = $('#set_all_' + type).val();
+      if (value !== '')
+        $($dlg.data(type + '-selector')).each(function(idx, input) {
+          $(input).val(value);
+        });
+    });
+
+    $dlg.dialog('close');
+  };
 });
index 93a3aff..299f58b 100644 (file)
@@ -89,6 +89,7 @@ namespace("kivi").setupLocale({
 "Save and keep open":"Speichern und geöffnet lassen",
 "Section/Function block actions":"Abschnitts-/Funktionsblockaktionen",
 "Select template to paste":"Einzufügende Vorlage auswählen",
+"Set all source and memo fields":"Alle Beleg-/Memo-Felder setzen",
 "Show all details":"Alle Details anzeigen",
 "Show details":"Details anzeigen",
 "Subject":"Betreff",
index aa42ab3..4cdc816 100755 (executable)
@@ -2598,8 +2598,10 @@ $self->{texts} = {
   'Service, assembly or part'   => 'Dienstleistung, Erzeugnis oder Ware',
   'Services'                    => 'Dienstleistungen',
   'Set (set to)'                => 'Setze',
+  'Set all source and memo fields' => 'Alle Beleg-/Memo-Felder setzen',
   'Set count for one or more of the items to select them' => 'Zum Selektieren bitte Menge für einen oder mehrere Artikel setzen',
   'Set eMail text'              => 'E-Mail Text eingeben',
+  'Set fields'                  => 'Felder setzen',
   'Set lastcost'                => 'EK-Preis übernehmen',
   'Set sellprice'               => 'VK-Preis übernehmen',
   'Set to paid missing'         => 'Fehlbetrag setzen',
index d5abbcd..2727ba4 100644 (file)
   <div id="automatic">[% PROCESS "bank_transactions/tabs/automatic.html" %]</div>
 </div>
 
+<div id="set_all_sources_memos_dialog" class="hidden">
+ <table>
+  <tr>
+   <th>[% LxERP.t8("Source") %]:</th>
+   <td>[% L.input_tag("set_all_sources", "") %]</td>
+  </tr>
+
+  <tr>
+   <th>[% LxERP.t8("Memo") %]:</th>
+   <td>[% L.input_tag("set_all_memos", "") %]</td>
+  </tr>
+ </table>
+
+ <p>
+  [% L.button_tag("kivi.BankTransaction.set_all_sources_memos()", LxERP.t8("Set fields")) %]
+  <a href="#" onclick="$('#set_all_sources_memos_dialog').dialog('close');">[%- LxERP.t8("Cancel") %]</a>
+ </p>
+</div>
 
 <script type="text/javascript">
 <!--
index c7c3b8d..c7038b0 100644 (file)
@@ -1,7 +1,7 @@
 [%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
 
 [% SET debug=1 %]
-<form method="post" id="list_form">
+<form method="post" id="list_all_form">
 [% L.hidden_tag('filter.bank_account', FORM.filter.bank_account) %]
 [% L.hidden_tag('filter.fromdate', FORM.filter.fromdate) %]
 [% L.hidden_tag('filter.todate',   FORM.filter.todate) %]
index 9caf501..b0dcc2b 100644 (file)
@@ -1,6 +1,6 @@
 [%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
 
-<form method="post" id="list_form">
+<form method="post" id="list_automatic_form">
 [% L.hidden_tag('filter.bank_account', FORM.filter.bank_account) %]
 [% L.hidden_tag('filter.fromdate', FORM.filter.fromdate) %]
 [% L.hidden_tag('filter.todate',   FORM.filter.todate) %]
@@ -19,6 +19,8 @@
       <th>[% 'Skonto' | $T8 %]</th>
       <th>[% 'Purpose/Reference' | $T8 %]</th>
       <th>[% 'Customer/Vendor/Remote name' | $T8 %]</th>
+      <th>[% LxERP.t8("Source") %]</th>
+      <th>[% LxERP.t8("Memo") %]</th>
     </tr>
   </thead>
   [% IF !PROPOSALS.size %]
@@ -54,6 +56,8 @@
               END %]
           </td>
           <td>[% HTML.escape(proposal.remote_name) %]</td>
+          <td></td>
+          <td></td>
         </tr>
 
       [% FOREACH proposed_invoice = proposal.proposals %]
               [% L.hidden_tag("invoice_skontos." _ proposal.id _ "[]", proposed_invoice.skonto_type) %]</td>
           <td[% IF proposed_invoice.invnumber == invnumber_found %] class="invoice_number_highlight"[% END %]>[% proposed_invoice.link %]</td>
           <td>[% HTML.escape(proposed_invoice.customer.name) %][% HTML.escape(proposed_invoice.vendor.name) %]</td>
+          <td>[% L.input_tag("sources." _ proposal.id _ "[]", "", size=20) %]</td>
+          <td>[% L.input_tag("memos." _ proposal.id _ "[]", "", size=20) %]</td>
         </tr>
         [% END %]
-        <tr><td style="height:10px" colspan="8"></td></tr>
+        <tr><td style="height:10px" colspan="10"></td></tr>
       </tbody>
     [% END %]
   [% END %]
 </table>
-[% L.submit_tag('action_save_proposals', LxERP.t8('Save proposals')) %]
+
+<p>
+ [% L.submit_tag('action_save_proposals', LxERP.t8('Save proposals')) %]
+ [% L.button_tag('kivi.BankTransaction.show_set_all_sources_memos_dialog("#list_automatic_form [name^=\\"sources.\\"]", "#list_automatic_form [name^=\\"memos.\\"]")', LxERP.t8('Set all source and memo fields')) %]
+</p>
 
 </form>