X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=80c5fda6e45cb23a721db8770b9ed35261ddb431;hb=8eca5e84a3f8ebecfb93b593e4540edfa755dcc8;hp=f538bc3590f191957ea286c2d402914c9145cbe8;hpb=e293009f4e1d70e547a479e956fd1733c24b1441;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index f538bc359..80c5fda6e 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; @@ -158,11 +159,11 @@ sub post_transaction { if ($amount != 0) { $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, - source, memo, project_id, taxkey, ob_transaction, cb_transaction) + source, memo, project_id, taxkey, ob_transaction, cb_transaction, tax_id) VALUES (?, (SELECT id FROM chart WHERE accno = ?), - ?, ?, ?, ?, ?, ?, ?, ?)|; + ?, ?, ?, ?, ?, ?, ?, ?, ?)|; @values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{transdate}), - $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f'); + $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{"tax_id_$i"})); do_query($form, $dbh, $query, @values); } @@ -170,12 +171,12 @@ sub post_transaction { # add taxentry $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, - source, memo, project_id, taxkey) + source, memo, project_id, taxkey, tax_id) VALUES (?, (SELECT chart_id FROM tax WHERE id = ?), - ?, ?, ?, ?, ?, ?)|; + ?, ?, ?, ?, ?, ?, ?)|; @values = (conv_i($form->{id}), conv_i($form->{"tax_id_$i"}), $tax, conv_date($form->{transdate}), $form->{"source_$i"}, - $form->{"memo_$i"}, $project_id, $taxkey); + $form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"})); do_query($form, $dbh, $query, @values); } } @@ -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 ($::instance_conf->get_datev_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;