X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAR.pm;h=002041ecf8fb47419044913a2c7e2ad9b11f7d06;hb=481e3f934e08d79a35597e01e0c02bb9931ef4a7;hp=e1501b7f7a68ebfef2a2faac2203af1c9b3fe652;hpb=c3898bd886b47a36d64336342a95c584a12ad847;p=kivitendo-erp.git diff --git a/SL/AR.pm b/SL/AR.pm index e1501b7f7..002041ecf 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -35,6 +35,7 @@ package AR; use Data::Dumper; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::IO; use SL::MoreCommon; @@ -273,6 +274,27 @@ sub post_transaction { IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh); + # safety check datev export + if ($::lx_office_conf{datev_check}{check_on_ar_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; + } + } + my $rc = 1; if (!$provided_dbh) { $rc = $dbh->commit();