X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=60b54e22dc7d4846b12d7746c0c71929eda1b337;hb=68ccd089c525fd41d00266fe493cd52a9dbb6513;hp=016601e01c72e3a1ca346729f59bf73ab7ed6a6d;hpb=1b15807093421ca00493a447048b960f2f512152;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index 016601e01..60b54e22d 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -41,6 +41,7 @@ package GL; use Data::Dumper; use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; +use SL::Util qw(trim); use strict; @@ -196,8 +197,6 @@ sub post_transaction { exporttype => DATEV_ET_BUCHUNGEN, format => DATEV_FORMAT_KNE, dbh => $dbh, - from => $transdate, - to => $transdate, trans_id => $form->{id}, ); @@ -232,9 +231,9 @@ sub all_transactions { $glwhere .= qq| AND g.reference ILIKE ?|; $arwhere .= qq| AND a.invnumber ILIKE ?|; $apwhere .= qq| AND a.invnumber ILIKE ?|; - push(@glvalues, '%' . $form->{reference} . '%'); - push(@arvalues, '%' . $form->{reference} . '%'); - push(@apvalues, '%' . $form->{reference} . '%'); + push(@glvalues, like($form->{reference})); + push(@arvalues, like($form->{reference})); + push(@apvalues, like($form->{reference})); } if ($form->{department}) { @@ -251,39 +250,39 @@ sub all_transactions { $glwhere .= " AND ac.trans_id IN (SELECT trans_id from acc_trans WHERE source ILIKE ?)"; $arwhere .= " AND ac.trans_id IN (SELECT trans_id from acc_trans WHERE source ILIKE ?)"; $apwhere .= " AND ac.trans_id IN (SELECT trans_id from acc_trans WHERE source ILIKE ?)"; - push(@glvalues, '%' . $form->{source} . '%'); - push(@arvalues, '%' . $form->{source} . '%'); - push(@apvalues, '%' . $form->{source} . '%'); + push(@glvalues, like($form->{source})); + push(@arvalues, like($form->{source})); + push(@apvalues, like($form->{source})); } # default Datumseinschränkung falls nicht oder falsch übergeben (sollte nie passieren) $form->{datesort} = 'transdate' unless $form->{datesort} =~ /^(transdate|gldate)$/; - if ($form->{datefrom}) { + if (trim($form->{datefrom})) { $glwhere .= " AND ac.$form->{datesort} >= ?"; $arwhere .= " AND ac.$form->{datesort} >= ?"; $apwhere .= " AND ac.$form->{datesort} >= ?"; - push(@glvalues, $form->{datefrom}); - push(@arvalues, $form->{datefrom}); - push(@apvalues, $form->{datefrom}); + push(@glvalues, trim($form->{datefrom})); + push(@arvalues, trim($form->{datefrom})); + push(@apvalues, trim($form->{datefrom})); } - if ($form->{dateto}) { + if (trim($form->{dateto})) { $glwhere .= " AND ac.$form->{datesort} <= ?"; $arwhere .= " AND ac.$form->{datesort} <= ?"; $apwhere .= " AND ac.$form->{datesort} <= ?"; - push(@glvalues, $form->{dateto}); - push(@arvalues, $form->{dateto}); - push(@apvalues, $form->{dateto}); + push(@glvalues, trim($form->{dateto})); + push(@arvalues, trim($form->{dateto})); + push(@apvalues, trim($form->{dateto})); } - if ($form->{description}) { + if (trim($form->{description})) { $glwhere .= " AND g.description ILIKE ?"; $arwhere .= " AND ct.name ILIKE ?"; $apwhere .= " AND ct.name ILIKE ?"; - push(@glvalues, '%' . $form->{description} . '%'); - push(@arvalues, '%' . $form->{description} . '%'); - push(@apvalues, '%' . $form->{description} . '%'); + push(@glvalues, like($form->{description})); + push(@arvalues, like($form->{description})); + push(@apvalues, like($form->{description})); } if ($form->{employee_id}) { @@ -295,13 +294,13 @@ sub all_transactions { push(@apvalues, conv_i($form->{employee_id})); } - if ($form->{notes}) { + if (trim($form->{notes})) { $glwhere .= " AND g.notes ILIKE ?"; $arwhere .= " AND a.notes ILIKE ?"; $apwhere .= " AND a.notes ILIKE ?"; - push(@glvalues, '%' . $form->{notes} . '%'); - push(@arvalues, '%' . $form->{notes} . '%'); - push(@apvalues, '%' . $form->{notes} . '%'); + push(@glvalues, like($form->{notes})); + push(@arvalues, like($form->{notes})); + push(@apvalues, like($form->{notes})); } if ($form->{accno}) { @@ -724,10 +723,14 @@ sub storno { $query = qq|SELECT * FROM gl WHERE id = ?|; $storno_row = selectfirst_hashref_query($form, $dbh, $query, $id); - $storno_row->{id} = $new_id; - $storno_row->{storno_id} = $id; - $storno_row->{storno} = 't'; - $storno_row->{reference} = 'Storno-' . $storno_row->{reference}; + $storno_row->{id} = $new_id; + $storno_row->{storno_id} = $id; + $storno_row->{storno} = 't'; + $storno_row->{reference} = 'Storno-' . $storno_row->{reference}; + + $query = qq|SELECT id FROM employee WHERE login = ?|; + my ($employee_id) = selectrow_query($form, $dbh, $query, $::myconfig{login}); + $storno_row->{employee_id} = $employee_id; delete @$storno_row{qw(itime mtime gldate)};