How to create only one invoice for several purchase orders in DAX012

Category: Stories Post Date: 29.05.2015

How to create only one invoice for several purchase orders in DAX012.

//Create Purchase Parameter Lines for one of the purchases:
purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.purchTable(purchTable);
purchFormLetter.specQty(PurchUpdate::ALL);
purchFormLetter.chooseLines(true);

//Use the standard code that adds purchases to invoice
purchFormLetterInvoiceContract  = purchFormLetter.getPurchFormLetterContract();
purchParmUpdate = purchFormLetterInvoiceContract.parmParmUpdate();
select firstOnly forUpdate vendInvoiceInfoTable
where vendInvoiceInfoTable.ParmId == purchParmUpdate.ParmId;

//delete all of the vendInvoiceInfoLine
delete_from vendInvoiceInfoLine
where vendInvoiceInfoLine.ParmId == _vendInvoiceInfoTable.ParmId;

purchSelectLinesManager = PurchSelectLinesManager::newPurchSelectLinesManager(_vendInvoiceInfoTable.TableRefId);
purchSelectLinesManager.parmPurchTableMark(parmPurchTableMark);
purchSelectLinesManager.parmPurchLineMark(parmPurchLineMark);
purchSelectLinesManager.parmParmId(_vendInvoiceInfoTable.ParmId);
purchSelectLinesManager.lukParmBuildQuery(false);//additional parameter, it disables query creation
purchSelectLinesManager.init();

while select purchLine
..where //your filters
{
purchSelectLinesManager.mark('', purchLine.RecId, purchLine, true, NoYes::No, true);
}
purchSelectLinesManager.passSets(_purchFormLetter);

purchFormLetter.reArrangeNow(false);//it's very important to make this parameter false
purchFormLetter.run();

Leave a Reply


AllEscort