commit d53433f8c2b1e0e0a167f309e0e550cc05e60884
Author: Tamino Steinert <tamino.steinert@tamino.st>
Date:   Mon Mar 27 10:23:13 2023 +0200

    Rechnungsbericht VK und EK nach Zahlungsbedingung filtern können

diff --git a/SL/AP.pm b/SL/AP.pm
index b86f872a8..00957bfe5 100644
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -646,6 +646,10 @@ sub ap_transactions {
     $where .= " AND a.taxzone_id = ?";
     push(@values, $form->{taxzone_id});
   }
+  if ($form->{payment_id}) {
+    $where .= " AND a.payment_id = ?";
+    push(@values, $form->{payment_id});
+  }
   if ($form->{transaction_description}) {
     $where .= " AND a.transaction_description ILIKE ?";
     push(@values, like($form->{transaction_description}));
diff --git a/SL/AR.pm b/SL/AR.pm
index 56b51df06..941fe9613 100644
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -605,6 +605,10 @@ sub ar_transactions {
     $where .= " AND a.taxzone_id = ?";
     push(@values, $form->{taxzone_id});
   }
+  if ($form->{payment_id}) {
+    $where .= " AND a.payment_id = ?";
+    push(@values, $form->{payment_id});
+  }
   foreach my $column (qw(invnumber ordnumber cusordnumber notes transaction_description shipvia shippingpoint)) {
     if ($form->{$column}) {
       $where .= " AND a.$column ILIKE ?";
diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl
index d3f7e53e3..ac47b42f3 100644
--- a/bin/mozilla/ap.pl
+++ b/bin/mozilla/ap.pl
@@ -999,6 +999,7 @@ sub search {
 
   $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
   $::form->{ALL_TAXZONES}    = SL::DB::Manager::TaxZone   ->get_all_sorted;
+  $::form->{ALL_PAYMENT_TERMS} = SL::DB::Manager::PaymentTerm->get_all_sorted;
 
   # constants and subs for template
   $form->{vc_keys}   = sub { "$_[0]->{name}--$_[0]->{id}" };
@@ -1058,7 +1059,7 @@ sub ap_transactions {
   my @hidden_variables = map { "l_${_}" } @columns;
   push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id
                                            transdatefrom transdateto duedatefrom duedateto datepaidfrom datepaidto
-                                           parts_partnumber parts_description department_id taxzone_id);
+                                           parts_partnumber parts_description department_id taxzone_id payment_id);
 
   my $href = build_std_url('action=ap_transactions', grep { $form->{$_} } @hidden_variables);
 
@@ -1134,6 +1135,10 @@ sub ap_transactions {
   push @options, $locale->text('Date Paid') . " " . $locale->text('to')   . " " . $locale->date(\%myconfig, $form->{datepaidto},   1)     if ($form->{datepaidto});
   push @options, $locale->text('Open')                                                                   if ($form->{open});
   push @options, $locale->text('Closed')                                                                 if ($form->{closed});
+  if ($form->{payment_id}) {
+    my $payment_term = SL::DB::Manager::PaymentTerm->find_by( id => $form->{payment_id} );
+    push @options, $locale->text('Payment Term') . " : " . $payment_term->description;
+  }
 
   $report->set_options('top_info_text'        => join("\n", @options),
                        'output_format'        => 'HTML',
diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl
index 052283e2b..03615a6cf 100644
--- a/bin/mozilla/ar.pl
+++ b/bin/mozilla/ar.pl
@@ -978,6 +978,7 @@ sub search {
   $form->{ALL_DEPARTMENTS}    = SL::DB::Manager::Department->get_all_sorted;
   $form->{ALL_BUSINESS_TYPES} = SL::DB::Manager::Business  ->get_all_sorted;
   $form->{ALL_TAXZONES}       = SL::DB::Manager::TaxZone   ->get_all_sorted;
+  $form->{ALL_PAYMENT_TERMS}  = SL::DB::Manager::PaymentTerm->get_all_sorted;
 
   $form->{CT_CUSTOM_VARIABLES}                  = CVar->get_configs('module' => 'CT');
   ($form->{CT_CUSTOM_VARIABLES_FILTER_CODE},
@@ -1055,7 +1056,7 @@ sub ar_transactions {
   push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber cusordnumber transaction_description notes project_id
                                            transdatefrom transdateto duedatefrom duedateto datepaidfrom datepaidto
                                            employee_id salesman_id business_id parts_partnumber parts_description department_id show_marked_as_closed show_not_mailed
-                                           shippingpoint shipvia taxzone_id);
+                                           shippingpoint shipvia taxzone_id payment_id);
   push @hidden_variables, map { "cvar_$_->{name}" } @ct_searchable_custom_variables;
 
   $href =  $params{want_binary_pdf} ? '' : build_std_url('action=ar_transactions', grep { $form->{$_} } @hidden_variables);
@@ -1154,6 +1155,10 @@ sub ar_transactions {
   if ($form->{transaction_description}) {
     push @options, $locale->text('Transaction description') . " : $form->{transaction_description}";
   }
+  if ($form->{payment_id}) {
+    my $payment_term = SL::DB::Manager::PaymentTerm->find_by( id => $form->{payment_id} );
+    push @options, $locale->text('Payment Term') . " : " . $payment_term->description;
+  }
   if ($form->{parts_partnumber}) {
     push @options, $locale->text('Part Number') . " : $form->{parts_partnumber}";
   }
diff --git a/locale/de/all b/locale/de/all
index c77fad941..0e1feeba8 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -2679,6 +2679,7 @@ $ ./scripts/installation_check.pl',
   'Payment / Delivery Options'  => 'Zahlungs- und Lieferoptionen',
   'Payment Date'                => 'Leistungsdatum',
   'Payment Reminder'            => 'Zahlungserinnerung',
+  'Payment Term'                => 'Zahlungsbedingung',
   'Payment Terms'               => 'Zahlungsbedingungen',
   'Payment Terms missing in row ' => 'Zahlungsfrist fehlt in Zeile ',
   'Payment bookings disallowed. After the booking this record may be suggested with the amount of \'#1\' or otherwise has to be choosen manually. No automatic payment booking will be done to chart \'#2\'.' => 'Zahlungsbuchungen nicht erlaubt. Nach der Verbuchung kann dieser Beleg in der Vorschlagsliste mit dem Zahlungs-Betrag von \'#1\' erscheinen, ansonsten muss dieser manuell verknüpft werden. Es wird nicht automatisch eine Zahlungsbuchung auf das Konto \'#2\' durchgeführt.',
diff --git a/templates/design40_webpages/ap/search.html b/templates/design40_webpages/ap/search.html
index 13993e7fa..26fc6c8f1 100644
--- a/templates/design40_webpages/ap/search.html
+++ b/templates/design40_webpages/ap/search.html
@@ -78,6 +78,10 @@
       <th>[% 'Steuersatz' | $T8 %]</th>
       <td>[% L.select_tag('taxzone_id', ALL_TAXZONES, with_empty=1, title_key='description', class="wi-normal") %]</td>
     </tr>
+    <tr>
+      <th>[% 'Payment Term' | $T8 %]</th>
+      <td>[% L.select_tag('payment_id', ALL_PAYMENT_TERMS, with_empty=1, title_key='description', class="wi-normal") %]</td>
+    </tr>
   </tbody>
 </table>
 
diff --git a/templates/design40_webpages/ar/search.html b/templates/design40_webpages/ar/search.html
index 50c998b92..5179aa4a5 100644
--- a/templates/design40_webpages/ar/search.html
+++ b/templates/design40_webpages/ar/search.html
@@ -43,6 +43,10 @@
           <th>[% 'Transaction description' | $T8 %]</th>
           <td>[% L.input_tag("transaction_description", "") %]</td>
         </tr>
+        <tr>
+          <th>[% 'Payment Term' | $T8 %]</th>
+          <td>[% L.select_tag('payment_id', ALL_PAYMENT_TERMS, title_key = 'description', with_empty = 1) %]</td>
+        </tr>
         <tr>
           <th>[% 'Notes' | $T8 %]</th>
           <td>[% L.input_tag("notes", "") %]</td>
diff --git a/templates/webpages/ap/search.html b/templates/webpages/ap/search.html
index b7c558d80..e11cea756 100644
--- a/templates/webpages/ap/search.html
+++ b/templates/webpages/ap/search.html
@@ -34,6 +34,10 @@
       <th align="right">[% 'Steuersatz' | $T8 %]</th>
       <td>[% L.select_tag('taxzone_id', ALL_TAXZONES, with_empty=1, title_key='description', style=style) %]</td>
      </tr>
+     <tr>
+      <th align="right" nowrap>[% 'Payment Term' | $T8 %]</th>
+      <td>[% L.select_tag('payment_id', ALL_PAYMENT_TERMS, with_empty=1, title_key='description', style=style) %]</td>
+     </tr>
      <tr>
       <th align="right" nowrap>[% 'Transaction description' | $T8 %]</th>
       <td>[% L.input_tag("transaction_description", "", style=style) %]</td>
diff --git a/templates/webpages/ar/search.html b/templates/webpages/ar/search.html
index b3c55894e..e9b9df2c4 100644
--- a/templates/webpages/ar/search.html
+++ b/templates/webpages/ar/search.html
@@ -65,6 +65,10 @@
       <th align="right">[% 'Ship via' | $T8 %]</th>
       <td>[% L.input_tag("shipvia", "", style=style) %]</td>
      </tr>
+     <tr>
+      <th align="right" nowrap>[% 'Payment Term' | $T8 %]</th>
+      <td>[% L.select_tag('payment_id', ALL_PAYMENT_TERMS, with_empty=1, title_key="description", style=style) %]</td>
+     </tr>
      <tr>
       <th align="right">[% 'Project Number' | $T8 %]</th>
       <td>[% P.project.picker("project_id", project_id, active="both", valid="both", style=style) %]</td>
