InventTrans inventTrans;
InventTransOrigin inventTransOrigin;
SalesLine salesLine;
InventMovement inventMovement;
InventUpd_Reservation inventUpd_Reservation ;
SalesId SalesId = "TesSo0001";//get sales id
// Remove reservations and markings on a reserved salesorder
while select inventTrans
where inventTrans.StatusReceipt == StatusReceipt::None
&& (inventTrans.StatusIssue == StatusIssue::ReservPhysical
|| inventTrans.StatusIssue == StatusIssue::ReservOrdered)
exists join inventTransOrigin
where inventTransOrigin.RecId == inventTrans.InventTransOrigin
exists join salesLine
where salesLine.InventTransId == inventTransOrigin.InventTransId
&& SalesLine.SalesId == SalesId
{
if (inventTrans.MarkingRefInventTransOrigin)
{
InventTransOrigin::deleteMarking(inventTrans.MarkingRefInventTransOrigin, inventTrans.InventTransOrigin, -inventTrans.Qty, true);
InventTransOrigin::deleteMarking(inventTrans.InventTransOrigin, inventTrans.MarkingRefInventTransOrigin, inventTrans.Qty, true);
}
if (inventTrans.StatusIssue == StatusIssue::ReservPhysical || inventTrans.StatusIssue == StatusIssue::ReservOrdered)
{
Inventmovement = inventTrans.inventmovement(true);
inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement,inventTrans.inventDim(), -1 * inventTrans.Qty, false);
inventUpd_Reservation.updatenow();
}
}
}
Comments