开发者

LedgerJournalEngine.errorExists(voucherNumber) not reporting errors

开发者 https://www.devze.com 2023-03-24 23:52 出处:网络
When attempting to validate a journal I use the LedgerJournalEngine ErrorExists for each voucher in the journal. For some reason it doesn\'t catch all errors in the code but if I use the validate butt

When attempting to validate a journal I use the LedgerJournalEngine ErrorExists for each voucher in the journal. For some reason it doesn't catch all errors in the code but if I use the validate button in the client the errors are in the info log.

Is there a better way to validate a voucher in a journal?

changecompany(ledgerJournalTable.dataAreaId)
{
    ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::Yes,NoYes::No);
    lje = LedgerJournalEngine::construct(ledgerJournalTabl开发者_如何学编程e.JournalType);
    lje.newJournalActive(ledgerJournalTable,true);
    ledgerJournalCheckPost.parmLedgerJournalEngine(lje);
    try
    {
        ledgerJournalCheckPost.run();
    }
    catch
    {
        ledgerJournalCheckPost.validate();
        while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
        {
            if(lje.errorExists(ledgerJournalTrans.Voucher))
            {
                errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
            }
        }
    }
}


So this is what I have come up with, so far it seems to be working as expected. If anyone has a better way please let me know.

changecompany(ledgerJournalTable.dataAreaId)
{
    ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::No);
    lje = LedgerJournalEngine::construct(ledgerJournalTable.JournalType);
    lje.newJournalActive(ledgerJournalTable,true);
    ledgerJournalCheckPost.parmLedgerJournalEngine(lje);
    try
    {
        ledgerJournalCheckPost.run();
        while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
        {
            if(lje.errorInJournal() || ledgerJournalCheckPost.numOfErrorsInList()>0)
            {
                errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
            }
        }
        ledgerJournalCheckPost.parmPost(NoYes::Yes);
        ledgerJournalCheckPost.run();
    }
    catch
    {
        ledgerJournalCheckPost.validate();
        while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
        {
            if(lje.errorInJournal() || ledgerJournalCheckPost.numOfErrorsInList()>0)
            {
                errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
            }
        }
    }
    ledgerJournalCheckPost = null;
    lje = null;
    ledgerJournalTrans = null;
    ledgerJOurnalTable = null;
}
return errors;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号