X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/12c24c2a11926588e03a05bb91cd7c152b0c983d..6454c25f66fd37513e8f8e94167c019e372c3ef7:/SL/IS.pm diff --git a/SL/IS.pm b/SL/IS.pm index 0c3b4c82c..32b517121 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -40,6 +40,7 @@ use SL::AM; use SL::ARAP; use SL::CVar; use SL::Common; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::DO; use SL::GenericTranslations; @@ -1080,6 +1081,27 @@ sub post_invoice { 'arap_id' => $form->{id}, 'table' => 'ar',); + # safety check datev export + if ($::lx_office_conf{datev_check}{check_on_sales_invoice}) { + my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : 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; $dbh->commit if !$provided_dbh; @@ -2091,7 +2113,7 @@ sub get_pricegroups_for_parts { $pkr->{price_ufmt} = $pkr->{price}; $pkr->{price} = $form->format_amount($myconfig, $pkr->{price}, 5); - if ($selectedpricegroup_id eq undef) { + if (!defined $selectedpricegroup_id) { # new entries in article list, either old invoice was loaded (edit) or a new article was added # Case A: open old invoice, no pricegroup selected # Case B: add new article to invoice, no pricegroup selected