TmpFrmVirtual tmpFrmVirtualVend;
PurchFormLetter_Invoice purchFormLetter;
VendPackingSlipJour vendPackingSlipJour;
SysQueryRun chooseLinesQuery;
SysQueryRun chooseLinesPendingInvoiceQuery;
container conTmpFrmVirtual;
List selectedList = new List(Types::Record);
while select TableId, RecId, PurchId from vendPackingSlipJour
where vendPackingSlipJour.PurchId == _purchTable.PurchId
{
tmpFrmVirtualVend.clear();
tmpFrmVirtualVend.TableNum = vendPackingSlipJour.TableId;
tmpFrmVirtualVend.RecordNo = vendPackingSlipJour.RecId;
tmpFrmVirtualVend.NoYes = NoYes::Yes;
tmpFrmVirtualVend.Id = vendPackingSlipJour.PurchId;
tmpFrmVirtualVend.insert();
}
chooseLinesQuery = new SysQueryRun(queryStr(PurchUpdate));
chooseLinesQuery.query().addDataSource(tableNum(VendInvoiceInfoTable)).enabled(false);
//chooseLinesPendingInvoiceQuery needs to be initialized, although it will not be used
chooseLinesPendingInvoiceQuery = new SysQueryRun(queryStr(PurchUpdatePendingInvoice));
chooseLinesPendingInvoiceQuery.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable,PurchId)).value(queryValue(''));
purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.chooseLinesQuery (chooseLinesQuery);
purchFormLetter.parmQueryChooseLinesPendingInvoice(chooseLinesPendingInvoiceQuery);
purchFormLetter.purchTable (_purchTable);
purchFormLetter.transDate (DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
purchFormLetter.parmParmTableNum (invoiceId);
purchFormLetter.printFormLetter (NoYes::No);
purchFormLetter.sumBy (AccountOrder::Auto);
purchFormLetter.specQty (PurchUpdate::All);
while select tmpFrmVirtualVend
{
selectedList.addEnd(tmpFrmVirtualVend);
conTmpFrmVirtual = selectedList.pack();
}
purchFormLetter.selectFromJournal(conTmpFrmVirtual);
VendInvoiceInfoTable vendInvoiceInfoTable;
select forupdate vendInvoiceInfoTable
where vendInvoiceInfoTable.ParmId == purchFormLetter.parmId()
&& vendInvoiceInfoTable.PurchId == _purchTable.PurchId;
if(vendInvoiceInfoTable)
{
vendInvoiceInfoTable.DocumentDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
vendInvoiceInfoTable.LastMatchVariance = LastMatchVarianceOptions::OK;
vendInvoiceInfoTable.ParmJobStatus = ParmJobStatus::Waiting;
vendInvoiceInfoTable.Approved = NoYes::Yes;
vendInvoiceInfoTable.Approver = HcmWorkerLookup::currentWorker();
vendInvoiceInfoTable.update();
}
purchFormLetter.reArrangeNow(true);
purchFormLetter.run();
Friday, December 7, 2018
Post Purchase Invoice with Match product receipts through Code in D365 FO
Subscribe to:
Post Comments (Atom)
Get or set adjust tax calculated amount using TAXDOCUMENT framework (Tax calculation service) in D365FO
//Get or adjust tax calculation using TAXDOCUMENT framework (Tax calculation service) TaxRegulation taxRegulationDetail; TmpTaxRegulation ...
-
Posting Vendor invoice based on Product receipt public void postPurchaseInvoiceJournal() { VendPackingSlipJour vendP...
-
protected void executePostingDataPerOrder(str _salesId) { SalesFormLetter_PackingSlip salesFormLetter_PackingSlip...
-
// Steps to create and Post a BOM journal through X++ void clicked() { InventJournalTable journalTable ; Inv...
No comments:
Post a Comment