Get Delivery Notes or Packing Slip IDs against Sales invoice X++
Hi folks,
Recently, I had a requirement where Delivery Notes or Packing Slip IDs were required to be displayed in the Sales invoice print out. Since, there are multiple Packing Slips against the same Sales Invoice and there is no direct relation between Sales invoice related tables and Packing slip related so i had to scratch my head and explored relations in Inventory transactions related tables because in both sales invoice and packing slip transactions, inventory transactions are impacted. Finally, i was able to find a way to find Delivery notes against Sales invoice.
Below is the code snippets of how you can get Delivery Notes or Packing Slip IDs against a Sales Invoice and prints on the Sales invoice print out
int i = 0;
str packingSlipIds;
while select custInvoiceTransPS
where custInvoiceTransPS.SalesId == _custInvoiceJour.SalesId
&& custInvoiceTransPS.InvoiceId == _custInvoiceJour.InvoiceId
&& custInvoiceTransPS.InvoiceDate == _custInvoiceJour.InvoiceDate
join custPackingSlipTrans group by custPackingSlipTrans.PackingSlipId
where custPackingSlipTrans.InventTransId == custInvoiceTransPS.InventTransId
exists join inventTransOrigin
where inventTransOrigin.InventTransId == custPackingSlipTrans.InventTransId
exists join inventTrans
where inventTrans.InventTransOrigin == inventTransOrigin.RecId
&& inventTrans.PackingSlipId == custPackingSlipTrans.PackingSlipId
&& inventTrans.InvoiceId == _custInvoiceJour.InvoiceId
{
if(i == 0)
{
packingSlipIds = custPackingSlipTrans.PackingSlipId;
salesInvoiceTmp.DeliveryNotes = packingSlipIds;
}
else
{
packingSlipIds = packingSlipIds + ", " + custPackingSlipTrans.PackingSlipId;
salesInvoiceTmp.DeliveryNotes = packingSlipIds;
}
i++;
}

Like
Report
*This post is locked for comments