Wednesday, March 13, 2013

Removig Artificial Intelligence from GL Journal Entry Screen.

Hi Guys,

GL Journal Entry screen has one controversial feature - auto balancing of Debit to Credit for the line entered in the grid.

Its like when you enter Debit 100$ then you move to the next line, system auto defaults Credit to be 100$. Well its nice to have but...would be great to be able to switch it off...when needed.

So after some browsing throught the code, just realised, the calculation is hidden into a Method PopulateSubDescr

So, if you do not like DR to be == to CR :) for each line, then just override that method in your customization code with this statment. Well what I did - just removed AI piece of code. So just leave this:


protected override void PopulateSubDescr(PXCache sender, GLTran Row, bool ExternalCall)
        {
            GLTran prevTran = null;
            foreach (GLTran tran in GLTranModuleBatNbr.Select())
            {
                if (Row == tran)
                {
                    break;
                }
                prevTran = tran;
            }
            if (prevTran != null)
            {
                if (prevTran.SubID != null)
                {
                    Sub sub = (Sub)PXSelectorAttribute.Select<GLTran.subID>(sender, prevTran);
                    if (sub != null)
                    {
                        sender.SetValueExt<GLTran.subID>(Row, sub.SubCD);
                        PXUIFieldAttribute.SetError<GLTran.subID>(sender, Row, null);
                    }
                }
                Row.TranDesc = prevTran.TranDesc;
                Row.RefNbr = prevTran.RefNbr;
            }
            else
            {
                Row.TranDesc = BatchModule.Current.Description;
            }
            Account account = (Account)PXSelectorAttribute.Select<GLTran.accountID>(sender, Row);
            if (account != null && account.CashSubID != null)
            {
                Row.SubID = account.CashSubID;
            }
            if (account != null && (bool)account.NoSubDetail && glsetup.Current.DefaultSubID != null)
            {
                Row.SubID = glsetup.Current.DefaultSubID;
            }
            
        }

Have a nice Day!
Sergey. :)

No comments:

Post a Comment