Hi Experts,
I need to modify the logic in the code below to avoid creating a new license plate. Instead, I want to receive the quantity into the same license plate that was shipped in the transfer order. I attempted to achieve this by extending the WhsWorkExecuteDisplayTOReceiving class and overriding the createWork() method. However, the system still creates a new target license plate due to standard behavior.
Can anyone advise if this requirement can be fulfilled through extensions, or if a different approach is needed?
protected WHSWorkBuildId createWork(InventTransferLine _transferLine)
{
WHSLicensePlate licensePlate = WHSLicensePlate::createLicensePlate(pass.lookup(#LicensePlateId), true, this.getDefaultContainerTypeCode());
WHSWorkCreateTransferLine workCreateTransferLine = new WHSWorkCreateTransferLine(_transferLine);
workCreateTransferLine.parmInventQty(WHSCatchWeightHelper::convertInventQuantity(pass.lookup(#ItemId), pass.lookup(#CurrentUOM), pass.lookupNum(#CurrentQty), _transferLine.InventDimId));
WHSTransWeight calcCatchWeight;
boolean isCWItem = PdsGlobal::pdsIsCWItem(_transferLine.ItemId);
if (isCWItem)
{
InventHandlingQty totalReceiptQty = WHSCatchWeightHelper::convertInventQuantity(pass.lookup(#ItemId), pass.lookup(#UOM), pass.lookupNum(#Qty), _transferLine.InventDimId);
if (WHSDeferredPOReceivingHandleCatchWeightFlight::instance().isEnabled())
{
calcCatchWeight = WHSCatchWeightHelper::calculateCatchWeightAndUpdatePass(_transferLine.ItemId, workCreateTransferLine.parmInventQty(), totalReceiptQty, pass);
}
else
{
if (WHSInventTable::shouldCaptureAggregateWeight(_transferLine.ItemId))
{
calcCatchWeight = WHSCatchWeightHelper::calculateAverageWeight(workCreateTransferLine.parmInventQty(),
totalReceiptQty - pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum),
pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeight) - pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightWeightSum),
InventTable::inventDecimals(_transferLine.ItemId));
}
else
{
// If not capturing aggregate weight use work creation handling quantity rounded to correct decimal precision.
calcCatchWeight = WHSCatchWeightHelper::calculateAverageWeight(workCreateTransferLine.parmInventQty(),
workCreateTransferLine.parmInventQty(),
pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeight),
InventTable::inventDecimals(_transferLine.ItemId));
pass.remove(WHSWorkExecuteDisplayCatchWeightControls::CatchWeight);
}
if (workCreateTransferLine.parmInventQty() != (totalReceiptQty - pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum)))
{
pass.insert(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum, pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightQtySum) + workCreateTransferLine.parmInventQty());
pass.insert(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightWeightSum, pass.lookupNum(WHSWorkExecuteDisplayCatchWeightControls::CatchWeightWeightSum) + calcCatchWeight);
}
}
}
// Auto Generate catch weight tag records based on configs
if (isCWItem
&& WHSInventTable::isCatchWeightTagTracked(_transferLine.ItemId)
&& WHSInventTable::shouldCaptureAggregateWeight(_transferLine.ItemId)
&& WHSRFMenuItemTable::find(pass.lookup(#MenuItem)).GenerateCatchWeightTag)
{
WHSCatchWeightTagCreationSource tagSource = WHSCatchWeightTagCreationSource::instantiateFromSource(_transferLine, pass);
WHSCatchWeightTagCreationMethod tagMethod = WHSCatchWeightTagCreationMethod::newAutoTagCreation(workCreateTransferLine.parmInventQty(), calcCatchWeight);
WHSCatchWeightTagCreator tagCreator = WHSCatchWeightTagCreator::construct();
this.trackAutoGeneratedCatchWeightTags(tagCreator.createCatchWeightTags(tagSource, tagMethod));
}
workCreateTransferLine.parmCreatedBy(userId);
workCreateTransferLine.parmInventTransferLine(_transferLine);
workCreateTransferLine.parmUnitization(pass.lookup(#Unitization));
workCreateTransferLine.parmTargetLicensePlateId(licensePlate.LicensePlateId);
workCreateTransferLine.parmWorkTemplateCode(WHSRFMenuItemTable::find(pass.lookup(#MenuItem)).WorkTemplateCode);
workCreateTransferLine.parmDispositionCode(pass.lookupStr(#Disposition));
workCreateTransferLine.parmReceiptId(pass.parmReceiptId());
WHSWorkBuildId workBuildId = workCreateTransferLine.createWork();
if (isCWItem && pass.exists(WHSWorkExecuteDisplayCatchWeightControls::ScannedCatchWeightTagList))
{
WHSCatchWeightTagLastRegistration::updateCatchWeightTagRegistrationWorkLine(str2con(pass.lookupStr(WHSWorkExecuteDisplayCatchWeightControls::ScannedCatchWeightTagList)),
WHSWorkTable::findSingleInboundWorkByWorkBuildId(workBuildId).WorkId);
}
return workBuildId;
}