X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=cdd9d406ffcd6380852677cae3f8096e42f6b8aa;hb=c7ad671d22e558e157797af7d787c8df499be1b4;hp=e1cb7bc5bb7e8070f8bee4e100d8bcfee8775978;hpb=3286128e8253b38ae4e996b327beaf243661a5ef;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index e1cb7bc5b..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; @@ -720,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)); @@ -733,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;