Wiedervorlagenbericht: Filter »erstellt für« gefixt
[kivitendo-erp.git] / SL / AR.pm
index 079e9e8..56f2da9 100644 (file)
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -38,6 +38,7 @@ package AR;
 use Data::Dumper;
 use SL::DATEV qw(:CONSTANTS);
 use SL::DBUtils;
+use SL::DB::Draft;
 use SL::IO;
 use SL::MoreCommon;
 use SL::DB::Default;
@@ -305,19 +306,18 @@ sub _post_transaction {
 
   IO->set_datepaid(table => 'ar', 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_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,
       trans_id   => $form->{id},
     );
 
-    $datev->export;
+    $datev->generate_datev_data;
 
     if ($datev->errors) {
       die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors;
@@ -499,14 +499,7 @@ sub ar_transactions {
     $where .= " AND NOT invoice = 'f' ";  # remove ar transactions from Sales -> Reports -> Invoices
   };
 
-  if ($form->{customernumber}) {
-    $where .= " AND c.customernumber = ?";
-    push(@values, trim($form->{customernumber}));
-  }
-  if ($form->{customer_id}) {
-    $where .= " AND a.customer_id = ?";
-    push(@values, $form->{customer_id});
-  } elsif ($form->{customer}) {
+  if ($form->{customer}) {
     $where .= " AND c.name ILIKE ?";
     push(@values, like($form->{customer}));
   }