Sunday, May 28, 2017

AX partial Purchase Order Product receipt

static void AXpartialPurchaseOrder(Args _args)
{
    PurchFormLetter             purchFormLetter;
    PurchFormletterParmData     purchFormLetterParmData;
    PurchParmUpdate             purchParmUpdate;
    PurchParmTable              purchParmTable;
    PurchParmLine               purchParmLine;
    PurchTable                  purchTable;
    PurchLine                   purchLine;
    ;
    ttsBegin;
    while select purchTable where purchTable.PurchId == "00000258"
    {
        purchFormLetterParmData = PurchFormletterParmData::newData(
             DocumentStatus::PackingSlip,
            VersioningUpdateType::Initial);
        purchFormLetterParmData.parmOnlyCreateParmUpdate(true);
        purchFormLetterParmData.createData(false);
        purchParmUpdate = purchFormLetterParmData.parmParmUpdate();
        purchParmTable.clear();
        purchParmTable.TransDate                = SystemDateGet();
        purchParmTable.Ordering                 = DocumentStatus::PackingSlip;
        purchParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
        purchParmTable.Num                      = "TestP1";
        purchParmTable.PurchId                  = purchTable.PurchId;
        purchParmTable.PurchName                = purchTable.PurchName;
        purchParmTable.DeliveryName             = purchTable.DeliveryName;
        purchParmTable.DeliveryPostalAddress    = purchTable.DeliveryPostalAddress;
        purchParmTable.OrderAccount             = purchTable.OrderAccount;
        purchParmTable.CurrencyCode             = purchTable.CurrencyCode;
        purchParmTable.InvoiceAccount           = purchTable.InvoiceAccount;
        purchParmTable.ParmId                   = purchParmUpdate.ParmId;
        purchParmTable.insert();
        while select purchLine
            where purchLine.PurchId == purchTable.PurchId
        {
            purchParmLine.clear();
            purchParmLine.InitFromPurchLine(purchLine);
            purchParmLine.ReceiveNow    = purchLine.PurchQty;
            purchParmLine.ParmId        = purchParmTable.ParmId;
            purchParmLine.TableRefId    = purchParmTable.TableRefId;
            purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
            purchParmLine.setLineAmount();
            purchParmLine.insert();
        }
        purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
        purchFormLetter.transDate(systemDateGet());
        purchFormLetter.proforma(false);
        purchFormLetter.specQty(PurchUpdate::All);
        purchFormLetter.purchTable(purchTable);
        purchFormLetter.parmParmTableNum(purchParmTable.ParmId);
        purchFormLetter.parmId(purchParmTable.ParmId);
        purchFormLetter.purchParmUpdate(purchFormLetterParmData.parmParmUpdate());
        purchFormLetter.run();
    }
    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...