Tuesday, July 6, 2010

Check Journal Balance - When you meet a problem of "do not balance", this break point will be very helpful.

Object:


\Classes\LedgerVoucherObject\updateTotals


Invoke Scenario:

When there is some problem about imbalance, this function will be very helpful to track why it is imbalance.


Operation Instance:



General ledger -> Journals -> General journal -> Create a new line -> Click Line -> add lines for journal -> Click button post -> post.


Explanation of codes:
private void updateTotals(LedgerTrans _ledgerTrans)
{
LedgerTrans ledgerTransTotals;
;
ledgerTransTotals.data(_ledgerTrans);
if (transDateTotals.find(ledgerTransTotals)) //line 13
{

ledgerTransTotals.AmountCur += _ledgerTrans.AmountCur;
ledgerTransTotals.AmountMST += _ledgerTrans.AmountMST; //line 16
ledgerTransTotals.AmountMSTSecond += _ledgerTrans.AmountMSTSecond;
ledgerTransTotals.Qty += _ledgerTrans.Qty;
transDateTotals.ins(ledgerTransTotals, true);

}
else //line 21
{
transDateTotals.ins(ledgerTransTotals);
}
}
“ledgerTransTotals” is used to accumulate all the transactions. If the transaction is the first transaction needs to be checked, it goes into line 13. Otherwise, it goes into line 21. The ledgerTransTotals.AmountMST at line 16 should be 0 when the last transaction has been added, or it will not be posted. And you will receive a infolog “The trasaction on voucher *** do not balance”

Post Journal - Illustrate the structure of LedgerJournalcheckPost\postJournal. It is called by most journals.

Object:  Classes\LedgerJournalCheckPost\postJournal

Invoke Scenario:

Most of the journals (including “General ledger”, “Payment journal”, “Invoice journal”, “Invoice register”, “Invoice approval journal”, etc.) will call this method to deal with the posting staff.

Operation Instance:


General ledger -> Journals -> General journal -> Create a new line -> Click Line -> add lines for journal -> Click button post -> post.


Explanation of codes:


while select ledgerJournalTrans order by Voucher, AccountType, RecId //line 99

where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum

{

……

while (ledgerJournalTrans.AccountNum

ledgerJournalTrans.AmountCurDebit

// line 316
ledgerJournalTrans.AmountCurCredite

{

if (!this.postTrans(……))

……

ledgerJournalTrans = this.ledgerJournalTransOffset(ledgerJournalTrans, // line357

swappedAcToPostTaxedFirst);

……

}

……

}

……

if (interCompanyCompanies.elements() > 0) //line 400

{

interCompanyCompaniesEnumerator = interCompanyCompanies.getEnumerator();

while (interCompanyCompaniesEnumerator.moveNext())
{
if (interCompanyJournalIds.exists(interCompanyCompaniesEnumerator.current()))
{
ok = this.postJournalInterCompany(……);
……
}
}
}
Instance: (General journal Form)

GL -> Journals -> General journals -> lines
Add two lines as following:
Account Debit Credit Offset account

11010 1000 12060(intercompany)

21125 200 40112

Line 99: The while loop contains all the lines created in the journal form. In this instance, the while loop will be execute twice. One is for “11010, Offset 12060”, another is for “21125, Offset 40112”.

Line 316: This while loop will be execute twice at most. One is for the Current line account, another is for the offset account. In the end of this loop line357, the ledgerJournalTrans will be changed to its offset account.

Line 400: The codes within the ‘if’ condition is used to post the legertrans for intercompany. In this instance, the while loop inside the ‘if’ condition will be executed once. Because there is only one intercompany record 12060.