X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/5b981bb6a5c48dbec2297af61893c0add678669b..eeb5375ee7727c956cc357cc8f90b19d1bfe80b9:/SL/Controller/TopQuickSearch/GLTransaction.pm diff --git a/SL/Controller/TopQuickSearch/GLTransaction.pm b/SL/Controller/TopQuickSearch/GLTransaction.pm index dab0a6284..c834ba4c3 100644 --- a/SL/Controller/TopQuickSearch/GLTransaction.pm +++ b/SL/Controller/TopQuickSearch/GLTransaction.pm @@ -25,39 +25,33 @@ sub query_autocomplete { my $limit = $::form->{limit} || 40; # max number of results per type (AR/AP/GL) my $term = $::form->{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) }; + my $descriptionquery = { ilike => like($term) }; + my $referencequery = { ilike => like($term) }; + my $apinvnumberquery = { ilike => like($term) }; + my $namequery = { ilike => like($term) }; + my $arinvnumber_left_query = { ilike => '%' . SL::Util::trim($term) }; + my $arinvnumber_right_query = { 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 - # ajax autocomplete minlimit of 3 characters + # and numbers like 000123 if you only enter 123. Right beginning searches from the begin. my (@glfilter, @arfilter, @apfilter); push( @glfilter, (or => [ description => $descriptionquery, reference => $referencequery ] ) ); - push( @arfilter, (or => [ invnumber => $arinvnumberquery, name => $namequery ] ) ); + push( @arfilter, (or => [ invnumber => $arinvnumber_left_query, invnumber => $arinvnumber_right_query, name => $namequery ] ) ); push( @apfilter, (or => [ invnumber => $apinvnumberquery, name => $namequery ] ) ); my $gls = SL::DB::Manager::GLTransaction->get_all( query => [ @glfilter ], limit => $limit, sort_by => 'transdate DESC'); 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 => $_->transdate->to_kivitendo, + transdate => $_->transdate->ymd(''), # only used for sorting label => $_->oneline_summary, value => '', - url => 'gl.pl?action=edit&id=' . $_->id, + id => 'gl.pl?action=edit&id=' . $_->id, } } @{$gls} @@ -68,10 +62,10 @@ sub query_autocomplete { map( { { - transdate => $_->transdate->to_kivitendo, + transdate => $_->transdate->ymd(''), label => $_->oneline_summary, value => "", - url => ($_->invoice ? "is" : "ar" ) . '.pl?action=edit&id=' . $_->id, + id => ($_->invoice ? "is" : "ar" ) . '.pl?action=edit&id=' . $_->id, } } @{$ars} @@ -82,7 +76,7 @@ sub query_autocomplete { map( { { - transdate => $_->transdate->to_kivitendo, + transdate => $_->transdate->ymd(''), label => $_->oneline_summary, value => "", id => ($_->invoice ? "ir" : "ap" ) . '.pl?action=edit&id=' . $_->id,