Topic: ERROR IN MYSQL WHEN A CUSTOMER PAYMENT IS VOID

I found a problem with error message after I voided a customer payment.  This problem has been encountered by other users:

Ref: https://frontaccounting.com/punbb/viewtopic.php?id=4892

When attempt to open a voided customer payment by clicking on the Customer Payment #, the following error message appeared:

DATABASE ERROR : no debtor trans found for given params
sql that failed was : SELECT trans.*,ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount AS Total,cust.name AS DebtorName, cust.address, cust.curr_code, cust.tax_id, com.memo_,bank_act,0_bank_accounts.bank_name, 0_bank_accounts.bank_account_name, 0_bank_accounts.account_type AS BankTransType, 0_bank_accounts.bank_curr_code, 0_bank_trans.amount as bank_amount FROM 0_debtor_trans trans LEFT JOIN 0_comments com ON trans.type=com.type AND trans.trans_no=com.id LEFT JOIN 0_shippers ON 0_shippers.shipper_id=trans.ship_via, 0_debtors_master cust, 0_bank_trans, 0_bank_accounts WHERE trans.trans_no='22' AND trans.type='12' AND trans.debtor_no=cust.debtor_no AND 0_bank_trans.trans_no ='22' AND 0_bank_trans.type=12 AND 0_bank_trans.amount != 0 AND 0_bank_accounts.id=0_bank_trans.bank_act

I managed to find a line in  sales/includes/db/cust_trans_db.inc that somehow caused the database error.

    if ($trans_type == ST_CUSTPAYMENT || $trans_type == ST_BANKDEPOSIT) {
        // it's a payment so also get the bank account
        $sql .= " AND ".TB_PREF."bank_trans.trans_no =".db_escape($trans_id)."
            AND ".TB_PREF."bank_trans.type=$trans_type
            AND ".TB_PREF."bank_trans.amount != 0  <<== the "!=" is causing the issue
            AND ".TB_PREF."bank_accounts.id=".TB_PREF."bank_trans.bank_act ";

As stated above, this != 0 is causing the problem.  If I remove "!", then the voided payment will appear normal.  But the normal customer payment will have the same error.

Due to my limited php knowledge, I am not able to fix it. 

I hope this can be fixed as soon as possible or it looks ugly when the user click on the transaction.

Thanks!

/Mark

Re: ERROR IN MYSQL WHEN A CUSTOMER PAYMENT IS VOID

Which version of FA are you using?
The current stable one is v2.3.25+.
Which Chart of Account are you using?

Since it is related to another post, it is best if posted in that thread itself.

Re: ERROR IN MYSQL WHEN A CUSTOMER PAYMENT IS VOID

It was version 2.3.22.   I upgraded to 2.3.25 and I did the same test and it just showed a blank screen. (not sure your 2.3.25"+" contains what patches).

The COA I'm using is Singapore 4 digit.

I will re-Post this over there.

Re: ERROR IN MYSQL WHEN A CUSTOMER PAYMENT IS VOID

Make a separate clean install of FA v2.3.25 and take a backup of the sql schema.
Compare the sql with that of your pre-upgrade v2.3.22 and see if there are any settings change.
Compare the sql/en_US-new.sql in FA v2.3.25+ with your Singapore CoA and see what differs.