Partial posting of invoice for sales order

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.

Hi Raghav,

Have you identified the solution of above problem.

I am also having the same problem. I have created one sales order with two sales line. I have generated packing slip for first line and now i want to generate invoice for that first line only i.e. partial invoice of sales order through code.

Do u have created any job or code for this. If you are having then please share with me. Or else you can guide me through this that i can achieve this task.

Thanks in advance.

Vijay Solanki.

Hi Vijay,

you can directly create invoice for single line if the packing slip is created for it by using below code

salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
salesTable = SalesTable::Find(“SO-001”);
SalesFormLetter.update(SalesTable,systemDateGet(), SalesUpdate::PackingSlip, AccountOrder::None, false, false);

Thanks