Acumatica 自动计算并添加土地成本

Acumatica 自动计算并添加土地成本,acumatica,Acumatica,我需要在PO收据屏幕(PO302000)中根据固定百分比添加LandedCost(我可以将其作为自定义字段包含在PO首选项中)。应在发布采购订单收据时自动添加。哪项活动应该是触发和增加土地成本的最佳方法 这是用户取消选中OnHold复选框的时候吗 或者,用户点击释放按钮?如果是,那么我可以扩展释放操作吗?释放Porecipts的方法是静态的,我们无法覆盖它。 但是,我们可以覆盖调用此静态方法的位置。它在两个位置被调用:1)在PoreceipEntry(图形)的释放操作上,以及2)在设置流程委托的

我需要在PO收据屏幕(PO302000)中根据固定百分比添加LandedCost(我可以将其作为自定义字段包含在PO首选项中)。应在发布采购订单收据时自动添加。哪项活动应该是触发和增加土地成本的最佳方法

这是用户取消选中OnHold复选框的时候吗

或者,用户点击释放按钮?如果是,那么我可以扩展释放操作吗?

释放Porecipts的方法是静态的,我们无法覆盖它。 但是,我们可以覆盖调用此静态方法的位置。它在两个位置被调用:1)在PoreceipEntry(图形)的释放操作上,以及2)在设置流程委托的POReleaseReceipt(图形)的构造函数上

1) 在porecipentry上,您可以扩展此图,首先执行自定义代码,然后调用base release方法

