Ошибка распределения данных в методе CreateSalesPrice - PullRequest
0 голосов
/ 08 июля 2020

Ситуация:

Мне нужно назначить цену за подпункт как на экране Таблицы цен поставщиков, так и на экране цен поставщиков.

Когда кнопка разблокировки нажата в Продавце Таблицы цен, записи в таблице APPriceWorksheetDetail должны быть созданы в таблице APVendorPrice. Очевидно, мне нужно присвоить значение поля SubItemID таблицы APPriceWorksheetDetail полю UsrSubItemID таблицы APVendorPrice.

Примечания :

Не было необходимости создавать поле SubItemID в сетке Vendor Price Worksheets, потому что оно уже существует в окне данных Details.

Я создал поле SubItemID в сетке Vendor Price, потому что это не так. не существует в окне данных Records.

Это мой экран рабочих листов цен поставщика

enter image description here

This is my Vendor Prices screen

введите описание изображения здесь

Это мой APVendorPriceExtensions DA C

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
  }
}

Я нашел метод, который присваивает значения в графике APPriceWorkSheetMain, метод называется CreateSalesPrice, Я пытаюсь переопределить этот метод, помещая свое настраиваемое поле UsrSubItemID, но получаю следующую ошибку: «CS0117: 'APVendorPrice' не содержит определения для 'UsrSubItemID'».

Это мое APPriceWorkSheetMain_Extension

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
  }
}

Есть какие-нибудь советы по этому поводу?

1 Ответ

1 голос
/ 09 июля 2020

Вы пробовали использовать следующий подход? (обновление через расширение DA C):

  APVendorPrice newSalesPrice = new APVendorPrice
        {
            VendorID = priceLine.VendorID,
            InventoryID = priceLine.InventoryID,            
            SiteID = priceLine.SiteID,
            UOM = priceLine.UOM,
            BreakQty = priceLine.BreakQty,
            SalesPrice = priceLine.PendingPrice,
            CuryID = priceLine.CuryID,
            IsPromotionalPrice = isPromotional,
            EffectiveDate = effectiveDate,
            ExpirationDate = expirationDate,
        };

        var vendorPriceExt = PXCache<APVendorPrice>.GetExtension<APVendorPriceExt>(newSalesPrice);
        vendorPriceExt.UsrSubItemID = priceLine.SubItemID;

        return newSalesPrice;
...