How to check the customer whether it is already exceeded credit limit or not, programmatically?

SOLVED

Hi all,

How to check the customer whether it is already exceeded credit limit or not, programmatically? Because I do not find any standard function to check it. I only find the exceptions, but I do not know how to trigger the exception during customer selection on my custom form. 

Thank you.

  • +1
    verified answer

    Checked the standard coding and just copy how standard do the validation.

    /*
             * <summary>
             * Check if the customer has exceeded credit limit
             * </summary>
             */
            internal bool hasExceededCreditLimit(Sage.Accounting.SalesLedger.Customer customer)
            {
                bool isovercreditlimit = false;
                decimal zero = 0;
                if(customer.TradingAccount.CreditLimit > zero)
                {
                    if ((customer.PendingNotificationDocumentsValue + customer.AccountBalance) <= customer.TradingAccount.CreditLimit)
                    {
                        isovercreditlimit = false;
                    }
                    else
                    {
                        isovercreditlimit = true;
                    }
                }
                return isovercreditlimit;
            }

  • 0
    SUGGESTED

    Hi Murni,

    I apologise for the delay in getting back to you. This code example you've given should work.

    If you require further assistance and are a member of the Developers Programme, you can get in touch with us at [email protected]