Wenn UTF-8 als Datenbankcharset verwendet wird, so muss der ReportGenerator die an...
[kivitendo-erp.git] / SL / USTVA.pm
index 658e2c7..b10fea6 100644 (file)
@@ -386,11 +386,7 @@ sub info {
 
   } else {
 
-    if ($form->{error_function}) {
-      &{ $form->{error_function} }($msg);
-    } else {
-      die "Hinweis: $msg\n";
-    }
+    die "Hinweis: $msg\n";
   }
 
   $main::lxdebug->leave_sub();
@@ -800,6 +796,21 @@ sub get_accounts_ustva {
     $ARwhere  .= " AND acc.transdate <= '$todate'";
   }
 
+  my $acc_trans_where = '1=1';
+  if ($fromdate || $todate) {
+    $acc_trans_where = "ac.trans_id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE ";
+
+    if ($fromdate) {
+      $acc_trans_where .= "transdate >= '$fromdate'";
+    }
+    if ($todate) {
+      $acc_trans_where .= " AND " if ($fromdate);
+      $acc_trans_where .= "transdate <= '$todate'";
+    }
+
+    $acc_trans_where .= ")";
+  }
+
   ############################################
   # Method eq 'cash' = IST Versteuerung
   ############################################
@@ -847,9 +858,7 @@ sub get_accounts_ustva {
          )
        )
        WHERE 
-       1=1 
-       -- Here no where, please. All Transactions ever should be
-       -- testet if they are paied in the USTVA report period.
+       $acc_trans_where
        GROUP BY tk.pos_ustva
     |;
    
@@ -882,7 +891,7 @@ sub get_accounts_ustva {
    
   } else {
   
-    $self->error("Unknown tax method: $form->{method}")
+    $form->error("Unknown tax method: $form->{method}")
 
   }