1 (edited by boxygen 12/02/2022 06:05:54 am)

Topic: Bug in Voiding Customer Payment

I faced a case with one of my installation.

I tried voiding a Customer Payment.

When It comes to the following Line of code in void_transaction() function

case ST_CUSTPAYMENT : // it's a customer payment
            if (!check_void_bank_trans($type, $type_no))
                return _('This transaction cannot be voided because the operation would decrease account balance below allowed limit in some point of account history.');
        case ST_SALESINVOICE : // it's a customer invoice
             if (is_cust_invoice_credited($type_no))
                return _('This invoice cannot be voided because it was already credited.');

    case ST_CUSTCREDIT : // it's a customer credit note
        case ST_CUSTDELIVERY : // it's a customer dispatch
            if (!exists_customer_trans($type, $type_no))
                return _('Selected transaction does not exists.');
            if ($type == ST_CUSTDELIVERY)    // added 04 Oct 2008 by Joe Hunt. If delivery note has a not voided invoice, then NO.
            {
                $vers = get_customer_trans_version($type, $type_no);
                if ($vers[$type_no] == 1) {
                    $childs = get_sales_child_lines($type, $type_no, false); // 2011-03-17 This had been changed. Joe
                    if ($childs && db_num_rows($childs))
                        return _('This delivery cannot be voided because it was already invoiced.');
                }
            }
            post_void_customer_trans($type, $type_no);
            break;

it gave the error message This invoice cannot be voided because it was already credited

Means there is no break after ST_CUSTPAYMENT condition so it attempted the next switch case ST_SALESINVOICE

I resolved the bug with following changes.

case ST_CUSTPAYMENT : // it's a customer payment
            if (!check_void_bank_trans($type, $type_no))
                return _('This transaction cannot be voided because the operation would decrease account balance below allowed limit in some point of account history.');
            post_void_customer_trans($type, $type_no);
            break;
        case ST_SALESINVOICE : // it's a customer invoice
             if (is_cust_invoice_credited($type_no))
                return _('This invoice cannot be voided because it was already credited.');
            post_void_customer_trans($type, $type_no);
            break;

Please let me know if this is the right way to handle this bug?

www.boxygen.pk

Re: Bug in Voiding Customer Payment

This bug has already been fixed, see topic

https://frontaccounting.com/punbb/viewt … ?id=10038].

Joe

Re: Bug in Voiding Customer Payment

Ok Thank you. I missed that Post earlier

www.boxygen.pk