Tuesday, June 27, 2017

X++ code to create Purchase Order Invoice

X++ Code to Post the Purchase Order Invoice.

 

Following Job post the invoice by using PurchFormLetter class.

static void CreatePOInvoice(Args _args)
{

    PurchFormLetter purchFormLetter;
    PurchTable          PurchTable;
    ttsbegin;
   PurchTable = PurchTable::find('PO-Demo');
   purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
   purchFormLetter.update(purchtable, // Purchase record Buffer
                           "Inv_"+purchTable.PurchId, // Invoice Number
                             systemdateget()); // Transaction date
ttscommit;
if (PurchTable::find(purchTable.PurchId).DocumentStatus ==           DocumentStatus::Invoice)
{
    info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
}
}

Now run the CreatePOInvoice job.

No comments:

Post a Comment