Alu-Funktion aus Kundenprojekt entfernt.
[kivitendo-erp.git] / SL / USTVA.pm
index 3551efa..0f23783 100644 (file)
@@ -637,6 +637,7 @@ sub get_accounts_ustva {
   my $glwhere  = "";
   my $subwhere = "";
   my $ARwhere  = "";
+  my $APwhere  = '';
   my $arwhere  = "";
   my $item;
 
@@ -645,6 +646,7 @@ sub get_accounts_ustva {
       $subwhere .= " AND transdate >= '$fromdate'";
       $glwhere = " AND ac.transdate >= '$fromdate'";
       $ARwhere .= " AND acc.transdate >= '$fromdate'";
+      $APwhere .= " AND AP.transdate >= '$fromdate'"; 
     }
     $where .= " AND ac.transdate >= '$fromdate'";
   }
@@ -653,6 +655,7 @@ sub get_accounts_ustva {
     $where    .= " AND ac.transdate <= '$todate'";
     $ARwhere  .= " AND acc.transdate <= '$todate'";
     $subwhere .= " AND transdate <= '$todate'";
+    $APwhere  .= " AND AP.transdate <= '$todate'";     
   }
 
   if ($department_id) {
@@ -708,18 +711,19 @@ sub get_accounts_ustva {
 
  UNION -- alle Ausgaben AP erfassen
 
-   SELECT sum(ac.amount) AS amount, c.$category
-   FROM acc_trans ac
-   JOIN chart c ON (c.id = ac.chart_id)
-   $dpt_join 
-   WHERE 
-   $where
-   AND c.link LIKE '%AP_amount%'
-   $dpt_where
-   $project
-   GROUP BY c.$category
-
-   UNION -- alle Ausgaben und Einnahmen direkter gl Buchungen erfassen
+     SELECT
+     sum(ac.amount) AS amount, pos_ustva
+     FROM acc_trans ac
+     JOIN AP ON (AP.id = ac.trans_id )
+     JOIN chart c ON (c.id = ac.chart_id AND pos_ustva NOT LIKE '')
+     WHERE
+       1=1
+       $APwhere
+       $dpt_where
+       $project
+     GROUP BY pos_ustva
+
+ UNION -- alle Ausgaben und Einnahmen direkter gl Buchungen erfassen
 
    SELECT sum
    (