Solved Bug 365: Falsche UStVA bei negativem Vorsteuer-Betrag (Teil 2)
authorUdo Spallek <info@wissensvermittlung.com>
Tue, 20 Jun 2006 11:06:10 +0000 (11:06 +0000)
committerUdo Spallek <info@wissensvermittlung.com>
Tue, 20 Jun 2006 11:06:10 +0000 (11:06 +0000)
SL/USTVA.pm

index f1bd2a0..3cb7ff8 100644 (file)
@@ -724,14 +724,17 @@ sub get_accounts_ustva {
 
         UNION
 
-                SELECT sum(ac.amount) AS amount,
+                SELECT sum(
+                  CASE WHEN c.link LIKE '%AR%' THEN ac.amount * -1
+                       WHEN c.link LIKE '%AP%' THEN ac.amount * 1
+                   END
+                ) AS amount,
                 c.$category
                 FROM acc_trans ac
                 JOIN chart c ON (c.id = ac.chart_id)
                 JOIN gl a ON (a.id = ac.trans_id)
                 $dpt_join
                 WHERE $where
-                $glwhere
                 $dpt_from
                 AND NOT (c.link = 'AR' OR c.link = 'AP')
                 $project