Hi All,
I'm facing a rare issue while posting invoice. We have a screen where we can post packing slip and invoice at a time for single/multiple sales orders. The issue is when a certain sales order is invoiced, partial invoice is posted for the sales order (only the last sales line is not invoiced). The issue occurs only for following sales order.
Sales order has 9 lines and last sales line qty is more than 2.
From a custom screen, packing slip is posted first and invoice is posted through the following code.
queryPack = new Query(QueryStr(SalesUpdatePackingSlip));
qbdsPackSalesTable = queryPack.dataSourceTable(tableNum(SalesTable));
qbdsPackSalesTable.addRange(fieldnum(SalesTable, SalesId)).value("SOR0136098");
queryRun = new queryRun(queryPack);
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.specQty(SalesUpdate::PackingSlip);
salesFormLetter.chooseLinesQuery(queryRun);
salesFormLetter.transDate(systemdateget());
salesFormLetter.printFormLetter(true);
salesFormLetter.createParmUpdate(false);
salesFormLetter.chooseLines(null,false);
salesFormLetter.reArrangeNow(false);
salesFormLetter.sumBy(AccountOrder::Auto);
salesFormLetter.run();
from salesFormLetter.chooseLines() method, it goes to child class method i.e., salesFormLetter_Invoice.chooseLines() and then the control goes to 'chooseLinesFromPackingslip' method of 'salesFormLetter_Invoice' class.
The issue what I found exists in following code (while(chooseLines.next()))
this.allowCreateParmTable(this.allowEmptyTable());
chooseLines.reset(); // if the select button is used from saleseditlines
while (chooseLines.next())
{
if (chooseLines.changed(tablenum(SalesTable)))
{
localSalesTable = chooseLines.get(tablenum(SalesTable));
mayJournalBePosted = this.mayJournalBePosted(localSalesTable);
}
if (! mayJournalBePosted)
{
continue;
}
if (chooseLines.changed(tablenum(SalesLine)))
{
localSalesLine = chooseLines.get(tablenum(SalesLine));
}
.
.
}
When chooseLines.next() method executes for second quantity of last sales line, local variable 'localSalesLine' is nullified.
what could be the possible reason for this behavior ?
Regards,
Raghav.