project QadFinancials > class TConCheck > method GLTrialBalanceCheck

Description

GL trial balance check for consistency check


Parameters


icFileinputcharacter
ocConCheckLineDetResultoutputcharacter
otConCheckLineDetStartDateoutputdate
oiConCheckLineDetStartTimeoutputinteger
oiConCheckLineDetDurationoutputinteger
iiCompanyIDinputinteger
iiPeriodIDinputinteger
iiSessionIDinputinteger
oiErrorNumbersoutputinteger
ocConCheckLineDetVersionoutputcharacter
icAppVersioninputcharacter
icSumFileinputcharacter
ihTranslationHandleinputhandleTranslation Handle.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method TConCheck.MainEntry


program code (program1/tconcheck.p)

/* ================================================================================= */
/* This is the method for Trial Balance                                              */
/* ================================================================================= */

assign oiReturnStatus = -98.
assign vdStartEtime               = etime(no)
       otConCheckLineDetStartDate = now
       oiConCheckLineDetStartTime = time
       oiErrorNumbers             = 0
       ocConCheckLineDetVersion   = icAppVersion + '.1'.

/* open logfile stream */
OUTPUT STREAM sTechOut TO value(icFile) APPEND.
OUTPUT STREAM sSumOut TO value(icSumFile) APPEND. 

PUT STREAM sTechOut unformatted ' ' skip.
PUT STREAM sTechOut unformatted '##### Trial Balance Validation #####' skip.
PUT STREAM sTechOut unformatted 'Version: ' ocConCheckLineDetVersion skip.
PUT STREAM sTechOut unformatted 'Validation Start At: ' string(now, '99/99/9999 HH:MM:SS') skip. 
   
MAIN_BLOCK: 
do on error undo, throw: 
    /* Get CompanyCode by iiCompanyId */
    find first Company where 
               Company.Company_id = iiCompanyID 
               no-lock no-error.     
    if iiCompanyID = ? or iiCompanyID = 0 or not available Company
    then do:
       assign ocConCheckLineDetResult = {&CONCHECKRESULT-FAILED}.
       PUT STREAM sTechOut unformatted "**Error** Input parameter CompanyID is null or Company not found." skip. 
       LEAVE MAIN_BLOCK.
    end.

    /* Get YearPeriod by iiPeriodID */
    find first Period of Company where 
               Period_id = iiPeriodID 
               no-lock no-error.    
    if iiPeriodID = ? or iiPeriodID = 0 or not available Period
    then do:
       assign ocConCheckLineDetResult = {&CONCHECKRESULT-FAILED}.
       PUT STREAM sTechOut unformatted "**Error** Input parameter PeriodID is null or Period not found." skip. 
       LEAVE MAIN_BLOCK.
    end.

    find first DomainProperty where DomainProperty.Domain_ID = Company.Domain_ID no-lock no-error.
    if available DomainProperty then
    assign viCompanyLC = DomainProperty.Currency_ID
           viCompanyCC = DomainProperty.StatutoryCurrency_ID.

    for each postinghist of company where postinghist.postinghistyearperiodfrom = Period.PeriodYearPeriod no-lock:
        assign 
            vdTotalDebitLC = vdTotalDebitLC + PostingHistMovemntDebitLC
            vdTotalCreditLC = vdTotalCreditLC + PostingHistMovemntCreditLC
            vdTotalDebitCC = vdTotalDebitCC + PostingHistMovemntDebitCC
            vdTotalCreditCC = vdTotalCreditCC + PostingHistMovemntCreditCC.
    end. /* for each postinghist */

    assign vdDiffLC = vdTotalDebitLC - vdTotalCreditLC
           vdDiffCC = vdTotalDebitCC - vdTotalCreditCC.

    if vdDiffLC <> 0 then assign oiErrorNumbers = oiErrorNumbers + 1.
    if vdDiffCC <> 0 then assign oiErrorNumbers = oiErrorNumbers + 1.
    if oiErrorNumbers = 0
    then assign ocConCheckLineDetResult = {&CONCHECKRESULT-PASSED}.
    else assign ocConCheckLineDetResult = {&CONCHECKRESULT-FAILED}.
end. /* main_block */
assign oiConCheckLineDetDuration = etime - vdStartEtime.

/* to format the total duration time */
assign viMilliSecs = oiConCheckLineDetDuration.
assign viSecs = TRUNCATE (oiConCheckLineDetDuration / 1000, 0).
assign viMilliSecs = viMilliSecs mod 1000.
assign vcTotalTime = string(viSecs, 'HH:MM:SS')  +  '.'  +  string(viMilliSecs).

