Bug in Tax Inquiry and Tax Report when entering in Journal Entry
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 13 Jul 2009 00:57:28 +0000 (00:57 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 13 Jul 2009 00:57:28 +0000 (00:57 +0000)
CHANGELOG.txt
gl/includes/db/gl_db_banking.inc
gl/includes/db/gl_db_trans.inc
reporting/rep709.php

index a4218d5fe3a5f28560151d84e987b8384315e84c..4af7e5e12dce486f8bb0f3cd2e342ccee8de2257 100644 (file)
@@ -19,6 +19,12 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+13-Jul-2009 Joe Hunt
+# Bug in Tax Inquiry and Tax Report when entering in Journal Entry
+$ /gl/includes/db/gl_db_banking.inc
+  /gl/includes/db/gl_db_trans.inc
+  /reporting/rep709.php
+  
 12-Jul-2009 Joe Hunt
 # Wrong presentation of left to allocate if discount was given
 $ /sales/view/view_receipt.php
index 903b22b5ff0a24fe6bf3b96b0c1acedc07f14d83..defbcd846178fca56293e90b546efa2b5f33266f 100644 (file)
@@ -203,7 +203,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_,
                $amount = $gl_item->amount;
                $ex_rate = get_exchange_rate_from_home_currency($currency, $date_);
                        
-               add_gl_tax_details($gl_item->code_id, $trans_type, $trans_no, $amount,
+               add_gl_tax_details($gl_item->code_id, $trans_type, $trans_no, -$amount,
                        $ex_rate, $date_, $memo_);
        }
 
index 76d293e0985032937fa4dc287522a55235e55532..297eeb38e9b525209ac1c7fa44af326a3d18b824 100644 (file)
@@ -260,8 +260,8 @@ function add_gl_tax_details($gl_code, $trans_type, $trans_no, $amount, $ex_rate,
        if(!$tax_type) return;  // $gl_code is not tax account
        
        $tax = get_tax_type($tax_type);
-       if ($gl_code == $tax['sales_gl_code']) 
-               $amount = -$amount;
+       //if ($gl_code == $tax['sales_gl_code']) 
+       //      $amount = -$amount;
        // we have to restore net amount as we cannot know the base amount
        if ($tax['rate'] == 0) {
 //             display_warning(_("You should not post gl transactions  
@@ -329,14 +329,14 @@ function get_tax_summary($from, $to)
        $todate = date2sql($to);
 
        $sql = "SELECT 
-                               SUM(IF( trans_type=1 || trans_type=11 || trans_type=20,-1,1)*
-                               IF(trans_type=0 || trans_type=2 || trans_type=10 || trans_type=11, net_amount*ex_rate,0)) net_output,
-                               SUM(IF( trans_type=1 || trans_type=11 || trans_type=20,-1,1)*
-                               IF(trans_type=0 || trans_type=2 || trans_type=10 || trans_type=11, amount*ex_rate,0)) payable,
-                               SUM(IF( trans_type=1 || trans_type=11 || trans_type=20,-1,1)*
-                               IF(trans_type=0 || trans_type=2 || trans_type=10 || trans_type=11, 0, net_amount*ex_rate)) net_input,
-                               SUM(IF( trans_type=1 || trans_type=11 || trans_type=20,-1,1)*
-                               IF(trans_type=0 || trans_type=2 || trans_type=10 || trans_type=11, 0, amount*ex_rate)) collectible,
+                               SUM(IF(trans_type=11 || trans_type=20,-1,1)*
+                               IF(trans_type=2 || trans_type=10 || trans_type=11, net_amount*ex_rate,0)) net_output,
+                               SUM(IF(trans_type=11 || trans_type=20,-1,1)*
+                               IF(trans_type=2 || trans_type=10 || trans_type=11, amount*ex_rate,0)) payable,
+                               SUM(IF(trans_type=11 || trans_type=20,-1,1)*
+                               IF(trans_type=2 || trans_type=10 || trans_type=11, 0, net_amount*ex_rate)) net_input,
+                               SUM(IF(trans_type=11 || trans_type=20,-1,1)*
+                               IF(trans_type=2 || trans_type=10 || trans_type=11, 0, amount*ex_rate)) collectible,
                                taxrec.rate,
                                ttype.id,
                                ttype.name
@@ -375,7 +375,7 @@ function add_journal_entries($items, $date_, $ref, $reverse, $memo_=null)
        }
                // store tax details if the gl account is a tax account
                add_gl_tax_details($journal_item->code_id, 
-                       $trans_type, $trans_id, -$journal_item->amount, 1, $date_, $memo_);
+                       ($journal_item->amount < 0.0 ? 2 : 1), $trans_id, -$journal_item->amount, 1, $date_, $memo_);
        }
        
        add_comments($trans_type, $trans_id, $date_, $memo_);
@@ -401,13 +401,13 @@ function add_journal_entries($items, $date_, $ref, $reverse, $memo_=null)
                if ($is_bank_to)
                {
                        add_bank_trans($trans_type, $trans_id_reverse, $is_bank_to, $ref,
-                               $reversingDate, $journal_item->amount,
+                               $reversingDate, -$journal_item->amount,
                                0, "", get_company_currency(),
                                "Cannot insert a destination bank transaction");
                }
                        // store tax details if the gl account is a tax account
                        add_gl_tax_details($journal_item->code_id, 
-                               $trans_type, $trans_id, $journal_item->amount, 1, $date, $memo_);
+                               ($journal_item->amount < 0.0 ? 2 : 1), $trans_id, $journal_item->amount, 1, $date, $memo_);
        }
 
        add_comments($trans_type, $trans_id_reverse, $reversingDate, $memo_);
index c135445f9b91e0ee452faaa67d1ecb1e23f2ae28..ac058d31ec7777b6436a91edafaa71940619448d 100644 (file)
@@ -119,7 +119,7 @@ function print_tax_report()
 
        while ($trans=db_fetch($transactions))
        {
-               if (in_array($trans['trans_type'], array(11,20,1))) {
+               if (in_array($trans['trans_type'], array(11,20))) {
                        $trans['net_amount'] *= -1;
                        $trans['amount'] *= -1;
                }
@@ -144,7 +144,7 @@ function print_tax_report()
                                $rep->Header();
                        }
                }
-               if (in_array($trans['trans_type'], array(0,2,10,11))) {
+               if (in_array($trans['trans_type'], array(2,10,11))) {
                        $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount'];
                        $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount'];
                } else {