invoices are created but cant't be posted, only the first invoice is posted .
protected void createAndPostJournal()
{
FormletterJournalPost formletterJournalPost1;
SalesParmLine salesParmLine,salesParmLine1;
SalesQty salesQty ;
SalesParmTable salesParmTable = SalesParmTable::find(formletterParmTable.parmId,formletterParmTable.tableRefId);
salesParmUpdate salesParmUpdate;
salesParmTable salesParmTable1;
salesFormletterParmData salesFormLetterParmData;
TransDate PackingSlipDate ;
ttsbegin;
select firstOnly Forupdate salesParmLine where salesParmLine.parmId == salesParmTable.ParmId;
salesQty = salesParmLine.DeliverNow ;
salesParmLine.deliverNow=UnitOfMeasureConverter::convert(1,
UnitOfMeasure::unitOfMeasureIdBySymbol(salesParmLine.inventTable().inventUnitId()),
UnitOfMeasure::unitOfMeasureIdBySymbol(salesParmLine.salesUnit()),
NoYes::Yes,
InventTable::itemProduct(salesParmLine.ItemId));
salesParmLine.setInventDeliverNow();
salesParmLine.setLineAmount();
salesParmLine.update();
ttscommit;
next createAndPostJournal();
if (salesParmTable.documentId(salesParmTable))
{
salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Invoice, VersioningUpdateType::Initial);
salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
salesFormLetterParmData.createData(false);
salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
salesParmTable1.clear();
salesParmTable1.TransDate = salesParmTable.transdate;
salesParmTable1.Ordering = DocumentStatus::Invoice;
salesParmTable1.ParmJobStatus = ParmJobStatus::Waiting;
salesParmTable1.salesId = salesParmTable.salesId;
salesParmTable1.salesName = salesParmTable.salesName;
salesParmTable1.DeliveryName = salesParmTable.DeliveryName;
salesParmTable1.DeliveryPostalAddress = salesParmTable.DeliveryPostalAddress;
salesParmTable1.CustAccount = salesParmTable.CustAccount;
salesParmTable1.CurrencyCode = salesParmTable.CurrencyCode;
salesParmTable1.InvoiceAccount = salesParmTable.InvoiceAccount;
salesParmTable1.ParmId = SalesParmTable.ParmId;
salesParmTable1.insert();
salesParmLine1.DeliverNow = salesParmLINE.delivernow;
salesParmLine1.setInventDeliverNow();
salesParmLine1.setLineAmount();
salesParmLine1.ParmId = salesParmTable1.ParmId;
salesParmLine1.TableRefId = salesParmTable1.TableRefId;
salesParmLine1.setQty(DocumentStatus::INVOICE, TRUE, true);
//salesParmLine1.setLineAmount(salesParmLine.salesLine());
salesParmLine1.InventDimId = salesParmLine.InventDIMID;
salesParmLine1.ItemId = salesParmLine.ItemId;
salesParmLine1.initFromSalesLine(salesParmLine.salesLine());
salesParmLine1.calcPackingUnitQty();
salesParmLine1.InventNow = salesParmLine.salesLine().ExpectedRetQty;
salesParmLine1.insert();
salesParmSubLine salesParmSubLine;
salesParmSubLine.clear();
salesParmSubLine.initValue();
salesParmSubLine.initFromSalesParmLine(salesParmLine1);
salesParmSubLine.InventNow = salesParmLine.salesLine().SalesQty;
salesParmSubLine.DeliverNow = salesParmLine.salesLine().SalesQty;
salesParmSubLine.insert();
SalesLine salesline1 = salesParmLine.salesLine();
this.createJournal(salesParmTable1); // CREATE Invoice
if (journal.RecId)
{
formletterJournalPost1 = this.postJournal(salesParmTable1); //Post Invoice : where the system throws multiple errors
this.addJournalToLists();
}
this.updateParmTableJobStatusExecuted(salesParmTable1);
if ( journal.RecId && formletterJournalPost1)
{
formletterJournalPost1.postJournalPost();
this.prepareProforma(formletterJournalPost1);
}
}