Sunday, May 28, 2017

Inventory Marking X++

static void San_MarkInventTrans(InventTransId _inventTransId,InventTransId _refInventTransId,InventQty _qtyTomark)
{
    InventTrans             issueInventTrans;
    TmpInventTransMark      tmpInventTransMask;
    Map                     mapMarkNow;
    container               conget;
    real                    qty;
    Map                     mapMark;
    MapEnumerator           mapEnumerator;
    InventTransOriginId issueInventTransOriginId    = InventTransOrigin::findByInventTransId(_inventTransId).RecId;
    InventTransOriginId receiptInventTransOriginId  = InventTransOrigin::findByInventTransId(_refInventTransId).RecId;
    InventQty qtyToMark = _qtyTomark;
    ttsBegin;
    issueInventTrans = InventTrans::findByInventTransOrigin(issueInventTransOriginId);
    [conget, qty] = TmpInventTransMark::packTmpMark(
        InventTransOrigin::find(issueInventTransOriginId),
        issueInventTrans.inventDim(),
        issueInventTrans.Qty);
    mapMark = Map::create(conget);
    mapEnumerator = mapMark.getEnumerator();
    while (mapEnumerator.moveNext())
    {
        tmpInventTransMask = mapEnumerator.currentValue();
        if (tmpInventTransMask.InventTransOrigin == receiptInventTransOriginId)
        {
            tmpInventTransMask.QtyMarkNow = qtyToMark;
            tmpInventTransMask.QtyRemain -= tmpInventTransMask.QtyMarkNow;
            mapMarkNow = new Map(Types::Int64, Types::Record);
            mapMarkNow.insert(tmpInventTransMask.RecId, tmpInventTransMask);
            TmpInventTransMark::updateTmpMark(
                issueInventTransOriginId,
                issueInventTrans.inventDim(),
                -qtyToMark,
                mapMarkNow.pack());
        }
    }
    ttsCommit;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...