Acumatica CreateSalesPrice方法中的数据分配错误

Acumatica CreateSalesPrice方法中的数据分配错误,acumatica,acumatica-kb,Acumatica,Acumatica Kb,情况: 我必须在“供应商价格工作表”屏幕和“供应商价格”屏幕上为每个子项指定价格 当在供应商价格工作表中按下释放按钮时,必须在APVendorPrice表中创建APPriceWorksheetDetail表中的记录,显然,我必须将APPriceWorksheetDetail表的SubItemID字段值分配给APVendorPrice表的UsrSubItemID字段 注意事项: 没有必要在供应商价格工作表网格中创建SubItemID字段,因为它已经存在于Details dataview中 我在供应

情况:

我必须在“供应商价格工作表”屏幕和“供应商价格”屏幕上为每个子项指定价格

当在供应商价格工作表中按下释放按钮时,必须在APVendorPrice表中创建APPriceWorksheetDetail表中的记录,显然,我必须将APPriceWorksheetDetail表的SubItemID字段值分配给APVendorPrice表的UsrSubItemID字段

注意事项:

没有必要在供应商价格工作表网格中创建SubItemID字段,因为它已经存在于Details dataview中

我在供应商价格网格中创建了SubItemID字段,因为它在Records dataview中不存在

这是我的供应商价格工作表屏幕

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data;
using PX.Objects.Common;
using PX.Objects.Common.Extensions;
using PX.Objects.CS;
using PX.Objects.CM;
using PX.Objects.IN;
using PX.Objects.GL;
using PX.Api;
using PX.Objects;
using PX.Objects.AP;

namespace PX.Objects.AP
{
  public class APPriceWorksheetMaint_Extension : PXGraphExtension<APPriceWorksheetMaint>
  {
    #region Event Handlers
    public delegate APVendorPrice CreateSalesPriceDelegate(APPriceWorksheetDetail priceLine, Nullable<Boolean> isPromotional, Nullable<DateTime> effectiveDate, Nullable<DateTime> expirationDate);
    [PXOverride]
    public APVendorPrice CreateSalesPrice(APPriceWorksheetDetail priceLine, Nullable<Boolean> isPromotional, Nullable<DateTime> effectiveDate, Nullable<DateTime> expirationDate, CreateSalesPriceDelegate baseMethod)
    {
      APVendorPrice newSalesPrice = new APVendorPrice
        {
            VendorID = priceLine.VendorID,
            InventoryID = priceLine.InventoryID,
            UsrSubItemID = priceLine.SubItemID,
            SiteID = priceLine.SiteID,
            UOM = priceLine.UOM,
            BreakQty = priceLine.BreakQty,
            SalesPrice = priceLine.PendingPrice,
            CuryID = priceLine.CuryID,
            IsPromotionalPrice = isPromotional,
            EffectiveDate = effectiveDate,
            ExpirationDate = expirationDate,
        };

        return newSalesPrice;
    }

    #endregion
  }
}

这是我的供应商价格屏幕

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data;
using PX.Objects.Common;
using PX.Objects.Common.Extensions;
using PX.Objects.CS;
using PX.Objects.CM;
using PX.Objects.IN;
using PX.Objects.GL;
using PX.Api;
using PX.Objects;
using PX.Objects.AP;

namespace PX.Objects.AP
{
  public class APPriceWorksheetMaint_Extension : PXGraphExtension<APPriceWorksheetMaint>
  {
    #region Event Handlers
    public delegate APVendorPrice CreateSalesPriceDelegate(APPriceWorksheetDetail priceLine, Nullable<Boolean> isPromotional, Nullable<DateTime> effectiveDate, Nullable<DateTime> expirationDate);
    [PXOverride]
    public APVendorPrice CreateSalesPrice(APPriceWorksheetDetail priceLine, Nullable<Boolean> isPromotional, Nullable<DateTime> effectiveDate, Nullable<DateTime> expirationDate, CreateSalesPriceDelegate baseMethod)
    {
      APVendorPrice newSalesPrice = new APVendorPrice
        {
            VendorID = priceLine.VendorID,
            InventoryID = priceLine.InventoryID,
            UsrSubItemID = priceLine.SubItemID,
            SiteID = priceLine.SiteID,
            UOM = priceLine.UOM,
            BreakQty = priceLine.BreakQty,
            SalesPrice = priceLine.PendingPrice,
            CuryID = priceLine.CuryID,
            IsPromotionalPrice = isPromotional,
            EffectiveDate = effectiveDate,
            ExpirationDate = expirationDate,
        };

        return newSalesPrice;
    }

    #endregion
  }
}

这是我的APVendorPriceExtensions DAC

using PX.Data;
using PX.Objects.AP;
using PX.Objects.CM;
using PX.Objects.IN;
using PX.Objects.CS;
using PX.Objects;
using System.Collections.Generic;
using System;

