The bug I am going to detail here needs a scenario.
Using on Journal Entry I recorded the Opening Balances of all customers.
Upon recording payment for one out of those customers I encountered following error.
/PATH-TO-FA/includes/errors.inc:207: trigger_error('DATABASE ERROR : duplicate debtor transactions 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, trans.prep_amount>0 as prepaid,com.memo_, branch.* FROM debtor_trans trans LEFT JOIN comments com ON trans.type=com.type AND trans.trans_no=com.id LEFT JOIN shippers ON shippers.shipper_id=trans.ship_via, debtors_master cust, cust_branch branch WHERE trans.trans_no='96' AND trans.type='0' AND trans.debtor_no=cust.debtor_no AND branch.branch_code = trans.branch_code
','256')
/PATH-TO-FA/sales/includes/db/cust_trans_db.inc:214: display_db_error('duplicate debtor transactions found for given params','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, trans.prep_amount>0 as prepaid,com.memo_, branch.* FROM &TB_PREF&debtor_trans trans LEFT JOIN &TB_PREF&comments com ON trans.type=com.type AND trans.trans_no=com.id LEFT JOIN &TB_PREF&shippers ON &TB_PREF&shippers.shipper_id=trans.ship_via, &TB_PREF&debtors_master cust, &TB_PREF&cust_branch branch WHERE trans.trans_no='96' AND trans.type='0' AND trans.debtor_no=cust.debtor_no AND branch.branch_code = trans.branch_code ','1')
/PATH-TO-FA/includes/ui/allocation_cart.inc:381: get_customer_trans('96','0')
/PATH-TO-FA/sales/customer_payments.php:222: check_allocations()
/PATH-TO-FA/sales/customer_payments.php:236: can_process()
The reason for this bug is that multiple customer payments are recorded for One Transaction Number and Same Transaction Type.
I found the solution to this is to add 3rd argument in function call get_customer_trans() in /includes/ui/allocation_cart.inc as below on Line#399
$trans = get_customer_trans($_SESSION['alloc']->allocs[$counter]->type_no, $_SESSION['alloc']->allocs[$counter]->type, $_SESSION['alloc']->person_id);
I hope this shall not cause any other bug.