Skip to main content
Answer

Change transactions AccountID

  • October 30, 2025
  • 2 replies
  • 39 views

Forum|alt.badge.img+1

Hi. I have Prepayment on AR302000 screen. On Application of the Prepayment to a Normal AR Invoice, i need change debit account id. How I can do this? 

Best answer by bihalivan15

I override this method. And it solved for me:

 [PXOverride]
        public virtual GLTran InsertAdjustmentsAdjustingTransaction(JournalEntry je, GLTran tran, GLTranInsertionContext context, Func<JournalEntry, GLTran, GLTranInsertionContext, GLTran> baseMethod)
        {
            if (context.ARRegisterRecord != null && context.ARAdjustRecord != null)
            {
                if (tran.DebitAmt != 0 && context.ARRegisterRecord?.DocType == ARDocType.Prepayment && context.ARAdjustRecord?.AdjdDocType == ARInvoiceType.Invoice)
                {
                    ARDepositInvoiceSetup setup = PXSelect<ARDepositInvoiceSetup>.Select(Base).FirstOrDefault();

                    if (setup?.EnableGLIntegration == true)
                    {
                        Customer customer = Customer.PK.Find(Base, context.ARAdjustRecord.CustomerID);

                        tran.AccountID = customer?.PrepaymentAcctID;
                        tran.SubID = customer?.PrepaymentSubID;
                    }
                }
            }

            return baseMethod(je, tran, context);
        }

2 replies

Forum|alt.badge.img+3

Could you please provide more details, along with attached screenshots, explaining your workflow and the conditions under which you need to change the AccountID?


Forum|alt.badge.img+1
  • Author
  • Semi-Pro II
  • Answer
  • October 31, 2025

I override this method. And it solved for me:

 [PXOverride]
        public virtual GLTran InsertAdjustmentsAdjustingTransaction(JournalEntry je, GLTran tran, GLTranInsertionContext context, Func<JournalEntry, GLTran, GLTranInsertionContext, GLTran> baseMethod)
        {
            if (context.ARRegisterRecord != null && context.ARAdjustRecord != null)
            {
                if (tran.DebitAmt != 0 && context.ARRegisterRecord?.DocType == ARDocType.Prepayment && context.ARAdjustRecord?.AdjdDocType == ARInvoiceType.Invoice)
                {
                    ARDepositInvoiceSetup setup = PXSelect<ARDepositInvoiceSetup>.Select(Base).FirstOrDefault();

                    if (setup?.EnableGLIntegration == true)
                    {
                        Customer customer = Customer.PK.Find(Base, context.ARAdjustRecord.CustomerID);

                        tran.AccountID = customer?.PrepaymentAcctID;
                        tran.SubID = customer?.PrepaymentSubID;
                    }
                }
            }

            return baseMethod(je, tran, context);
        }