X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAP.pm;h=f03fb63e892b461085088eceb0363dab873c0e7d;hb=c623caef58787a808fd292e7a8f1f074067e5711;hp=8d700640e532b86b80506c23286ff1af7c1e1383;hpb=cf9865dc7faad6b1ea68e2c5db8b8b44d316fd26;p=kivitendo-erp.git diff --git a/SL/AP.pm b/SL/AP.pm index 8d700640e..f03fb63e8 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -40,6 +40,7 @@ use SL::DBUtils; use SL::IO; use SL::MoreCommon; use SL::DB::Default; +use SL::DB::Draft; use SL::Util qw(trim); use SL::DB; use Data::Dumper; @@ -361,19 +362,17 @@ sub _post_transaction { IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh); + if ($form->{draft_id}) { + SL::DB::Manager::Draft->delete_all(where => [ id => delete($form->{draft_id}) ]); + } + # safety check datev export if ($::instance_conf->get_datev_check_on_ap_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, trans_id => $form->{id}, ); - - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; @@ -644,7 +643,7 @@ sub _post_payment { # Get the AP accno. $query = - qq|SELECT c.accno + qq|SELECT c.id FROM acc_trans at LEFT JOIN chart c ON (at.chart_id = c.id) WHERE (trans_id = ?) @@ -652,7 +651,7 @@ sub _post_payment { ORDER BY at.acc_trans_id LIMIT 1|; - ($form->{APselected}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id})); + ($form->{AP_chart_id}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id})); # Post the new payments. $self->post_transaction($myconfig, $form, $dbh, 1);