public override void Initialize()
{
base.Initialize();
PXCache cacheBase = Base.Caches[typeof(INLotSerialStatusByCostCenter)];
cacheBase.Interceptor = new BZAccumulatorAttribute();
}public class BZAccumulatorAttribute : PX.Objects.IN.InventoryRelease.Accumulators.QtyAllocated.LotSerialStatusByCostCenter.AccumulatorAttribute
{
public BZAccumulatorAttribute() : base()
{
_SingleRecord = true;
}
protected override bool PrepareInsert(PXCache cache, object row, PXAccumulatorCollection columns)
{
bool ret = base.PrepareInsert(cache, row, columns);
SiteStatusByCostCenter siteStatusByCostCenter = (SiteStatusByCostCenter)row;
InventoryItem item = InventoryItem.PK.Find(cache.Graph, siteStatusByCostCenter.InventoryID);
if (item != null)
{
BZInventoryItemExt itemExt = item.GetExtension<BZInventoryItemExt>();
if (siteStatusByCostCenter.SkipQtyValidation != true && siteStatusByCostCenter.ValidateHardAvailQtyForAdjustments == true && siteStatusByCostCenter.QtyHardAvail < itemExt.UsrBZThresholdQty)
{
columns.AppendException(string.Empty, new PXAccumulatorRestriction<PX.Objects.IN.INSiteStatusByCostCenter.qtyHardAvail>(PXComp.GE, itemExt.UsrBZThresholdQty));
ret = false;
}
}
return ret;
}}In LotSerialStatusByCostCenter Accumulator Attribute PrepareInsert method, there is code like if (diff.QtyOnHand < 0m) columns.Restrict<qtyOnHand>(PXComp.GE, -diff.QtyOnHand);. I want to override it and add a check (for example, if qty < 10, throw an error). How does it throw an error when qty < 0 if ‘Allow Negative’ is not enabled? I want to do this on the Invoice screen. How can I do this?