Hi All.
The below Job creates the Sales order from X++ code and post the invoice by making use of SalesFormLetter class.
static void CreateSalesOrder_and_Invoice(Args _args)
{
NumberSeq numberSeq;
SalesTable salesTable;
SalesLine salesLine;
SalesFormLetter salesFormLetter;
;
ttsbegin;
numberSeq = NumberSeq::newGetNumFromCode(salesParameters::numRefSalesId().NumberSequence,true);
// Initialize Sales order values
salesTable.initValue();
salesTable.SalesId = numberSeq.num();
salesTable.CustAccount = '3001';
salesTable.initFromCustTable();
if (!salesTable.validateWrite())
{
throw Exception::Error;
}
salesTable.insert();
// Initialize Sales Line items
salesLine.SalesId = salesTable.SalesId;
salesLine.ItemId = '1101';
salesLine.createLine(true, true, true, true, true, false);
ttscommit;
salesFormLetter = salesFormLetter::construct(DocumentStatus::Invoice);
//Pass the salesTable buffer to the update method.Also you can pass optional parameters to the update method based on your need.
salesFormLetter.update(salesTable);
if(SalesTable::find(salesTable.salesId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt("Posted invoiced journal for Sales order %1",salesTable.SalesId));
}
}
Nice blog. Very useful.
ReplyDeleteThanks
How do i create a payment and settle this invoice in x++ (AX4)
ReplyDeleteOne more useful website to learn tally....Tally Training
ReplyDeleteHalo,I'm Helena Julio from Ecuador,I want to talk good about Le_Meridian Funding Service on this topic.Le_Meridian Funding Service gives me financial support when all bank in my city turned down my request to grant me a loan of 500,000.00 USD, I tried all i could to get a loan from my banks here in Ecuador but they all turned me down because my credit was low but with god grace I came to know about Le_Meridian so I decided to give a try to apply for the loan. with God willing they grant me loan of 500,000.00 USD the loan request that my banks here in Ecuador has turned me down for, it was really awesome doing business with them and my business is going well now. Here is Le_Meridian Funding Investment Email/WhatsApp Contact if you wish to apply loan from them.Email:lfdsloans@lemeridianfds.com / lfdsloans@outlook.comWhatsApp Contact:+1-989-394-3740.
ReplyDelete