Helper class for shippment validation how to create it with infolog
/// <summary>
/// Helper class for Loads
/// </summary>
public class WHSInboundShipmentHelper_POR
{
// POR_2784_inboundShipmentConfirmation:26/11/2024 : VK: 26/11/2024 Start
/// <summary>
/// validate the conditions before inbound shipment process.
/// </summary>
/// <param name="_loadTable">
/// WHSLoadTable Table as a refernce.
/// </param>
/// <returns>
/// return true or False .
/// </returns>
public static boolean validateInboundShipment_POR(List _loadIdList)
{
boolean ret = true;
ListEnumerator loadIdEnumerator;
WHSLoadId loadId;
WHSLoadTable loadTable;
loadIdEnumerator = _loadIdList.getEnumerator();
infolog.clear();
while (loadIdEnumerator.moveNext())
{
loadTable = WHSLoadTable::find(loadIdEnumerator.current());
if(!WHSInboundShipmentHelper_POR::validatePackingStructure_POR(loadTable))
{
ret = false;
}
else if(!WHSInboundShipmentHelper_POR::validateLicensePlate_POR(loadTable))
{
ret = false;
}
else if(!WHSInboundShipmentHelper_POR::validateWorkProcessPercent_POR(loadTable))
{
ret = false;
}
}
return ret;
}
protected static boolean validatePackingStructure_POR(WHSLoadTable _loadTable)
{
WHSUOMStructure whsUOMStructure;
boolean ret = true;
select firstonly LoadId from whsUOMStructure
where whsUOMStructure.LoadId == _loadTable.LoadId;
if(!whsUOMStructure.LoadId)
{
ret = checkFailed(strFmt("@POR:POR_2784_inboundShipmentConfirmation001",_loadTable.LoadId));
}
return ret;
}
protected static boolean validateLicensePlate_POR(WHSLoadTable _loadTable)
{
WHSUOMStructure whsUOMStructure;
WHSUOMStructureReceipt uomStructureReceipt;
boolean ret = true;
select firstonly LoadId,LicensePlateId from whsUOMStructure
where whsUOMStructure.LoadId == _loadTable.LoadId
notexists join uomStructureReceipt
where uomStructureReceipt.UOMStructure == whsUOMStructure.RecId;
if(whsUOMStructure.LoadId)
{
ret = checkFailed(strFmt("@POR:POR_2784_inboundShipmentConfirmation002", whsUOMStructure.LicensePlateId, _loadTable.LoadId));
}
return ret;
}
protected static boolean validateWorkProcessPercent_POR(WHSLoadTable _loadTable)
{
WHSLoadLine loadLine;
WHSWorkLine workLine;
int totalLines;
int totalCompleted;
real calculatePercentage;
boolean ret = true;
while select WorkStatus, count(RecId) from workLine
group by WorkStatus
where workLine.LoadId == _loadTable.LoadId
&& workLine.ShipmentId != ''
exists join loadLine
where (!workLine.LoadLineRefRecId || loadLine.RecId == workLine.LoadLineRefRecId)
&& loadLine.ShipmentId == workLine.ShipmentId
&& loadLine.LoadId == _loadTable.LoadId
{
if (workLine.WorkStatus != WHSWorkStatus::Cancelled)
{
totalLines += workLine.RecId;
}
if (workLine.WorkStatus == WHSWorkStatus::Closed
|| workLine.WorkStatus == WHSWorkStatus::Combined)
{
totalCompleted += workLine.RecId;
}
}
if (totalLines)
{
calculatePercentage = totalCompleted * 100 / totalLines;
if(calculatePercentage != 100)
{
ret = checkFailed(strFmt("@POR:POR_2784_inboundShipmentConfirmation003", _loadTable.LoadId));
}
}
else
{
ret = checkFailed(strFmt("@POR:POR_2784_inboundShipmentConfirmation004", _loadTable.LoadId));
}
return ret;
}
public static str getInfoLogMessages_POR()
{
SysInfologEnumerator sysInfologEnumerator;
SysInfologMessageStruct infoMessageStruct;
str logMessage;
const str NewLine = '\n';
sysInfologEnumerator = SysInfologEnumerator::newData(infolog.export());
while (sysInfologEnumerator.moveNext())
{
int i = 1;
if (logMessage)
{
logMessage += Newline;
}
infoMessageStruct = SysInfologMessageStruct::construct(sysInfologEnumerator.currentMessage());
while (i <= infoMessageStruct.prefixDepth())
{
logMessage += infoMessageStruct.preFixTextElement(i) + '. ';
i++;
}
logMessage += infoMessageStruct.message();
}
return logMessage;
}
public static List getLoadIdsFromDataSource(FormDataSource _whsLoadTableDS)
{
List loadIdList;
WHSLoadTable loadTable;
loadIdList = new List(Types::String);
for (loadTable = _whsLoadTableDS.getFirst(true) ? _whsLoadTableDS.getFirst(true) : _whsLoadTableDS.cursor();
loadTable;
loadTable = _whsLoadTableDS.getNext())
{
loadIdList.addEnd(loadTable.LoadId);
}
return loadIdList;
}
}
Comments
Post a Comment