namespace PX.Objects.AP
{
  public class APVendorPriceExt : PXCacheExtension<PX.Objects.AP.APVendorPrice>
  {
    #region UsrSubItemID
    [PXDefault(typeof(Search<InventoryItem.defaultSubItemID,
    Where<InventoryItem.inventoryID, Equal<Current<APVendorPrice.inventoryID>>,
    And<InventoryItem.defaultSubItemOnEntry, Equal<boolTrue>>>>),
    PersistingCheck = PXPersistingCheck.Nothing)]
    [PXFormula(typeof(Default<APVendorPrice.inventoryID>))]
    [SubItem(typeof(APVendorPrice.inventoryID))]
    public virtual int? UsrSubItemID { get; set; }
    public abstract class usrSubItemID : PX.Data.BQL.BqlInt.Field<usrSubItemID> { }
    #endregion
  }
}
使用PX.Data;
使用PX.Objects.AP;
使用PX.Objects.CM;
使用PX.Objects.IN;
使用PX.Objects.CS;
使用PX.Objects;
使用System.Collections.Generic;
使用制度;
命名空间PX.Objects.AP
{
公共类APVendorPriceExt:PXCacheExtension
{
#乌苏比特米地区
[PXDefault(类型)(搜索),
PersistingCheck=PXPersistingCheck.Nothing)]
[PXFormula(typeof(默认))]
[子项(类型(APVendorPrice.inventoryID))]
公共虚拟int?UsrSubItemID{get;set;}
公共抽象类usrSubItemID:PX.Data.BQL.BqlInt.Field{}
#端区
}
}
我在APPriceWorkSheetMain图中找到了分配值的方法,该方法名为CreateSalesPrice,我试图通过放置自定义UsrSubItemID字段来覆盖该方法,但我得到以下错误:“CS0117:'Apvendorpice'不包含'UsrSubItemID'的定义”

这是我的通知工作表main_分机

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data;
using PX.Objects.Common;
using PX.Objects.Common.Extensions;
using PX.Objects.CS;
using PX.Objects.CM;
using PX.Objects.IN;
using PX.Objects.GL;
using PX.Api;
using PX.Objects;
using PX.Objects.AP;

namespace PX.Objects.AP
{
  public class APPriceWorksheetMaint_Extension : PXGraphExtension<APPriceWorksheetMaint>
  {
    #region Event Handlers
    public delegate APVendorPrice CreateSalesPriceDelegate(APPriceWorksheetDetail priceLine, Nullable<Boolean> isPromotional, Nullable<DateTime> effectiveDate, Nullable<DateTime> expirationDate);
    [PXOverride]
    public APVendorPrice CreateSalesPrice(APPriceWorksheetDetail priceLine, Nullable<Boolean> isPromotional, Nullable<DateTime> effectiveDate, Nullable<DateTime> expirationDate, CreateSalesPriceDelegate baseMethod)
    {
      APVendorPrice newSalesPrice = new APVendorPrice
        {
            VendorID = priceLine.VendorID,
            InventoryID = priceLine.InventoryID,
            UsrSubItemID = priceLine.SubItemID,
            SiteID = priceLine.SiteID,
            UOM = priceLine.UOM,
            BreakQty = priceLine.BreakQty,
            SalesPrice = priceLine.PendingPrice,
            CuryID = priceLine.CuryID,
            IsPromotionalPrice = isPromotional,
            EffectiveDate = effectiveDate,
            ExpirationDate = expirationDate,
        };

        return newSalesPrice;
    }

    #endregion
  }
}
使用系统;
使用系统集合;
使用System.Collections.Generic;
使用System.Linq;
使用PX.Common;
使用PX数据;
使用PX.Objects.Common;
使用PX.Objects.Common.Extensions;
使用PX.Objects.CS;
使用PX.Objects.CM;
使用PX.Objects.IN;
使用PX.Objects.GL;
使用PX.Api;
使用PX.Objects;
使用PX.Objects.AP;
命名空间PX.Objects.AP
{
公共类通知工作表maint_扩展名:pxGrapherExtension
{
#区域事件处理程序
公共委托APVendorPrice CreateSalesPriceDelegate(通知工作表详细价格行、可为空的IsPromotion、可为空的生效日期、可为空的到期日期);
[PXOverride]
public APVendorPrice CreateSalesPrice(通知工作表详细价格线,可为空的IsPromotion,可为空的effectiveDate,可为空的expirationDate,可为空的CreateSalesPriceDelegate baseMethod)
{
APVendorPrice newSalesPrice=新APVendorPrice
{
VendorID=priceLine.VendorID,
InventoryID=priceLine.InventoryID,
UsrSubItemID=priceLine.SubItemID,
SiteID=priceLine.SiteID,
UOM=priceLine.UOM,
BreakQty=priceLine.BreakQty,
SalesPrice=priceLine.PendingPrice,
CuryID=priceLine.CuryID,
IsPromotionalPrice=IsPromotionalPrice,
生效日期=生效日期,
ExpirationDate=到期日期,
};
返回价格;
}
#端区
}
}

对此有什么建议吗?

您是否尝试使用以下方法?(通过扩展DAC更新):

APVendorPrice newsaleprice=新的APVendorPrice
{
VendorID=priceLine.VendorID,
InventoryID=priceLine.InventoryID,
SiteID=priceLine.SiteID,
UOM=priceLine.UOM,
BreakQty=priceLine.BreakQty,
SalesPrice=priceLine.PendingPrice,
CuryID=priceLine.CuryID,
IsPromotionalPrice=IsPromotionalPrice,
生效日期=生效日期,
ExpirationDate=到期日期,
};
var vendorPriceExt=PXCache.GetExtension(newSalesPrice);
vendorPriceExt.UsrSubItemID=priceLine.SubItemID;
返回价格;

我刚刚添加了这两行代码,效果非常好!!谢谢分享这些信息@JosephCaruana