Hi All,
Below is the code to mark sales line with correspond Purch line. I used this for completing the marking for migrated purchase line.
X++ Code
/// <summary>
/// Mark sales line with purch line
/// </summary>
/// <param name = "_issueInventTransId">SalesLine inventrans Recid</param>
/// <param name = "_receiptInventTransId">PurchLine inventtrans RecId</param>
public static void completeInventMarking(InventTransId _issueInventTransId, InventTransId _receiptInventTransId)
{
InventTransId issueInventTransId = _issueInventTransId;
InventTransId receiptInventTransId = _receiptInventTransId;
TmpInventTransMark tmpInventTransMark;
Map mapUpdated;
InventTransOriginId receiptInventTransOriginId = InventTransOrigin::findByInventTransId(receiptInventTransId).RecId;
InventTrans receiptInventTrans = InventTrans::findByInventTransOrigin(receiptInventTransOriginId);
InventTransOriginId issueInventTransOriginId = InventTransOrigin::findByInventTransId(issueInventTransId).RecId;
InventTrans issueInventTrans = InventTrans::findByInventTransOrigin(issueInventTransOriginId);
InventTransMarkCollection collection = TmpInventTransMark::markingCollection( InventTransOrigin::find(receiptInventTransOriginId),receiptInventTrans.inventDim(), receiptInventTrans.Qty);
collection.insertCollectionToTmpTable(tmpInventTransMark);
select firstonly tmpInventTransMark
where tmpInventTransMark.InventTransOrigin == issueInventTrans.InventTransOrigin && tmpInventTransMark.InventDimId == issueInventTrans.InventDimId;
if (tmpInventTransMark.RecId != 0)
{
Qty qtyToMark = issueInventTrans.Qty;
tmpInventTransMark.QtyMarkNow = qtyToMark;
tmpInventTransMark.QtyRemain -= tmpInventTransMark.QtyMarkNow;
mapUpdated = new Map(Types::Int64, Types::Record);
mapUpdated.insert(tmpInventTransMark.RecId, tmpInventTransMark);
TmpInventTransMark::updateTmpMark(
receiptInventTransOriginId,
receiptInventTrans.inventDim(),
-qtyToMark,
mapUpdated.pack());
}
}
No comments:
Post a Comment