2011-08-02 63 views
2

嘗試驗證日記帳時,我使用LedgerJournalEngine ErrorExists爲日記帳中的每個憑證。出於某種原因,它不會捕獲代碼中的所有錯誤,但如果我在客戶端中使用驗證按鈕,則錯誤將出現在信息日誌中。LedgerJournalEngine.errorExists(voucherNumber)不報告錯誤

是否有更好的方法來驗證日記賬憑證?

changecompany(ledgerJournalTable.dataAreaId) 
{ 
    ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::Yes,NoYes::No); 
    lje = LedgerJournalEngine::construct(ledgerJournalTable.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); 
      } 
     } 
    } 
} 

回答

2

所以這就是我想到的,到目前爲止它似乎按預期工作。如果有人有更好的方法,請讓我知道。

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;