]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Filterung nach Kundennummer in Zahlungseingang
authorNiclas Zimmermann <niclas@lx-office-hosting.de>
Tue, 11 Sep 2012 14:39:10 +0000 (16:39 +0200)
committerNiclas Zimmermann <niclas@lx-office-hosting.de>
Thu, 13 Sep 2012 12:48:42 +0000 (14:48 +0200)
Im Zahlungsverkehr-Zahlungseingang ist jetzt eine neue Filteroption
Kundennummer vorhanden. Bei Eingabe der Kundennummer wird die
Filterung für das Dropdown ausgeschaltet. Es funktioniert dann nur
noch die Filterung von Rechnungsnummer und Kundennummer.

SL/AR.pm
bin/mozilla/cp.pl
templates/webpages/cp/form_header.html

index 002041ecf8fb47419044913a2c7e2ad9b11f7d06..8c72d3cf99c518c96d0527808d5a0fb755a6007c 100644 (file)
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -472,6 +472,10 @@ sub ar_transactions {
     qq|LEFT JOIN department d ON (d.id = a.department_id)|;
 
   my $where = "1 = 1";
+  if ($form->{customernumber}) {
+    $where .= " AND c.customernumber = ?";
+    push(@values, $form->{customernumber});
+  }
   if ($form->{customer_id}) {
     $where .= " AND a.customer_id = ?";
     push(@values, $form->{customer_id});
index 1f061ad8e6c44bad3a660e10471c9882fa0176bc..885c88e622e481dcf2bf9fc53d054b41aa896a59 100644 (file)
@@ -36,6 +36,7 @@ use SL::IS;
 use SL::IR;
 use SL::AR;
 use SL::AP;
+use Data::Dumper;
 use strict;
 #use warnings;
 
@@ -71,13 +72,14 @@ sub payment {
   # für bugfix 1771 (doppelte Leerzeichen werden nicht 'gepostet')
   $form->{"select$form->{vc}"} = "";
 
+  $form->{selectcustomer} .= "<option value=\"\"></option>\n" if $form->{vc} eq "customer";
+
   if ($form->{"all_$form->{vc}"}) {
     # s.o. jb 12.10.2010
     $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
     map { $form->{"select$form->{vc}"} .= "<option value=\"$_->{name}--$_->{id}\">$_->{name}--$_->{id}</option>\n" }
       @{ $form->{"all_$form->{vc}"} };
   }
-
   CP->paymentaccounts(\%myconfig, \%$form);
 
   # Standard Konto für Umlaufvermögen
@@ -135,6 +137,13 @@ sub form_header {
   if ($form->{ $form->{vc} } eq "") {
     map { $form->{"addr$_"} = "" } (1 .. 4);
   }
+
+  # sometimes it happens that values in customer arrive without the signs '--'
+  # but in order to select the right option field we need values with '--'
+  if ($form->{vc} eq "customer"){
+    my ($customername) = split /--/, $form->{ $form->{vc} };
+    $form->{ $form->{vc} } = $customername . "--" . $form->{customer_id};
+  }
   # bugfix 1771
   # geändert von <option>asdf--2929
   # nach:
@@ -252,15 +261,30 @@ sub update {
     }
   }
 
+  # search by customernumber
+  # the customernumber has to be correct otherwise nothing is found
+  if ($form->{vc} eq 'customer' and $form->{customernumber} and $form->{ARAP} eq 'AR') {
+    $form->{open} ='Y'; # only open invoices
+    # ar_transactions automatically searches by $form->{customer_id} or else
+    # $form->{customer} if available, and these variables will always be set
+    # so we have to empty these values first
+    $form->{customer_id} = '';
+    $form->{customer} = '';
+    AR->ar_transactions(\%myconfig, \%$form);
+
+    # Here we just take the first returned value even if the custumernumber
+    # may not be unique
+    $form->{customer} = $form->{AR}[0]{name};
+    $form->{customer_id} = $form->{AR}[0]{customer_id};
+  }
+
   # search by invoicenumber, 
   if ($form->{invnumber}) { 
-    $form->{open} ='Y'; # nur die offenen rechnungen
+    $form->{open} ='Y'; # only open invoices
     if ($form->{ARAP} eq 'AR'){
-
       # ar_transactions automatically searches by $form->{customer_id} or else
       # $form->{customer} if available, and these variables will always be set
-      # when we have a dropdown field rather than an input field, so we have to
-      # empty these values first
+      # so we have to empty these values first
       $form->{customer_id} = '';
       $form->{customer} = '';
       AR->ar_transactions(\%myconfig, \%$form);
@@ -296,7 +320,7 @@ sub update {
   }
 
   # determine customer/vendor
-  if ( $form->{customer_id} and $form->{invnumber} ) {
+  if ( $form->{customer_id} and ($form->{invnumber} or $form->{customernumber}) ) {
     # we already know the exact customer_id, so fill $form with customer data
     IS->get_customer(\%myconfig, \%$form);
     $updated = 1;
index bc02918c577fc8e5677cd05dee9570fbd7b2d063..c513eca9b9f348bfc3716bcb3fbf7776e8e3ffdb 100644 (file)
@@ -25,7 +25,7 @@
         <tr>
           <th align=right>[% is_customer ? LxERP.t8('Customer') : LxERP.t8('Vendor') %]</th>
           <td>[% vccontent %]</td>
-          [% IF vc == 'customer' %]
+         [% IF vc == 'customer' %]
            [% L.hidden_tag('selectcustomer', selectcustomer) %]
            [% L.hidden_tag('customer_id', customer_id) %]
            [% L.hidden_tag('oldcustomer', oldcustomer) %]
            [% L.hidden_tag('oldvendor', oldvendor) %]
           [% END %]
         </tr>
+        [% IF vc == 'customer' %]
+        <tr>
+          <th align=right>[% 'Customer Number' | $T8 %]</th>
+          <td><input name="customernumber" size="35"</td>
+        </tr>
+        [% END %]
         <tr>
           <th align=right>[% 'Invoice Number' | $T8 %]</th>
           <td><input name="invnumber" size="35"</td>