//Loops on inventory transactions of Reserved and Reserved ordered and unreserves them
while select inventTrans
where inventTrans.StatusReceipt == StatusReceipt::None
&& (inventTrans.StatusIssue == StatusIssue::ReservPhysical
|| inventTrans.StatusIssue == StatusIssue::ReservOrdered)
&& inventTrans.ItemId == itemId
exists join inventTransOrigin
where inventTransOrigin.RecId == inventTrans.InventTransOrigin
exists join salesLine
where salesLine.InventTransId == inventTransOrigin.InventTransId
{
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();
}
}