Sometimes we need to post sales invoice with selected lines below is the code:
SalesFormLetter salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
SalesTable salesTAble;
SalesParmLine parmLine;
SalesLine salesline;
salesTable = SalesTable::find('AU-027333');
salesFormLetter.salesTable(salesTAble);
salesFormLetter.transDate (systemDateGet());
salesFormLetter.specQty (SalesUpdate::All);
//If you want proforma you can enable the code
salesFormLetter.proforma (true);
salesFormLetter.printFormLetter (true);
salesFormLetter.createParmUpdateFromParmUpdateRecord(salesFormLetter.salesParmUpdate());
salesFormLetter.initParmSalesTable(salesTAble);
salesFormLetter.initParameters(salesFormLetter.salesParmUpdate(),Printout::After);
salesFormLetter.initLinesQuery();
while select forUpdate parmLine where parmLine.ParmId == salesFormLetter.parmId()
{
salesLine = salesline::findInventTransId(parmLine.InventTransId);
if (salesline.ShippingDateRequested > today())
{
ttsBegin;
parmLine.delete();
ttsCommit;
}
}