Acumatica 修改票据和调整单发布时生成的总账批次

Acumatica 修改票据和调整单发布时生成的总账批次,acumatica,acumatica-kb,Acumatica,Acumatica Kb,目标是获取从AP账单页面生成的日记账事务,并在GLTran中添加另外两行 第一次尝试 首先,我扩展了Journal Transactions图中的Release操作,以包括两行新行: public class JournalEntryExt : PXGraphExtension<JournalEntry> { public delegate IEnumerable ReleaseDelegate(PXAdapter adapter); [PXOverr

目标是获取从AP账单页面生成的日记账事务,并在GLTran中添加另外两行

第一次尝试

首先,我扩展了Journal Transactions图中的Release操作,以包括两行新行:

        public class JournalEntryExt : PXGraphExtension<JournalEntry>
{
    public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
    [PXOverride]
    public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
    {
        baseMethod(adapter);

        //new code
        GLTran tranRow = new GLTran();
        tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);

        tranRow.AccountID = 2713;
        tranRow.SubID = 467;
        tranRow.CuryDebitAmt = 100;
        this.Base.GLTranModuleBatNbr.Update(tranRow);


        tranRow = new GLTran();
        tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);

        tranRow.AccountID = 1514;
        tranRow.SubID = 467;
        tranRow.CuryCreditAmt = 100;
        this.Base.GLTranModuleBatNbr.Update(tranRow);

        this.Base.Actions.PressSave();


        return adapter.Get();
    }
公共类JournalEntryText:PXGrapherExtension
{
公共委托IEnumerable ReleaseDelegate(PXAdapter适配器);
[PXOverride]
公共IEnumerable发布(PXAdapter适配器、ReleaseDelegate baseMethod)
{
基本方法(适配器);
//新代码
GLTran tranRow=新GLTran();
tranRow=this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID=2713;
tranRow.SubID=467;
tranRow.CuryDebitAmt=100;
this.Base.GLTranModuleBatNbr.Update(tranRow);
tranRow=新的GLTran();
tranRow=this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID=1514;
tranRow.SubID=467;
tranRow.CuryCreditAmt=100;
this.Base.GLTranModuleBatNbr.Update(tranRow);
this.Base.Actions.PressSave();
返回适配器Get();
}
结果:创建和发布批次时,正确输入了2行新行

在这之后,我认为释放AP账单也会触发GL页面的扩展逻辑。但是,这没有发生-账单的释放似乎没有重复使用GL页面中定义的释放逻辑

第二次尝试

然后,我返回到GL页面,将逻辑包含在RowPersisted事件中,以便在保存文档后立即创建两行新行:

    public class JournalEntryExt : PXGraphExtension<JournalEntry>
    {
        protected virtual void Batch_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
    {
        if (e.Row == null)
        {
            return;
        }

        Batch batchRow = (Batch)e.Row;

        if (batchRow != null
                && e.Operation == PXDBOperation.Insert
                && e.TranStatus == PXTranStatus.Completed)
        {
            ////new code
            GLTran tranRow = new GLTran();
            tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);

            tranRow.AccountID = 2713;
            tranRow.SubID = 467;
            tranRow.CuryDebitAmt = 102;
            this.Base.GLTranModuleBatNbr.Update(tranRow);


            tranRow = new GLTran();
            tranRow = this.Base.GLTranModuleBatNbr.Insert(tranRow);

            tranRow.AccountID = 1514;
            tranRow.SubID = 467;
            tranRow.CuryCreditAmt = 102;
            this.Base.GLTranModuleBatNbr.Update(tranRow);

        }
    }
using PX.Data;
using PX.Objects.GL;
using System.Collections;

namespace PX.Objects.AP
{
    public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
    {
        public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);

        [PXOverride]
        public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
        {
            PXGraph.InstanceCreated.AddHandler<JournalEntry>((JournalEntry graph) =>
            {
                graph.GetExtension<JournalEntry_Extension>().ModifyBatchFromAP = true;
            });

            return baseMethod(adapter);
        }
    }
}
公共类JournalEntryText:PXGrapherExtension
{
受保护的虚拟无效批处理保存(PXCache发送方,PXRowPersistedEventArgs e)
{
如果(e.Row==null)
{
返回;
}
Batch batchRow=(批次)e.Row;
if(batchRow!=null
&&e.Operation==PXDBOperation.Insert
&&e.TranStatus==PXTranStatus.Completed)
{
////新代码
GLTran tranRow=新GLTran();
tranRow=this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID=2713;
tranRow.SubID=467;
tranRow.CuryDebitAmt=102;
this.Base.GLTranModuleBatNbr.Update(tranRow);
tranRow=新的GLTran();
tranRow=this.Base.GLTranModuleBatNbr.Insert(tranRow);
tranRow.AccountID=1514;
tranRow.SubID=467;
tranRow.CuryCreditAmt=102;
this.Base.GLTranModuleBatNbr.Update(tranRow);
}
}
结果:创建和保存批次时正确地输入了两行新行

在这之后,我认为释放AP账单会触发这个扩展事件,因为应该从账单页面创建并使用日记账分录图,但在这种情况下,同样释放AP账单的情况下,没有在生成的批处理中添加2个新行

第三次尝试

然后我想我可以扩展Bill的发布操作,并通过搜索方法控制生成的日记账分录。但是,在这种情况下,扩展逻辑似乎在事务中执行,因为Document.Current.BatchNbr仍然为空:

第四次尝试

最后,我尝试扩展APReleaseProcess的Persist()方法,类似于指南T300中的方法,但是没有列出任何方法(版本17.207.0029):

关于如何输入这些总账行,还有其他想法吗


谢谢!

希望您不会花太多时间来完成这4次尝试……不过我必须说,您的问题中的努力和细节非常令人印象深刻,绝对非常感谢

在为应付款票据生成的批次中插入2个额外总账交易记录需要两步自定义:

  • 要插入额外的总账交易,您需要覆盖日志尝试BLC扩展中的持久化方法,并仅当自定义ModifyBatchFromAP布尔标志值等于True时调用逻辑插入额外的GLTrans:

    using PX.Data;
    using System;
    
    namespace PX.Objects.GL
    {
        public class JournalEntry_Extension : PXGraphExtension<JournalEntry>
        {
            private bool modifyBatchFromAP = false;
    
            public bool ModifyBatchFromAP
            {
                get
                {
                    return modifyBatchFromAP;
                }
                set
                {
                    modifyBatchFromAP = value;
                }
            }
    
            [PXOverride]
            public void Persist(Action del)
            {
                if (ModifyBatchFromAP)
                {
                    var glTran = Base.GLTranModuleBatNbr.Insert();
                    Base.GLTranModuleBatNbr.SetValueExt<GLTran.accountID>(glTran, "20000");
                    glTran = Base.GLTranModuleBatNbr.Update(glTran);
                    Base.GLTranModuleBatNbr.SetValueExt<GLTran.subID>(glTran, "000000");
                    glTran.CuryDebitAmt = 100;
                    glTran.TranDesc = "Additional Debit Transaction for AP Doc";
                    Base.GLTranModuleBatNbr.Update(glTran);
    
                    glTran = Base.GLTranModuleBatNbr.Insert();
                    Base.GLTranModuleBatNbr.SetValueExt<GLTran.accountID>(glTran, "20200");
                    glTran = Base.GLTranModuleBatNbr.Update(glTran);
                    Base.GLTranModuleBatNbr.SetValueExt<GLTran.subID>(glTran, "000000");
                    glTran.CuryCreditAmt = 100;
                    glTran.TranDesc = "Additional Credit Transaction for AP Doc";
                    Base.GLTranModuleBatNbr.Update(glTran);
                }
    
                del();
            }
        }
    }
    
    使用PX.Data;
    使用制度;
    命名空间PX.Objects.GL
    {
    公共类JournalEntry_扩展:pxGrapherExtension
    {
    private bool modifyBatchFromAP=false;
    公共bool ModifyBatchFromAP
    {
    得到
    {
    返回modifyBatchFromAP;
    }
    设置
    {
    modifyBatchFromAP=值;
    }
    }
    [PXOverride]
    公共无效持续(操作del)
    {
    如果(ModifyBatchFromAP)
    {
    var glTran=Base.GLTranModuleBatNbr.Insert();
    Base.GLTranModuleBatNbr.SetValueExt(glTran,“20000”);
    glTran=Base.GLTranModuleBatNbr.Update(glTran);
    Base.GLTranModuleBatNbr.SetValueExt(glTran,“000000”);
    glTran.CuryDebitAmt=100;
    glTran.TranDesc=“应付账款单据的附加借方交易”;
    Base.GLTranModuleBatNbr.Update(glTran);
    glTran=Base.GLTranModuleBatNbr.Insert();
    Base.GLTranModuleBatNbr.SetValueExt(glTran,“20200”);
    glTran=Base.GLTranModuleBatNbr.Update(glTran);
    Base.GLTranModuleBatNbr.SetValueExt(glTran,“000000”);
    glTran.CuryCreditAmt=100;
    glTran.TranDesc=“应付账款单据的附加信用交易”;
    Base.GLTranModuleBatNbr.Update(glTran);
    }
    del();
    }
    }
    }
    
  • 之后,在APINVOICECENTRY_扩展中覆盖的释放操作中,您可以