[ExtensionOf(classStr(InventSumCriticalInit))]
final public class SFA_InventSumCriticalInit_Extension
{
public void processInventSumCriticalRecords()
{
next processInventSumCriticalRecords();
QueryRun queryRun = new QueryRun(this.criticalOnHandQuery);
ReqItemTable reqItemTable;
InventDim inventDim;
ItemId itemId;
InventDimParm inventDimParm;
InventDimGroupSetup inventDimGroupSetup;
ReqSetup reqSetup;
while (queryRun.next())
{
if (queryRun.changed(tableNum(ReqItemTable)))
{
reqItemTable = queryRun.get(tableNum(ReqItemTable));
if (itemId != reqItemTable.ItemId)
{
itemId = reqItemTable.ItemId;
reqSetup = ReqSetup::newItemId(itemId);
inventDimGroupSetup = InventDimGroupSetup::newItemId(itemId);
inventDimParm.initCovPrDimension(inventDimGroupSetup);
}
}
inventDim = queryRun.get(tableNum(InventDim));
// Custom logic to include maximum quantity
this.insertPhysicalOnhandBelowMinimumQuantity_Extended(
reqSetup,
itemId,
inventDim,
inventDimParm,
inventDimGroupSetup);
}
}
private void insertPhysicalOnhandBelowMinimumQuantity_Extended(
ReqSetup _reqSetup,
ItemId _itemId,
InventDim _inventDim,
InventDimParm _inventDimParm,
InventDimGroupSetup _inventDimGroupSetup)
{
InventDim inventDimCoverage = InventDim::find(_inventDim.reqCovDimId(_inventDimGroupSetup));
InventQtyMaxOnhand maximumOnHandQuantity = ReqSetupDim::newCovInventDimId(_reqSetup, inventDimCoverage.InventDimId).maxInventOnHand(); // Fetch max quantity
this.initTmpTable_Extended(maximumOnHandQuantity);
this.insertTmpTable();
}
protected void initTmpTable_Extended(InventQtyMaxOnhand _maximumOnHandQuantity) // Add max quantity parameter
{
inventSumCriticalTmp.QtyMaxOnhand = _maximumOnHandQuantity; // Store max quantity
}
}
[ExtensionOf(classStr(InventSumCriticalInit))]
final public class SFA_InventSumCriticalInit_Extension
{
public void processInventSumCriticalRecords()
{
next processInventSumCriticalRecords();
QueryRun queryRun = new QueryRun(this.criticalOnHandQuery);
ReqItemTable reqItemTable;
InventDim inventDim;
ItemId itemId;
InventDimParm inventDimParm;
InventDimGroupSetup inventDimGroupSetup;
ReqSetup reqSetup;
while (queryRun.next())
{
if (queryRun.changed(tableNum(ReqItemTable)))
{
reqItemTable = queryRun.get(tableNum(ReqItemTable));
if (itemId != reqItemTable.ItemId)
{
itemId = reqItemTable.ItemId;
reqSetup = ReqSetup::newItemId(itemId);
inventDimGroupSetup = InventDimGroupSetup::newItemId(itemId);
inventDimParm.initCovPrDimension(inventDimGroupSetup);
}
}
inventDim = queryRun.get(tableNum(InventDim));
// Custom logic to include maximum quantity
this.insertPhysicalOnhandBelowMinimumQuantity_Extended(
reqSetup,
itemId,
inventDim,
inventDimParm,
inventDimGroupSetup);
}
}
private void insertPhysicalOnhandBelowMinimumQuantity_Extended(
ReqSetup _reqSetup,
ItemId _itemId,
InventDim _inventDim,
InventDimParm _inventDimParm,
InventDimGroupSetup _inventDimGroupSetup)
{
InventDim inventDimCoverage = InventDim::find(_inventDim.reqCovDimId(_inventDimGroupSetup));
InventQtyMinOnhand minimumOnHandQuantity = ReqSetupDim::newCovInventDimId(_reqSetup, inventDimCoverage.InventDimId).minInventOnHand();
InventQtyMaxOnhand maximumOnHandQuantity = ReqSetupDim::newCovInventDimId(_reqSetup, inventDimCoverage.InventDimId).maxInventOnHand(); // Fetch max quantity
InventSum inventSumOnHand = InventOnHandQty::newItemDim(_itemId, inventDimCoverage, _inventDimParm).inventSum();
if (inventSumOnHand.physicalInventCalculated() < minimumOnHandQuantity)
{
this.initTmpTable_Extended(inventSumOnHand, _inventDim, minimumOnHandQuantity, maximumOnHandQuantity);
this.insertTmpTable();
}
}
protected void initTmpTable_Extended(
InventSum _inventSumOnHand,
InventDim _inventDim,
InventQtyMinOnhand _minimumOnHandQuantity,
InventQtyMaxOnhand _maximumOnHandQuantity) // Add max quantity parameter
{
InventIAvailability inventAvailability = InventAvailabilityProvider::findBySumDim(_inventSumOnHand, _inventDim).parmInventAvailability();
inventSumCriticalTmp.QtyMinOnhand = _minimumOnHandQuantity;
inventSumCriticalTmp.QtyMaxOnhand = _maximumOnHandQuantity; // Store max quantity
inventSumCriticalTmp.ItemId = _inventSumOnHand.ItemId;
inventSumCriticalTmp.InventDimFieldsMap::initAllDimensionsFrom(_inventDim);
inventSumCriticalTmp.Ordered = inventAvailability.ordered();
inventSumCriticalTmp.ItemName = _inventSumOnHand.itemName();
inventSumCriticalTmp.PhysicalInvent = _inventSumOnHand.physicalInventCalculated();
}
}
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156