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
$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
}
// 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) {
}
// 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_);