Acumatica-如何向InvoiceSplits选择器添加新列

时间:2019-10-08 23:37:46

标签: action customization acumatica

我需要将UnitCost添加到“发票类型”是贷方或退货时在“销售订单”屏幕中单击“添加发票”时出现的“添加发票详细信息选择器”屏幕。我是Acumatica的新手,不确定是否需要做为扩展。我将其添加到InvoiceSplits中,但是当我在其中放置断点时,我再也没有遇到它们。

我将此代码添加到SOOrderEntry ...我在正确的轨道上吗?

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {
    [System.SerializableAttribute()]
    public class InvoiceSplits : IBqlTable
    {
    #region UnitCost
      public abstract class unitCost : PX.Data.IBqlField
      {
      }
      protected Decimal? _UnitCost;

      [PXDBPriceCost()]
      [PXUIField(DisplayName = "Unit Cost")]
      public virtual Decimal? UnitCost
      {
        get
        {
          return this._UnitCost;
        }
        set
        {
          this._UnitCost = value;
        }
      }
    }
    #endregion

    #region Event Handlers
    public delegate InvoiceSplits CreateInvoiceSplitsDelegate(ARTran artran, SOLine line, SOSalesPerTran sptran, INTran tran, INTranSplit split);
  //  [PXOverride]
    public InvoiceSplits CreateInvoiceSplits(ARTran artran, SOLine line, SOSalesPerTran sptran, INTran tran, INTranSplit split, CreateInvoiceSplitsDelegate baseMethod)
    {
      InvoiceSplits invSplit = new InvoiceSplits();

      invSplit.UnitCost = artran.UnitCost;
      if (tran != null)
      {
        invSplit.UnitCost = split.UnitCost ?? tran.UnitCost;
      }
        return invSplit;
     // return baseMethod(artran,line,sptran,tran,split);
    }

1 个答案:

答案 0 :(得分:0)

您希望创建一个InvoiceSplits的PXCacheExtension,而不是创建一个单独的InvoiceSplits类。

public sealed class InvoiceSplitsExtension : PXCacheExtension<InvoiceSplits>
{

    #region UnitCost
    public abstract class unitCost : IBqlField
    {
    }
    [PXDBPriceCost]
    [PXUIField(DisplayName = "Unit Cost")]
    public decimal? UnitCost { get; set; }
    #endregion

}

然后在CreateInvoiceSplits方法的PXOverride中,您将获得CacheExtension并在其上设置UnitCost。

public delegate InvoiceSplits CreateInvoiceSplitsDel(ARTran artran, SOLine line, SOSalesPerTran sptran, INTran tran, INTranSplit split);

[PXOverride]
public InvoiceSplits CreateInvoiceSplits(ARTran artran, SOLine line, SOSalesPerTran sptran, INTran tran, INTranSplit split, CreateInvoiceSplitsDel del)
{
    InvoiceSplits invSplit = del?.Invoke(artran, line, sptran, tran, split);

    InvoiceSplitsExtension invSplitExt = PXCache<InvoiceSplits>.GetExtension<InvoiceSplitsExtension>(invSplit);

    invSplitExt.UnitCost = artran.UnitCost;

    if (tran != null)
    {
        invSplitExt.UnitCost = split.UnitCost ?? tran.UnitCost;
    }

    return invSplit;
}

最后,您将需要将UnitCost字段添加到UI。为此,您需要进入自定义程序包,自定义SO301000屏幕,然后导航到树视图上的“对话框”->“对话框:添加发票明细”->“网格:invoiceSplits”。然后转到“添加数据字段”标签,选择您的UnitCost字段,然后单击创建控件。