public class POReceiptEntry_Extension:PXGraphExtension<POReceiptEntry>
  {
        public PXSetup<POSetup> posetup;

        #region Event Handlers
        public PXAction<POReceipt> release;
        [PXUIField(DisplayName = Messages.Release, MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
        [PXProcessButton]
        public virtual void Release()
        {
            //retrieve value from Custom field added on PO Preferences screen
            //POSetup setup = posetup.Current;
            //POSetupExt setupExt = setup.GetExtension<POSetupExt>();

            LandedCostTran landedCost = Base.landedCostTrans.Insert();
            landedCost.LandedCostCodeID = "YOURLANDEDCOSTCODE";
            landedCost.InvoiceNbr = "YOURINVOICENUMBER";
            landedCost.CuryLCAmount = 2;  //Formula here using setupExt.UsrFieldPercentange
            Base.landedCostTrans.Update(landedCost);

            Base.release.Press();
        }
    #endregion
  }
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using PX.Common;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.IN;
using PX.Objects.AP;
using PX.Objects.PO;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects;

namespace PX.Objects.PO
{

  public class POReleaseReceipt_Extension:PXGraphExtension<POReleaseReceipt>
  {
        public override void Initialize()
        {
            //Gets Process Delegate
            var processDelegate = (PXProcessingBase<POReceipt>.ProcessListDelegate)Base.Orders.GetProcessDelegate();

            //Change the process delegate that was created by the framework by your custom one.
            Base.Orders.SetProcessDelegate(delegate (List<POReceipt> orders) { POReceiptsProc(orders, processDelegate); });

        }

        public static void POReceiptsProc(List<POReceipt> orders, PXProcessingBase<POReceipt>.ProcessListDelegate processDelegate)
        {
            //Execute your custom code here
            //create POReceiptEntry graph, Loop through the orders,  Access your Custom field, Add LandedCost
            PXTrace.WriteInformation("Start Process execution");

            POReceiptEntry graph = PXGraph.CreateInstance<POReceiptEntry>();

            ........

            //Call the base action
            if (processDelegate != null)
                processDelegate(orders);
        }
    }
}
公共类PoreceipEntry\u扩展:pXgrapherExtension
{
公共PXSetup posetup;
#区域事件处理程序
公开行动发布;
[PXUIField(DisplayName=Messages.Release,MapEnableRights=PXCacheRights.Update,MapViewRights=PXCacheRights.Update)]
[PXProcessButton]
公共虚拟无效释放()
{
//从PO首选项屏幕上添加的自定义字段中检索值
//POSetup setup=POSetup.Current;
//POSetupExt setupExt=setup.GetExtension();
LandedCostTran landedCost=Base.landedCostTrans.Insert();
landedCost.LandedCostCodeID=“YOURLANDEDCOSTCODE”;
landedCost.InvoiceNbr=“您的发票号码”;
landedCost.CuryLCAmount=2;//此处的公式使用setupExt.UsrFieldPercentange
基本成本(landedCostTrans.Update)(landedCost);
Base.release.Press();
}
#端区
}
2) 在POReleaseReceipt图上,由于流程委托是在此图的构造函数上设置的,因此可以扩展此图并重写Initialize()方法来设置自定义流程委托。 自定义流程委托将拥有自定义代码,然后调用基本方法

public class POReceiptEntry_Extension:PXGraphExtension<POReceiptEntry>
  {
        public PXSetup<POSetup> posetup;

        #region Event Handlers
        public PXAction<POReceipt> release;
        [PXUIField(DisplayName = Messages.Release, MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
        [PXProcessButton]
        public virtual void Release()
        {
            //retrieve value from Custom field added on PO Preferences screen
            //POSetup setup = posetup.Current;
            //POSetupExt setupExt = setup.GetExtension<POSetupExt>();

            LandedCostTran landedCost = Base.landedCostTrans.Insert();
            landedCost.LandedCostCodeID = "YOURLANDEDCOSTCODE";
            landedCost.InvoiceNbr = "YOURINVOICENUMBER";
            landedCost.CuryLCAmount = 2;  //Formula here using setupExt.UsrFieldPercentange
            Base.landedCostTrans.Update(landedCost);

            Base.release.Press();
        }
    #endregion
  }
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using PX.Common;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.IN;
using PX.Objects.AP;
using PX.Objects.PO;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects;

namespace PX.Objects.PO
{

  public class POReleaseReceipt_Extension:PXGraphExtension<POReleaseReceipt>
  {
        public override void Initialize()
        {
            //Gets Process Delegate
            var processDelegate = (PXProcessingBase<POReceipt>.ProcessListDelegate)Base.Orders.GetProcessDelegate();

            //Change the process delegate that was created by the framework by your custom one.
            Base.Orders.SetProcessDelegate(delegate (List<POReceipt> orders) { POReceiptsProc(orders, processDelegate); });

        }

        public static void POReceiptsProc(List<POReceipt> orders, PXProcessingBase<POReceipt>.ProcessListDelegate processDelegate)
        {
            //Execute your custom code here
            //create POReceiptEntry graph, Loop through the orders,  Access your Custom field, Add LandedCost
            PXTrace.WriteInformation("Start Process execution");

            POReceiptEntry graph = PXGraph.CreateInstance<POReceiptEntry>();

            ........

            //Call the base action
            if (processDelegate != null)
                processDelegate(orders);
        }
    }
}
使用系统;
使用系统集合;
使用System.Collections.Generic;
使用System.Runtime.Serialization;
使用系统文本;
使用PX.Common;
使用PX数据;
使用PX.Objects.CS;
使用PX.Objects.IN;
使用PX.Objects.AP;
使用PX.Objects.PO;
使用PX.Objects.GL;
使用PX.Objects.CM;
使用PX.Objects;
命名空间PX.Objects.PO
{
公共类POReleaseReceipt_扩展:PXGraphExtension
{
公共覆盖无效初始化()
{
//获取进程委托
var processDelegate=(PXProcessingBase.ProcessListDelegate)Base.Orders.GetProcessDelegate();
//将框架创建的流程委托更改为自定义委托。
SetProcessDelegate(委托(列表订单){POReceiptsProc(订单,流程委托);});
}
公共静态void POReceiptsProc(列表顺序,PXProcessingBase.ProcessListDelegate processDelegate)
{
//在这里执行自定义代码
//创建PoreceipEntry图,循环查看订单,访问自定义字段,添加LandedCost
PXTrace.WriteInformation(“启动进程执行”);
PorecipEntry graph=PXGraph.CreateInstance();
........
//调用基本操作
if(processDelegate!=null)
处理代表(命令);
}
}
}