project QadFinancials > class TConCheck > method RevaluationCheck

Description

Revaluation check for consistency check


Parameters


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


Internal usage


QadFinancials
method TConCheck.MainEntry


program code (program1/tconcheck.p)

/* ================================================================================= */
/* This is the check for revaluation                                                 */
/* ================================================================================= */
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 '##### Revaluation Check #####' 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.

    assign ocConCheckLineDetResult = {&CONCHECKRESULT-WARNING}
           vlPostedRevalExist = no
           vlUnpostedRevalExist = no.

    for each RevalHeader where RevalHeader.Company_ID = iiCompanyID and
                               RevalHeader.Period_ID = iiPeriodID no-lock:   
        if can-find (first Reval of RevalHeader where Reval.RevalStatusCode = {&REVALSTATUS-POSTED})
        then do:
            assign vlPostedRevalExist = yes.
        end.
        if can-find (first Reval of RevalHeader where Reval.RevalStatusCode = {&REVALSTATUS-INITIAL})
        then do:
            assign vlUnpostedRevalExist = yes.
        end.        
    end.  

    if vlPostedRevalExist = yes and vlUnpostedRevalExist = no
    then assign ocConCheckLineDetResult = {&CONCHECKRESULT-PASSED}.
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 sSumOut unformatted ' ' skip.
PUT STREAM sSumOut unformatted trim({&CONCHECKLINEDETTYPE-REVALUATION-TR}) skip.
PUT STREAM sSumOut unformatted '-----------------' skip.
put stream sSumOut unformatted trim(#T-20'Execution Result':255(510391963)T-20#) + ': ' + ocConCheckLineDetResult skip. 

if ocConCheckLineDetResult = {&CONCHECKRESULT-WARNING}
then do:
    if not vlPostedRevalExist 
    then do:
        put stream sTechOut unformatted "Currently there are no revaluation transactions posted in the selected period." skip.
        put stream sSumOut unformatted 
                            trim(#T-5'Currently there are no revaluation transactions posted in the selected period.':200(333347614)T-5#)  skip.
    end.
    if vlPostedRevalExist and vlUnpostedRevalExist
    then do:
        put stream sTechOut unformatted "There are unposted revaluation simulations for the selected period." skip. 
        put stream sSumOut unformatted 
                            trim(#T-74'There are unposted revaluation simulations for the selected period.':200(142273621)T-74#) 
                            skip.
    end.  
end.
else do:
    put stream sTechOut unformatted "There are no unposted revaluation simulations for the selected period." skip. 
    put stream sSumOut unformatted 
                            trim(#T-50'There are no unposted revaluation simulations for the selected period.':200(890386603)T-50#)
                            skip. 
end.    


put stream sTechOut unformatted 'Execution Duration: ' vcTotalTime  skip. 
put stream sTechOut unformatted 'Execution Result: ' ocConCheckLineDetResult skip.
put stream sTechOut unformatted '**********************************************************************' skip.
output stream sTechOut close.

put stream sSumOut unformatted "____________________________________________________________" skip.
output stream sSumOut close.
if oiReturnStatus = -98
then assign oiReturnStatus = 0.