put stream sTechOut unformatted 'Execution Duration: ' vcTotalTime  skip. 
put stream sTechOut unformatted 'Execution Result: ' ocConCheckLineDetResult skip.
put stream sTechOut unformatted '<Error Count:> ' oiErrorNumbers skip.
put stream sTechOut unformatted '**********************************************************************' skip.

output stream sTechOut close.
PUT STREAM sSumOut unformatted ' ' skip.
PUT STREAM sSumOut unformatted trim({&CONCHECKLINEDETTYPE-POSTINGBALANCE-TR}) skip.
PUT STREAM sSumOut unformatted '-------------' skip.
put stream sSumOut unformatted trim(#T-74'Execution Result':255(510391963)T-74#) + ': ' + ocConCheckLineDetResult skip.
if ocConCheckLineDetResult = {&CONCHECKRESULT-PASSED} 
then do:
    put stream sSumOut unformatted 
                        trim(#T-39'The total of GL accounts is balanced.':100(129776973)T-39#)
                        skip.
end.
else
do:
    put stream sSumOut unformatted 
                        trim(#T-88'Total number of errors':100(376712702)T-88#)
                        ': ' oiErrorNumbers skip.
    put stream sSumOut unformatted 
                        trim(#T-98'The total of GL accounts is unbalanced.':100(870183701)T-98#)
                        skip.
end.
put stream sSumOut unformatted ' ' skip.
put stream sSumOut unformatted 
                    trim(#T-64'Total DR BC':20(639136812)T-64#) to 20
                    trim(#T-81'Total CR BC':20(456013343)T-81#) to 40
                    trim(#T-60'Difference BC':20(931388539)T-60#) to 60 skip.
<M-8 run RoundAmount
   (input-output vdTotalDebitLC (bdUnroundedAmount), 
    input  viCompanyLC (iiCurrencyId), 
    input  ? (icCurrencyCode), 
    output vcFormatedAmount (ocFormatedAmount), 
    output oiReturnStatus (oiReturnStatus)) in TConCheck>


put stream sSumOut unformatted vcFormatedAmount to 20.

<M-75 run RoundAmount
   (input-output vdTotalCreditLC (bdUnroundedAmount), 
    input  viCompanyLC (iiCurrencyId), 
    input  ? (icCurrencyCode), 
    output vcFormatedAmount (ocFormatedAmount), 
    output oiReturnStatus (oiReturnStatus)) in TConCheck> 
put stream sSumOut unformatted vcFormatedAmount to 40.

<M-23 run RoundAmount
   (input-output vdDiffLC (bdUnroundedAmount), 
    input  viCompanyLC (iiCurrencyId), 
    input  ? (icCurrencyCode), 
    output vcFormatedAmount (ocFormatedAmount), 
    output oiReturnStatus (oiReturnStatus)) in TConCheck>
put stream sSumOut unformatted vcFormatedAmount to 60 skip.

put stream sSumOut unformatted 
                    trim(#T-34'Total DR SC':20(746627135)T-34#) to 20
                    trim(#T-97'Total CR SC':20(898232085)T-97#) to 40
                    trim(#T-33'Difference SC':20(119164693)T-33#) to 60 skip.
<M-94 run RoundAmount
   (input-output vdTotalDebitCC (bdUnroundedAmount), 
    input  viCompanyCC (iiCurrencyId), 
    input  ? (icCurrencyCode), 
    output vcFormatedAmount (ocFormatedAmount), 
    output oiReturnStatus (oiReturnStatus)) in TConCheck>
put stream sSumOut unformatted vcFormatedAmount to 20.

<M-37 run RoundAmount
   (input-output vdTotalCreditCC (bdUnroundedAmount), 
    input  viCompanyCC (iiCurrencyId), 
    input  ? (icCurrencyCode), 
    output vcFormatedAmount (ocFormatedAmount), 
    output oiReturnStatus (oiReturnStatus)) in TConCheck>
put stream sSumOut unformatted vcFormatedAmount to 40.

<M-31 run RoundAmount
   (input-output vdDiffCC (bdUnroundedAmount), 
    input  viCompanyCC (iiCurrencyId), 
    input  ? (icCurrencyCode), 
    output vcFormatedAmount (ocFormatedAmount), 
    output oiReturnStatus (oiReturnStatus)) in TConCheck>
put stream sSumOut unformatted vcFormatedAmount to 60 skip.
put stream sSumOut unformatted "____________________________________________________________" skip.
output stream sSumOut close.
if oiReturnStatus = -98
then assign oiReturnStatus = 0.