]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/TopQuickSearch/GLTransaction.pm
FiBu Schnellsuche repariert
[mfinanz.git] / SL / Controller / TopQuickSearch / GLTransaction.pm
index 77854ff4cca9cda1443ee11310f74cdcb2a4a795..f1017397587cbe7f5c2e467b5d719a5b980418b8 100644 (file)
@@ -8,9 +8,10 @@ use SL::DB::Invoice;
 use SL::DB::PurchaseInvoice;
 use SL::DB::AccTransaction;
 use SL::Locale::String qw(t8);
+use SL::DBUtils qw(like);
 use List::Util qw(sum);
 
-sub auth { 'general_ledger' }
+sub auth { 'general_ledger|gl_transactions|ap_transactions|ar_transactions' }
 
 sub name { 'gl_transaction' }
 
@@ -24,11 +25,11 @@ sub query_autocomplete {
   my $limit = $::form->{limit} || 40; # max number of results per type (AR/AP/GL)
   my $term  = $::form->{term}  || '';
 
-  my $descriptionquery = { ilike => '%' . $term . '%' };
-  my $referencequery   = { ilike => '%' . $term . '%' };
-  my $apinvnumberquery = { ilike => '%' . $term . '%' };
-  my $namequery        = { ilike => '%' . $term . '%' };
-  my $arinvnumberquery = { ilike => '%' . $term       };
+  my $descriptionquery = { ilike => like($term) };
+  my $referencequery   = { ilike => like($term) };
+  my $apinvnumberquery = { ilike => like($term) };
+  my $namequery        = { ilike => like($term) };
+  my $arinvnumberquery = { ilike => '%' . SL::Util::trim($term) };
   # ar match is more restrictive. Left fuzzy beginning so it also matches "Storno zu $INVNUMBER"
   # and numbers like 000123 if you only enter 123.
   # When used in quicksearch short numbers like 1 or 11 won't match because of the
@@ -53,8 +54,9 @@ sub query_autocomplete {
     map(
       {
         {
-           transdate => DateTime->from_object(object => $_->transdate)->ymd(),
-           label     => $_->abbreviation. ": " . $_->description . " " . $_->reference . " " . $::form->format_amount(\%::myconfig, $_->{'amount'},2). " (" . $_->transdate->to_lxoffice . ")" ,
+           transdate => $_->transdate->to_kivitendo,
+           label     => $_->oneline_summary,
+           value     => '',
            id        => 'gl.pl?action=edit&id=' . $_->id,
         }
       }
@@ -66,8 +68,9 @@ sub query_autocomplete {
     map(
       {
         {
-           transdate => DateTime->from_object(object => $_->transdate)->ymd(),
-           label     => $_->abbreviation . ": " . $_->invnumber . "   " . $_->customer->name . " " . $::form->format_amount(\%::myconfig, $_->amount,2)  . " (" . $_->transdate->to_lxoffice . ")" ,
+           transdate => $_->transdate->to_kivitendo,
+           label     => $_->oneline_summary,
+           value     => "",
            id        => ($_->invoice ? "is" : "ar" ) . '.pl?action=edit&id=' . $_->id,
         }
       }
@@ -79,8 +82,8 @@ sub query_autocomplete {
     map(
       {
         {
-           transdate => DateTime->from_object(object => $_->transdate)->ymd(),
-           label     => $_->abbreviation . ": " . $_->invnumber . " " . $_->vendor->name . " " . $::form->format_amount(\%::myconfig, $_->amount,2)  . " (" . $_->transdate->to_lxoffice . ")" ,
+           transdate => $_->transdate->to_kivitendo,
+           label     => $_->oneline_summary,
            value     => "",
            id        => ($_->invoice ? "ir" : "ap" ) . '.pl?action=edit&id=' . $_->id,
         }