From f47d9d014a202852918520b35927ad65bb421bf6 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Mon, 13 Jul 2009 00:57:28 +0000 Subject: [PATCH] Bug in Tax Inquiry and Tax Report when entering in Journal Entry --- CHANGELOG.txt | 6 ++++++ gl/includes/db/gl_db_banking.inc | 2 +- gl/includes/db/gl_db_trans.inc | 26 +++++++++++++------------- reporting/rep709.php | 4 ++-- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a4218d5f..4af7e5e1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index 903b22b5..defbcd84 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -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_); } diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index 76d293e0..297eeb38 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -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_); diff --git a/reporting/rep709.php b/reporting/rep709.php index c135445f..ac058d31 100644 --- a/reporting/rep709.php +++ b/reporting/rep709.php @@ -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 { -- 2.30.2