X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=cdd9d406ffcd6380852677cae3f8096e42f6b8aa;hb=297ec9f0dcfb45a3d695506c824f13fd72f7d312;hp=feac77c50fabe9dd88dd61bb1a19049f541ee5c7;hpb=4000272e5ea3a605f3625934f07033472832de49;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index feac77c50..cdd9d406f 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -39,6 +39,7 @@ package GL; use Data::Dumper; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use strict; @@ -184,6 +185,27 @@ sub post_transaction { do_query($form, $dbh, qq|UPDATE gl SET storno = 't' WHERE id = ?|, conv_i($form->{storno_id})); } + # safety check datev export + if ($::lx_office_conf{datev_check}{check_on_gl_transaction}) { + my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; + $transdate ||= DateTime->today; + + my $datev = SL::DATEV->new( + exporttype => DATEV_ET_BUCHUNGEN, + format => DATEV_FORMAT_KNE, + dbh => $dbh, + from => $transdate, + to => $transdate, + ); + + $datev->export; + + if ($datev->errors) { + $dbh->rollback; + die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + } + } + # commit and redirect my $rc = $dbh->commit; $dbh->disconnect; @@ -263,8 +285,6 @@ sub all_transactions { if ($form->{employee} =~ /--/) { ($form->{employee_id},$form->{employee_name}) = split(/--/,$form->{employee}); - $query .= " AND o.employee_id = ?"; - push @values, conv_i($form->{employee_id}); #if ($form->{employee_id}) { $glwhere .= " AND g.employee_id = ? "; $arwhere .= " AND a.employee_id = ? "; @@ -370,7 +390,9 @@ sub all_transactions { CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee $project_columns $columns_for_sorting{gl} - FROM gl g, acc_trans ac $project_join, chart c + FROM gl g + LEFT JOIN employee e ON (g.employee_id = e.id), + acc_trans ac $project_join, chart c LEFT JOIN tax t ON (t.chart_id = c.id) WHERE $glwhere AND (ac.chart_id = c.id) @@ -384,7 +406,9 @@ sub all_transactions { CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee $project_columns $columns_for_sorting{arap} - FROM ar a, acc_trans ac $project_join, customer ct, chart c + FROM ar a + LEFT JOIN employee e ON (a.employee_id = e.id), + acc_trans ac $project_join, customer ct, chart c LEFT JOIN tax t ON (t.chart_id=c.id) WHERE $arwhere AND (ac.chart_id = c.id) @@ -399,7 +423,9 @@ sub all_transactions { CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee $project_columns $columns_for_sorting{arap} - FROM ap a, acc_trans ac $project_join, vendor ct, chart c + FROM ap a + LEFT JOIN employee e ON (a.employee_id = e.id), + acc_trans ac $project_join, vendor ct, chart c LEFT JOIN tax t ON (t.chart_id=c.id) WHERE $apwhere AND (ac.chart_id = c.id) @@ -716,7 +742,7 @@ sub storno { $storno_row->{storno} = 't'; $storno_row->{reference} = 'Storno-' . $storno_row->{reference}; - delete @$storno_row{qw(itime mtime)}; + delete @$storno_row{qw(itime mtime gldate)}; $query = sprintf 'INSERT INTO gl (%s) VALUES (%s)', join(', ', keys %$storno_row), join(', ', map '?', values %$storno_row); do_query($form, $dbh, $query, (values %$storno_row)); @@ -729,7 +755,7 @@ sub storno { my $rowref = selectall_hashref_query($form, $dbh, $query, $id); for my $row (@$rowref) { - delete @$row{qw(itime mtime acc_trans_id)}; + delete @$row{qw(itime mtime acc_trans_id gldate)}; $query = sprintf 'INSERT INTO acc_trans (%s) VALUES (%s)', join(', ', keys %$row), join(', ', map '?', values %$row); $row->{trans_id} = $new_id; $row->{amount} *= -1;