This is my code:
boolean PostJournal(ledgerJournalTable ledgerJournalTable) { LedgerJournalEngine ledgerJournalEngine; LedgerJournalCheckPost ledgerJournalCheckPost; LedgerJournalTrans LedgerJournalTrans; ; ledgerJournalCheckPost = LedgerJournalCheckPost::construct(ledgerJournalTable.JournalType); // Set the JournalId, tableId of the journalTable // and specify to post the journal (not only check it). ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::Yes,NoYes::No); ledgerJournalEngine = LedgerJournalEngine::construct(ledgerJournalTable.JournalType); ledgerJournalEngine.newJournalActive(ledgerJournalTable,true); ledgerJournalCheckPost.parmLedgerJournalEngine(ledgerJournalEngine); try { ledgerJournalCheckPost.run();
/* This actually works, but I won't be able to retrieve the error message
ledgerJournalTable.reread();
if (ledgerJournalTable.Posted)
return true;
else
return false;
*/
if (!ledgerJournalCheckPost.numOfErrorsInList() && ledgerJournalCheckPost.numOfVouchersBooked()) return true; else return false; while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum { if(LedgerJournalEngine.errorExists(ledgerJournalTrans.Voucher)) { return false; } } if (LedgerJournalEngine.errorInJournal()) { return false; } else { return true; } } catch { return false; } return true; }
For some reason, even when the journal throws error when posting, my function never returns false. Catch does not trigger, and errorExists, errorInJournal and numOfErrorsInList are always false. Any thing I need to check in my code??
There is a catch block inside ledgerJournalCheckPost.run(); that is correctly triggered, but how can I make my functions catch block to trigger as well?
*This post is locked for comments