X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FTopQuickSearch%2FGLTransaction.pm;h=53d05ea420e35adae8d4260580b21a38ceff5fff;hb=abafb475d9742e3a6c28427477235c923b21eeef;hp=2b4facdec7b538502b169afd2af958d7051dc350;hpb=6c63020409f486043d63c3a324db96a4a162ff67;p=kivitendo-erp.git diff --git a/SL/Controller/TopQuickSearch/GLTransaction.pm b/SL/Controller/TopQuickSearch/GLTransaction.pm index 2b4facdec..53d05ea42 100644 --- a/SL/Controller/TopQuickSearch/GLTransaction.pm +++ b/SL/Controller/TopQuickSearch/GLTransaction.pm @@ -8,11 +8,12 @@ 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_transction' } +sub name { 'gl_transaction' } sub description_config { t8('GL search') } @@ -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 @@ -44,17 +45,13 @@ sub query_autocomplete { my $ars = SL::DB::Manager::Invoice->get_all( query => [ @arfilter ], limit => $limit, sort_by => 'transdate DESC', with_objects => [ 'customer' ]); my $aps = SL::DB::Manager::PurchaseInvoice->get_all(query => [ @apfilter ], limit => $limit, sort_by => 'transdate DESC', with_objects => [ 'vendor' ]); - # use the sum of all credit amounts as the "amount" of the gl transaction - foreach my $gl ( @$gls ) { - $gl->{'amount'} = sum map { $_->amount if $_->amount > 0 } @{$gl->transactions}; - }; - my $gldata = [ map( { { - transdate => DateTime->from_object(object => $_->transdate)->ymd(), - label => $_->abbreviation. ": " . $_->description . " " . $_->reference . " " . $::form->format_amount(\%::myconfig, $_->{'amount'},2). " (" . $_->transdate->to_lxoffice . ")" , + transdate => $_->transdate->ymd(''), # only used for sorting + label => $_->oneline_summary, + value => '', id => 'gl.pl?action=edit&id=' . $_->id, } } @@ -66,8 +63,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->ymd(''), + label => $_->oneline_summary, + value => "", id => ($_->invoice ? "is" : "ar" ) . '.pl?action=edit&id=' . $_->id, } } @@ -79,8 +77,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->ymd(''), + label => $_->oneline_summary, value => "", id => ($_->invoice ? "ir" : "ap" ) . '.pl?action=edit&id=' . $_->id, }