Showing posts with label Invoice. Show all posts
Showing posts with label Invoice. Show all posts

Tuesday, June 27, 2017

Create/Post Sales order Invoice through x++

Hi,

Today i am going to show you how to create/post sales order invoice in x++

static void createPostSalesOrderInvoice(Args _args)
{
        SalesFormLetter salesFormLetter;
        salesFormLetter=SalesFormLetter::construct(DocumentStatus::Invoice);
       salesFormLetter.update(SalesTable::find('SO-ASC0001'));
       info(strFmt("%1 Sales Order Posted and Final Status is Invoiced",salesTable.SalesId));
}

now run this job

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.