Merged changes from stable branch up to 2.3.12
[fa-stable.git] / reporting / rep709.php
index c3cd8e193a4f46ad550e37a477392fb4c8e552c8..bd518b594f52adc7ed235709541a3cea217f1a6b 100644 (file)
@@ -122,7 +122,7 @@ function print_tax_report()
 
        while ($trans=db_fetch($transactions))
        {
-               if (in_array($trans['trans_type'], array(ST_CUSTCREDIT,ST_SUPPINVOICE))) {
+               if (in_array($trans['trans_type'], array(ST_CUSTCREDIT,ST_SUPPINVOICE,ST_JOURNAL))) {
                        $trans['net_amount'] *= -1;
                        $trans['amount'] *= -1;
                }
@@ -152,8 +152,12 @@ function print_tax_report()
                        }
                }
                if ($trans['trans_type']==ST_JOURNAL && $trans['amount']<0) {
-                       $taxes[$trans['tax_type_id']]['taxout'] -= $trans['amount'];
-                       $taxes[$trans['tax_type_id']]['out'] -= $trans['net_amount'];
+                       $taxes[$trans['tax_type_id']]['taxin'] += $trans['amount'];
+                       $taxes[$trans['tax_type_id']]['in'] += $trans['net_amount'];
+               }
+               elseif ($trans['trans_type']==ST_JOURNAL && $trans['amount']>=0) {
+                       $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount'];
+                       $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount'];
                }
                elseif (in_array($trans['trans_type'], array(ST_BANKDEPOSIT,ST_SALESINVOICE,ST_CUSTCREDIT))) {
                        $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount'];