PurchTable purchTableLoc;
PurchLine purchLineLoc;
InventTrans inventTransLoc;
InventTransOrigin inventTransOriginLoc;
ttsBegin;
purchTableLoc = PurchTable::find(_purchId, true);
if (purchTable != null)
{
while select forupdate * from purchLineLoc
where purchLineLoc.PurchId == purchTableLoc.PurchId
&& purchLineLoc.PurchStatus == PurchStatus::Backorder
join inventTransLoc
exists join inventTransOriginLoc
where inventTransOriginLoc.RecId == inventTransLoc.InventTransOrigin
&& inventTransOriginLoc.InventTransId == purchLineLoc.InventTransId
{
// to check the purch lines are not received
if(inventTrans.StatusReceipt == StatusReceipt::Ordered)
{
purchLineLoc.RemainInventPhysical = 0.00;
purchLineLoc.RemainPurchPhysical = 0.00;
purchLineLoc.reread();
purchLineLoc.update();
InventMovement::bufferSetRemainQty(purchLineLoc);
}
}
purchTableLoc.PurchStatus = PurchStatus::Canceled;
purchTableLoc.update();
}
ttsCommit;