Question

Add a new line in the GL detail when releasing from checks and payments

  • 12 July 2023
  • 0 replies
  • 41 views

Userlevel 1

Hi guys!,
I have a question. I am using the check and payment module, at launch I make GL insert a new line in addition to the existing one, and I have customized the GL screen and within it. I am using the public void Persist(PersistDelegate baseMethod) method and adding code to insert a new line in the GL details.
However, when I put the interrupt point I see that it enters many times.
Could you please tell me which event or method should I use and which is efficient?.

 

        public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(PersistDelegate baseMethod)
        {
            Batch batch = Base.BatchModule.Current;
            GLTran gL = Base.GLTranModuleBatNbr.Current;
            CurrencyInfo curren = Base.currencyinfo.Current;

             string TBienServ = string.Empty; decimal? detra = 0m; decimal? changetype = 0;
            if (batch != null && batch.AutoReverseCopy == false && batch.OrigBatchNbr == null)
            {
                #region validate

                string RefNbr = string.Empty;
                string TranType = string.Empty;

                Account account = PXSelectJoin<Account, InnerJoin<Tax,
                On<Tax.salesTaxAcctID, Equal<Account.accountID>>, InnerJoin<xtb08Sunat, On<xtb08Sunat.taxCD, Equal<Tax.taxID>>>>,
                Where<xtb08Sunat.tGdsSvcsCD, Equal<Required<xtb08Sunat.tGdsSvcsCD>>>>.Select(Base, TBienServ);

                Tax tax = PXSelectJoin<Tax, InnerJoin<xtb08Sunat, On<xtb08Sunat.taxCD, Equal<Tax.taxID>>>,
                 Where<xtb08Sunat.tGdsSvcsCD, Equal<Required<xtb08Sunat.tGdsSvcsCD>>>>.Select(Base, TBienServ);

                var glTran = Base.GLTranModuleBatNbr.Insert();
                Base.GLTranModuleBatNbr.SetValueExt<GLTran.accountID>(glTran, account.AccountID);
                glTran = Base.GLTranModuleBatNbr.Update(glTran);
                Base.GLTranModuleBatNbr.SetValueExt<GLTran.subID>(glTran, tax.SalesTaxSubID);
                glTran.RefNbr = gL.RefNbr;
                glTran.Qty = 0;
                glTran.UOM = null;
                glTran.ProjectID = 0;
                glTran.TranType = gL.TranType;
                glTran.ReferenceID = null;
                glTran.InventoryID = null;
                glTran.Released = true;
                Base.GLTranModuleBatNbr.SetValueExt<GLTran.curyCreditAmt>(glTran, detra);
                Base.GLTranModuleBatNbr.SetValueExt<GLTran.curyDebitAmt>(glTran, 0m);
                Base.GLTranModuleBatNbr.SetValueExt<GLTran.creditAmt>(glTran, detra * changetype);
                Base.GLTranModuleBatNbr.SetValueExt<GLTran.debitAmt>(glTran, 0m);
                glTran.TranDesc = "new line";
                RefNbr = gL.RefNbr;
                TranType = gL.TranType;
                Base.GLTranModuleBatNbr.Update(glTran);
            }
            #endregion
            baseMethod.Invoke();
        }

 

 


0 replies

Be the first to reply!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved