Skip to main content
Question

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

  • July 11, 2023
  • 0 replies
  • 61 views

Forum|alt.badge.img

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();
        }