Regarding Multiple Po Invoice Through X++

Consider two purchase orders created using same vendor

Till Product receipt the process should be done functionally from front end.

Now both of them should be invoiced with same invoice id through x++ code.

Invoice should be done for only received quantity in two purchase orders.

Could any one suggest me how to achieve this and also share your sample code.

Thanks & Regards,

Jagadeesh.V

To do multiple po’s invoice for same vendor, You to have to pass partial product receipt name as shown in below code .

static void invoicePurchaseOrder_Packingslip(Args _args)
{
Purchformletter_invoice Purchformletter;
Purchtable purchtable;
vendPackingSlipJour vendPackingSlipJour;
vendPackingSlipTrans vendPackingSlipTrans;
TmpFrmVirtual tmpFrmVirtual;
List selectedList = new List(Types::Record);
purchParmUpdate purchParmUpdate;
purchParmtable purchParmtable;
ParmId parmId;
VendInvoiceInfoTable vendinvoiceinfoTable;
;
try
{
ttsbegin;
tmpFrmVirtual.setTmp();
// Add the packing slips into tmpFrmVirtual
while select vendpackingslipjour
where vendpackingslipjour.packingslipid == ‘Packingslip1’ && vendpackingslipjour.packingslipid == ‘packingslip2’
{
tmpFrmVirtual.clear();
tmpFrmVirtual.TableNum = vendpackingslipjour.TableId;
tmpFrmVirtual.RecordNo = vendpackingslipjour.RecId;
tmpFrmVirtual.NoYes = NoYes::Yes;
tmpFrmVirtual.Id = vendpackingslipjour.PurchId;
tmpFrmVirtual.insert();

}
while select tmpFrmVirtual
{
selectedList.addEnd(tmpFrmVirtual);
}
// Construct form letter
Purchformletter = purchformletter::construct(DocumentStatus::Invoice);
// Add the packing slips to the purch form letter
Purchformletter.selectFromJournal(selectedList.pack());

purchformletter.sumBy(AccountOrder::None);
purchformletter.reArrangeNow(true);
purchformletter.reArrange();
purchformletter.specQty(purchupdate::PackingSlip);
parmId = purchformletter.parmId();

// Execute
ttscommit;
purchformletter.startOperation();
if (purchFormLetter.parmJournalRecord().recid)
{
info(“Invoice completed sucessfully”);
}
}
catch
{
throw error(strFmt(“Invoice failed”));
}