Partial posting of purchase order in AX 2012

In my previous post
we created code to post product receipt via x++. 
Now this code would post the lines of the PO appropriately as per the quantity specified on the line , provided the ReceiveNow quantity on the purchParmLine is set appropriately. The inventory transfer would work fine for a normal item,with the deduction of the partial quantity alone from the ordered quantity. Yet when you have a serial number tracked or lot item , while creation of receipt say you do not enter the sl no or lot id , yet during posting if you have your lot ID /sl no (inserted through some process via an interfacing application)  you may face problems as the transactions would not have the batch number or serial number specified on them and in 2012 Axapta does all posting on the basis of transactions. (This may lead to negative inventory(ordered qty) against the particular sl no or lot ID.

So to make the whole thing work, you would need to split the transactions via some logic through code by calling the InventTrans.updateSplit method and then register the inventory with the transaction that you created via the split. The registering of inventory would make use of code from class InventTransWMS_Register, method updateInvent which would encompass this piece of code in particular:
 registered = InventUpd_Registered::newParameters(movement,inventDim,inventDimParm,inventDim,inventDimParm,_tmpInventTransWMS.InventQty, _tmpInventTransWMS.PdsCWQty);
      registered.parmSkipQualityOrderCreation(true);  // We handle quality order creation later in this method
      registered.parmInventReceiptForTestRegistrator(inventReceiptForTestRegistrator);

       if (movement.mustBeQuarantineControlled())
            {
                    registered.parmInventDimQuarantine(inventDimQuarantine);
            }

        if (_tmpInventTransWMS.InventTrans)
            {
                    inventTransPrefered = InventTrans::findRecId(_tmpInventTransWMS.InventTrans);
                    if (inventTransPrefered.RecId)
                    { // Only use if sign/direction matches specified quantity.
                        if ((_tmpInventTransWMS.InventQty > 0 && inventTransPrefered.StatusReceipt == StatusReceipt::Ordered)
                         || (_tmpInventTransWMS.InventQty < 0 && inventTransPrefered.StatusReceipt == StatusReceipt::Registered))
                        {
                            registered.parmPreferedInventTransRecId(_tmpInventTransWMS.InventTrans);
                        }
                    }
             }
        movement.parmPDSBaseValue(_tmpInventTransWMS.pdsBaseValue);

        if (inventDim.InventBatchId)
        {
                    registered.pdsSetBatchAttributeValue(inventDim.InventBatchId);
        }

        registered.updateNow();
        inventReceiptForTestRegistrator = registered.parmInventReceiptForTestRegistrator();
        if (inventDim.InventBatchId)
        {
                    inventBatch = InventBatch::find(inventDim.InventBatchId, _tmpInventTransWMS.ItemId, true);
                    inventBatch.pdsInitFromVendBatchDetails(_tmpInventTransWMS.bufferPdsVendBatchInfo());
                    inventBatch.update();
         }
         inventQtySumCW += _tmpInventTransWMS.PdsCWQty;

         inventQtySum += _tmpInventTransWMS.InventQty;

         if (inventReceiptForTestRegistrator)
         {
                InventQualityManagementCreateHandler::createInventoryRegistration(
                    inventTransOriginId,
                    inventReceiptForTestRegistrator);
         }


        if (inventTransWMSRegistrationObserver
            && inventQtySum)
        {
            inventTransWMSRegistrationObserver.notifyArrivalRegistered(inventQtySum, inventQtySumCW, inventDim);
        }

        _tmpInventTransWMS.ttscommit();



1 comment:

  1. Hi Help Me Out From Below Requirement,
    Consider two purchase orders created using same vendor
    Till Product receipt the process should be done functionally from front end.
    Now both of them should be invoiced with same invoice id through x++ code.
    Invoice should be done for only received quantity in two purchase orders.
    Could any one suggest me how to achieve this and also share your sample code.

    Thanks & Regards,
    Jagadeesh.V

    ReplyDelete