Bug 5522, 5523, 5524: Journal Entry Affecting in both sales and purchase and more...
[fa-stable.git] / gl / includes / db / gl_db_trans.inc
index 45067bb755a3f27a2b42a772868b71a6f126ce58..a6a10e8246da7b693937433d22baf77967351f4b 100644 (file)
@@ -523,22 +523,22 @@ function get_tax_summary($from, $to, $also_zero_purchases=false)
        $sql = "SELECT 
                                SUM(IF(trans_type=".ST_CUSTCREDIT.",-1,1)*
                                IF((reg_type=".TR_OUTPUT.")"
-                                       ." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.") OR (trans_type=".ST_JOURNAL." AND reg_type=".TR_INPUT."))
+                                       ." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.",".ST_BANKDEPOSIT."))
                                        ), net_amount*ex_rate,0)
                                ) net_output,
 
                                SUM(IF(trans_type=".ST_CUSTCREDIT.",-1,1)*
                                IF((reg_type=".TR_OUTPUT.")"
-                                       ." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.") OR (trans_type=".ST_JOURNAL." AND reg_type=".TR_INPUT."))
+                                       ." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.",".ST_BANKDEPOSIT."))
                                        ), amount*ex_rate,0)) payable,
 
-                               SUM(IF(trans_type IN(".ST_SUPPCREDIT."),-1,1)*
-                               IF(reg_type=".TR_INPUT
+                               SUM(IF(trans_type IN(".ST_SUPPCREDIT.",".ST_BANKPAYMENT."),-1,1)*
+                               IF((reg_type=".TR_INPUT." OR trans_type IN (".ST_SUPPINVOICE.",".ST_BANKPAYMENT."))"
                                        . ($also_zero_purchases ? '': " AND tax_type_id AND taxrec.rate")
                                        .", net_amount*ex_rate, 0)) net_input,
 
-                               SUM(IF(trans_type IN(".ST_SUPPCREDIT."),-1,1)*
-                               IF(reg_type=".TR_INPUT
+                               SUM(IF(trans_type IN(".ST_SUPPCREDIT.",".ST_BANKPAYMENT."),-1,1)*
+                               IF((reg_type=".TR_INPUT." OR trans_type IN (".ST_SUPPINVOICE.",".ST_BANKPAYMENT."))"
                                        . ($also_zero_purchases ? '': " AND tax_type_id AND taxrec.rate ") 
                                        .", amount*ex_rate, 0)) collectible,
                                taxrec.rate,