Verwendete Lizenz eindeutig bennennen.
[kivitendo-erp.git] / SL / USTVA.pm
index 3551efa..505efb4 100644 (file)
@@ -607,14 +607,12 @@ sub ustva {
 
   foreach $item (@categories_cent) {
     $form->{$item} =
-      $form->format_amount($myconfig, $form->round_amount($form->{$item}, 2),
-                           2, '0');
+      $form->format_amount($myconfig, $form->{$item}, '2', '0');
   }
 
   foreach $item (@categories_euro) {
     $form->{$item} =
-      $form->format_amount($myconfig, $form->round_amount($form->{$item}, 0),
-                           0, '0');
+      $form->format_amount($myconfig, $form->{$item}, '0', '0');
   }
 
   $dbh->disconnect;
@@ -637,6 +635,7 @@ sub get_accounts_ustva {
   my $glwhere  = "";
   my $subwhere = "";
   my $ARwhere  = "";
+  my $APwhere  = '';
   my $arwhere  = "";
   my $item;
 
@@ -645,6 +644,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 +653,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 +709,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
    (