From: Janusz Dobrowolski Date: Sat, 30 Jan 2010 14:25:45 +0000 (+0000) Subject: [0000194] Fixed tax records from journal entry (voiding problem) X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=e0e49e6673ede59b907ae9b813d9cef6af9e0763;p=textcart.git [0000194] Fixed tax records from journal entry (voiding problem) --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7cdf1f5..8b4d777 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,8 +19,13 @@ Legend: ! -> Note $ -> Affected files +30-Jan-2010 Janusz Dobrowolski +# [0000194] Fixed tax records from journal entry (voiding problem) +$ /gl/includes/db/gl_db_trans.inc + /reporting/rep709.php + 25-Jan-2010 Joe Hunt -# {0000195] Bug not deleting refs record when deleting Sales Order, Quotation +# [0000195] Bug not deleting refs record when deleting Sales Order, Quotation # A couple of redirecting bugs $ /sales/sales_order_entry.php /sales/includes/db/sales_order_db.inc diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index af06ced..efb8b2f 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -279,8 +279,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 @@ -349,14 +349,27 @@ function get_tax_summary($from, $to) $todate = date2sql($to); $sql = "SELECT + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE + ." || trans_type=".ST_JOURNAL.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", net_amount*ex_rate,0)) net_output, + + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE + ." || trans_type=".ST_JOURNAL.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", amount*ex_rate,0)) payable, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", net_amount*ex_rate,0)) net_output, - SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", amount*ex_rate,0)) payable, - SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", 0, net_amount*ex_rate)) net_input, + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", 0, net_amount*ex_rate)) net_input, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", 0, amount*ex_rate)) collectible, + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", 0, amount*ex_rate)) collectible, taxrec.rate, ttype.id, ttype.name @@ -411,7 +424,7 @@ function write_journal_entries(&$cart, $reverse, $use_transaction=true) } // store tax details if the gl account is a tax account add_gl_tax_details($journal_item->code_id, - ($journal_item->amount < 0.0 ? ST_BANKDEPOSIT : ST_BANKPAYMENT), $trans_id, -$journal_item->amount, 1, $date_, $memo_); + ST_JOURNAL, $trans_id, $journal_item->amount, 1, $date_, $memo_); } if ($new) { @@ -448,7 +461,7 @@ function write_journal_entries(&$cart, $reverse, $use_transaction=true) } // store tax details if the gl account is a tax account add_gl_tax_details($journal_item->code_id, - ($journal_item->amount < 0.0 ? ST_BANKDEPOSIT : ST_BANKPAYMENT), $trans_id, $journal_item->amount, 1, $reversingDate, $memo_); + ST_JOURNAL, $trans_id, $journal_item->amount, 1, $reversingDate, $memo_); } add_comments($trans_type, $trans_id_reverse, $reversingDate, $memo_); diff --git a/reporting/rep709.php b/reporting/rep709.php index 4baf010..3fc4c63 100644 --- a/reporting/rep709.php +++ b/reporting/rep709.php @@ -143,7 +143,11 @@ function print_tax_report() $rep->Header(); } } - if (in_array($trans['trans_type'], array(ST_BANKDEPOSIT,ST_SALESINVOICE,ST_CUSTCREDIT))) { + 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']; + } + elseif (in_array($trans['trans_type'], array(ST_BANKDEPOSIT,ST_SALESINVOICE,ST_CUSTCREDIT))) { $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount']; $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount']; } else {