project QadFinancials > class BClosingPostingsReport > method IsGLAutoBalClear

Description

Checks, if all postings on the Auto-balance GL account are cleared by manual journal entry


Parameters


iiCompanyIdinputinteger
iiPeriodYearinputintegerPeriod, for which check should be done.
iiPeriodPeriodinputintegerPeriod, for which check should be done.
olIsGLAutoBalClearoutputlogicalIs the Auto-balance GL account cleared by manual corrections?
tGLAutoBalClearoutputtemp-table
icNumericFormatinputcharacter
icLayerCodeinputcharacterInput Parameter: Layer Code
icLayerTypeCodeinputcharacterInput parameter: layer Code Type
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BClosingPostingsReport.ProcessIsGLAutoBalClear
method BYearClosing.ValidateComponentAll


program code (program7/bclosingpostingsreport.p)

/* ====================================================================================== *
 * Method       : IsGLAutoBalClear                                                        *
 * Description  : Validations, whether the postings to Auto-balance GL account is cleared *
 *                by Manual Journal Entries or not                                        *                                                                        *
 * -------------------------------------------------------------------------------------- *
 * Parameters   : iiPeriodYear (M) Year for which period should be checked                *
 *                iiPeriodPeriod   Period for which Auto-blance GL account clear should   *
 *                                 be executed                                            *
 *                olIsGLAutoBalClear Resutl of the test                                   *
 * ====================================================================================== */
 
assign oiReturnStatus = -98
       viLocalReturn  = 0.

MAIN_BLOCK:
do on error undo, return:
    /* Default output parameters */
    assign olIsGLAutoBalClear = false
           vcFormatLC         = "":U
           vcFormatCC         = "":U.

    /* Pre-validation block */
    if iiPeriodYear   = 0 then assign iiPeriodYear = ?.
    if iiPeriodPeriod = 0 then assign iiPeriodPeriod = ?.

    if iiPeriodYear = ?
    then do:
        assign vcMessage = #T-68'Not all mandatory input parameters are populated.':255(999890633)T-68#
               vcContext = "iiPeriodYear = &1|iiPeriodPeriod = &2"
               vcContext = replace(vcContext, "|":U, chr(2))
               vcContext = substitute(vcContext, iiPeriodYear, iiPeriodPeriod).
        <M-73 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'S':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-207310':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  vcContext (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BClosingPostingsReport>
        assign oiReturnStatus = -1.
        return.
    end. /* if iiPeriodYear = ? */

    /* Check if there is already defined Auto-balance GL account */
    <Q-2 run GLBySystemTypeAndType (all) (Read) (NoCache)
       (input ?, (GLCode)
        input {&GLSYSTEMTYPE-AUTOBALANCE}, (GLSystemTypeCode)
        input ?, (GLId)
        input {&GLTYPECODE-SYST}, (GLTypeCode)
        input iiCompanyId, (CompanyId)
        input yes, (GlIsActive)
        output dataset tqGLBySystemTypeAndType) in BGL>        
        
    find first tqGLBySystemTypeAndType where
               tqGLBySystemTypeAndType.tcGLSystemTypeCode = {&GLSYSTEMTYPE-AUTOBALANCE} and /* AUTOBALANCE */
               tqGLBySystemTypeAndType.tcGLTypeCode       = {&GLTYPECODE-SYST} /* 'SYSTEM':U */
               no-error.

    /* If there is not defined Auto-balance GL account, then all is fine */
    if not available tqGLBySystemTypeAndType
    then do:        
        assign olIsGLAutoBalClear = true.
        leave MAIN_BLOCK.
    end.   
 

    /* Get periods, for which check is executed */
    <Q-30 run PeriodPrim (all) (Read) (NoCache)
       (input iiCompanyId, (CompanyId)
        input ?, (PeriodId)
        input iiPeriodYear, (PeriodYear)
        input iiPeriodPeriod, (PeriodPeriod)
        output dataset tqPeriodPrim) in BPeriod>


    assign  vdManPosCreditLC = 0
            vdManNegCreditLC = 0
            vdManPosCreditCC = 0
            vdManNegCreditCC = 0
            vdManPosDebitLC  = 0
            vdManNegDebitLC  = 0
            vdManPosDebitCC  = 0
            vdManNegDebitCC  = 0
            vdAutCreditLC    = 0
            vdAutCreditCC    = 0
            vdAutDebitLC     = 0
            vdAutDebitCC     = 0.
    empty temp-table tGLAutoBalClear.

    /* Get transactions from the Posting hist and validate all checks are ok */
    for each tqPeriodPrim:
        
        <Q-78 run PostingLineForConsCheckAutoBal (all) (Read) (NoCache)
           (input iiCompanyId, (CompanyId)
            input tqGLBySystemTypeAndType.tiGL_ID, (GLId)
            input tqPeriodPrim.tiPeriod_ID, (PeriodId)
            output dataset tqPostingLineForConsCheckAutoBal) in BPosting>
            
        /* Check for a specific layer code */    
        if icLayerCode <> '':U or
           icLayerCode <> ?
        then do:
            for each tqPostingLineForConsCheckAutoBal where
                     tqPostingLineForConsCheckAutoBal.tiCompany_ID = iiCompanyId                     and
                     tqPostingLineForConsCheckAutoBal.tiGL_ID      = tqGLBySystemTypeAndType.tiGL_ID and
                     tqPostingLineForConsCheckAutoBal.tiPeriod_ID  = tqPeriodPrim.tiPeriod_ID        and
                     tqPostingLineForConsCheckAutoBal.tcLayerCode  = icLayerCode:
                
                create tGLAutoBalClear.
                assign tGLAutoBalClear.tiPeriodYear     = tqPostingLineForConsCheckAutoBal.tiPostingYear
                       tGLAutoBalClear.tiPeriodPeriod   = tqPostingLineForConsCheckAutoBal.tiPostingPeriod
                       tGLAutoBalClear.tcJournalCode    = tqPostingLineForConsCheckAutoBal.tcJournalCode
                       tGLAutoBalClear.tiPostingVoucher = tqPostingLineForConsCheckAutoBal.tiPostingVoucher
                       tGLAutoBalClear.ttPostingDate    = tqPostingLineForConsCheckAutoBal.ttPostingDate
                       tGLAutoBalClear.tcPostingText    = tqPostingLineForConsCheckAutoBal.tcPostingText
                       tGLAutoBalClear.tcGLCode         = tqPostingLineForConsCheckAutoBal.tcGLCode
                       tGLAutoBalClear.tdCreditCC       = tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC
                       tGLAutoBalClear.tdCreditLC       = tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC
                       tGLAutoBalClear.tdDebitCC        = tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC
                       tGLAutoBalClear.tdDebitLC        = tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC.
    
                if tqPostingLineForConsCheckAutoBal.tcJournalTypeCode = {&JOURNALTYPE-JOURNALENTRY}
                then assign vdManPosCreditLC = vdManPosCreditLC +
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC else 0)
                            vdManNegCreditLC = vdManNegCreditLC + 
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC)
                            vdManPosCreditCC = vdManPosCreditCC +
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC else 0)
                            vdManNegCreditCC = vdManNegCreditCC +
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC)
                            vdManPosDebitLC  = vdManPosDebitLC +
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC else 0)
                            vdManNegDebitLC  = vdManNegDebitLC +
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC)
                            vdManPosDebitCC  = vdManPosDebitCC +
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC else 0)
                            vdManNegDebitCC  = vdManNegDebitCC +
                                               (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC).
                else assign vdAutCreditLC = vdAutCreditLC + tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC
                            vdAutCreditCC = vdAutCreditCC + tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC
                            vdAutDebitLC  = vdAutDebitLC  + tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC
                            vdAutDebitCC  = vdAutDebitCC  + tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC.
            end. /* for each tqPostingLineForConsCheckAutoBal where */
        end.  /* if icLayerCode <> '':U or */
        else if iclayerTypeCode <> '':U or
                icLayerTypeCode <> ?
            then do:
                for each tqPostingLineForConsCheckAutoBal where
                         tqPostingLineForConsCheckAutoBal.tiCompany_ID     = iiCompanyId                     and
                         tqPostingLineForConsCheckAutoBal.tiGL_ID          = tqGLBySystemTypeAndType.tiGL_ID and
                         tqPostingLineForConsCheckAutoBal.tiPeriod_ID      = tqPeriodPrim.tiPeriod_ID        and
                         tqPostingLineForConsCheckAutoBal.tcLayerTypeCode = icLayerTypeCode:
                    
                    create tGLAutoBalClear.
                    assign tGLAutoBalClear.tiPeriodYear     = tqPostingLineForConsCheckAutoBal.tiPostingYear
                           tGLAutoBalClear.tiPeriodPeriod   = tqPostingLineForConsCheckAutoBal.tiPostingPeriod
                           tGLAutoBalClear.tcJournalCode    = tqPostingLineForConsCheckAutoBal.tcJournalCode
                           tGLAutoBalClear.tiPostingVoucher = tqPostingLineForConsCheckAutoBal.tiPostingVoucher
                           tGLAutoBalClear.ttPostingDate    = tqPostingLineForConsCheckAutoBal.ttPostingDate
                           tGLAutoBalClear.tcPostingText    = tqPostingLineForConsCheckAutoBal.tcPostingText
                           tGLAutoBalClear.tcGLCode         = tqPostingLineForConsCheckAutoBal.tcGLCode
                           tGLAutoBalClear.tdCreditCC       = tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC
                           tGLAutoBalClear.tdCreditLC       = tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC
                           tGLAutoBalClear.tdDebitCC        = tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC
                           tGLAutoBalClear.tdDebitLC        = tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC.
        
                    if tqPostingLineForConsCheckAutoBal.tcJournalTypeCode = {&JOURNALTYPE-JOURNALENTRY}
                    then assign vdManPosCreditLC = vdManPosCreditLC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC else 0)
                                vdManNegCreditLC = vdManNegCreditLC + 
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC)
                                vdManPosCreditCC = vdManPosCreditCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC else 0)
                                vdManNegCreditCC = vdManNegCreditCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC)
                                vdManPosDebitLC  = vdManPosDebitLC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC else 0)
                                vdManNegDebitLC  = vdManNegDebitLC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC)
                                vdManPosDebitCC  = vdManPosDebitCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC else 0)
                                vdManNegDebitCC  = vdManNegDebitCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC).
                    else assign vdAutCreditLC = vdAutCreditLC + tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC
                                vdAutCreditCC = vdAutCreditCC + tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC
                                vdAutDebitLC  = vdAutDebitLC  + tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC
                                vdAutDebitCC  = vdAutDebitCC  + tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC.
                end. /* for each tqPostingLineForConsCheckAutoBal where */
            end. /* else if iclayerTypeCode <> '':U or */
            else do:   
                for each tqPostingLineForConsCheckAutoBal where
                         tqPostingLineForConsCheckAutoBal.tiCompany_ID     = iiCompanyId                     and
                         tqPostingLineForConsCheckAutoBal.tiGL_ID          = tqGLBySystemTypeAndType.tiGL_ID and
                         tqPostingLineForConsCheckAutoBal.tiPeriod_ID      = tqPeriodPrim.tiPeriod_ID        and
                         (tqPostingLineForConsCheckAutoBal.tcLayerTypeCode = {&LAYERTYPECODE-MANAGEMENT} or
                          tqPostingLineForConsCheckAutoBal.tcLayerTypeCode = {&LAYERTYPECODE-OFFICIAL}):
                    
                    create tGLAutoBalClear.
                    assign tGLAutoBalClear.tiPeriodYear     = tqPostingLineForConsCheckAutoBal.tiPostingYear
                           tGLAutoBalClear.tiPeriodPeriod   = tqPostingLineForConsCheckAutoBal.tiPostingPeriod
                           tGLAutoBalClear.tcJournalCode    = tqPostingLineForConsCheckAutoBal.tcJournalCode
                           tGLAutoBalClear.tiPostingVoucher = tqPostingLineForConsCheckAutoBal.tiPostingVoucher
                           tGLAutoBalClear.ttPostingDate    = tqPostingLineForConsCheckAutoBal.ttPostingDate
                           tGLAutoBalClear.tcPostingText    = tqPostingLineForConsCheckAutoBal.tcPostingText
                           tGLAutoBalClear.tcGLCode         = tqPostingLineForConsCheckAutoBal.tcGLCode
                           tGLAutoBalClear.tdCreditCC       = tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC
                           tGLAutoBalClear.tdCreditLC       = tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC
                           tGLAutoBalClear.tdDebitCC        = tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC
                           tGLAutoBalClear.tdDebitLC        = tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC.
        
                    if tqPostingLineForConsCheckAutoBal.tcJournalTypeCode = {&JOURNALTYPE-JOURNALENTRY}
                    then assign vdManPosCreditLC = vdManPosCreditLC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC else 0)
                                vdManNegCreditLC = vdManNegCreditLC + 
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC)
                                vdManPosCreditCC = vdManPosCreditCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC else 0)
                                vdManNegCreditCC = vdManNegCreditCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC)
                                vdManPosDebitLC  = vdManPosDebitLC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC else 0)
                                vdManNegDebitLC  = vdManNegDebitLC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC)
                                vdManPosDebitCC  = vdManPosDebitCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC > 0 then tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC else 0)
                                vdManNegDebitCC  = vdManNegDebitCC +
                                                   (if tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC > 0 then 0 else tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC).
                    else assign vdAutCreditLC = vdAutCreditLC + tqPostingLineForConsCheckAutoBal.tdPostingLineCreditLC
                                vdAutCreditCC = vdAutCreditCC + tqPostingLineForConsCheckAutoBal.tdPostingLineCreditCC
                                vdAutDebitLC  = vdAutDebitLC  + tqPostingLineForConsCheckAutoBal.tdPostingLineDebitLC
                                vdAutDebitCC  = vdAutDebitCC  + tqPostingLineForConsCheckAutoBal.tdPostingLineDebitCC.
                end. /* for each tqPostingLineForConsCheckAutoBal where */
            end. /* else do: */
    end. /* for each tqPeriodPrim: */

    empty temp-table tGLAutoBalClearSum.
    /* ============================================================================ */
    /* Perform validations                                                          */
    /* ============================================================================ */
    /* 1. Sum of all Debit BC created by non-manual journal entry is different      *
     *    to Sum of all positive CreditBC + Sum of all negative Debit BC created by *
     *    manual journal entry                                                      */
    if vdAutDebitLC <> vdManPosCreditLC - vdManNegDebitLC
    then do:
        assign vdAmountTemp = <M-75 RoundAmount
                                 (input  vdAutDebitLC - (vdManPosCreditLC - vdManNegDebitLC) (idUnroundedAmount), 
                                  input  viCompanyLCId (iiCurrencyID), 
                                  input  ? (icCurrencyCode)) in BClosingPostingsReport>.

        if vcFormatLC = "":U 
        then do:
            <M-11 run GetAmountFormat
               (input  viCompanyLCId (iiCurrencyID), 
                input  ? (icCurrencyCode), 
                output vcFormatLC (ocFormat), 
                output viFcReturnSuper (oiReturnStatus)) in BClosingPostingsReport>
        end. 
        create tGLAutoBalClearSum.
        assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = trim(#T-38'Auto balance account activity in BC of &1 (Dr) is expected to be cleared. The amount &2 cleared with manual journal entries is expected to be the same.':255(582246700)T-38#).
        if icNumericFormat = session:numeric-format
        then assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,trim(string(vdAmountTemp, vcFormatLC)),trim(string(vdAmountTemp, vcFormatLC))).       
        else assign vcFormatedAmount =  trim(replace(replace(replace(string(vdAmountTemp, vcFormatLC),".":U,"#":U),",":U,".":U),"#":U,",":U))
                    tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,
                                                                vcFormatedAmount,
                                                                vcFormatedAmount).       
    end. /* if vdAutDebitLC <> vdManPosCreditLC - vdManNegDebitLC */
    
    /* 2. Sum of all Credit BC created by non-manual journal entry is different to  *
     *    Sum of all positive DebitBC + Sum of all negative Credit BC created by    *
     *    manual journal entry                                                      */
    if vdAutCreditLC <> vdManPosDebitLC - vdManNegCreditLC
    then do:
        assign vdAmountTemp = <M-85 RoundAmount
                                 (input  vdAutCreditLC - (vdManPosDebitLC - vdManNegCreditLC) (idUnroundedAmount), 
                                  input  viCompanyLCId (iiCurrencyID), 
                                  input  ? (icCurrencyCode)) in BClosingPostingsReport>.
        if vcFormatLC = "":U 
        then do:
            <M-44 run GetAmountFormat
               (input  viCompanyLCId (iiCurrencyID), 
                input  ? (icCurrencyCode), 
                output vcFormatLC (ocFormat), 
                output viFcReturnSuper (oiReturnStatus)) in BClosingPostingsReport>
        end.  
        create tGLAutoBalClearSum.
        assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = trim(#T-27'Auto balance account activity in BC of &1 (Cr) is expected to be cleared. The amount &2 cleared with manual journal entries is expected to be the same.':255(345727331)T-27#).
        if icNumericFormat = session:numeric-format 
        then assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,trim(string(vdAmountTemp, vcFormatLC)),trim(string(vdAmountTemp, vcFormatLC))).
        else assign vcFormatedAmount =  trim(replace(replace(replace(string(vdAmountTemp, vcFormatLC),".":U,"#":U),",":U,".":U),"#":U,",":U))
                    tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,
                                                                vcFormatedAmount,
                                                                vcFormatedAmount).       
    end. /* if vdAutCreditLC <> vdManPosDebitLC - vdManNegCreditLC */

    /* 3. Sum of all Debit SC created by non-manual journal entry is different to   *
     *    Sum of all positive CreditSC + Sum of all negative Debit SC created by    *
     *    manual journal entry                                                      */
    if vdAutDebitCC <> vdManPosCreditCC - vdManNegDebitCC
    then do:
        assign vdAmountTemp = <M-89 RoundAmount
                                 (input  vdAutDebitCC - (vdManPosCreditCC - vdManNegDebitCC) (idUnroundedAmount), 
                                  input  viCompanyCCId (iiCurrencyID), 
                                  input  ? (icCurrencyCode)) in BClosingPostingsReport>.
        if vcFormatCC = "":U 
        then do:
            <M-50 run GetAmountFormat
               (input  viCompanyCCId (iiCurrencyID), 
                input  ? (icCurrencyCode), 
                output vcFormatCC (ocFormat), 
                output viFcReturnSuper (oiReturnStatus)) in BClosingPostingsReport>
        end.  
        create tGLAutoBalClearSum.
        assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = trim(#T-57'Auto balance account activity in SC of &1 (Dr) is expected to be cleared. The amount &2 cleared with manual journal entries is expected to be the same.':255(19309383)T-57#).
        if icNumericFormat = session:numeric-format
        then assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,trim(string(vdAmountTemp, vcFormatCC)),trim(string(vdAmountTemp, vcFormatCC))).
        else assign vcFormatedAmount =  trim(replace(replace(replace(string(vdAmountTemp, vcFormatCC),".":U,"#":U),",":U,".":U),"#":U,",":U))
                    tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,
                                                               vcFormatedAmount,
                                                               vcFormatedAmount).       
    end. /* if vdAutDebitCC <> vdManPosCreditCC - vdManNegDebitCC */

    /* 4.	Sum of all Credit SC created by non-manual journal entry is different to *
     *      Sum of all positive DebitSC + Sum of all negative Credit SC created by   *
     *      manual journal entry                                                     */
    if vdAutCreditCC <> vdManPosDebitCC - vdManNegCreditCC
    then do:
        assign vdAmountTemp = <M-53 RoundAmount
                                (input  vdAutCreditCC - (vdManPosDebitCC - vdManNegCreditCC) (idUnroundedAmount), 
                                 input  viCompanyCCId (iiCurrencyID), 
                                 input  ? (icCurrencyCode)) in BClosingPostingsReport>.
        if vcFormatCC = "":U 
        then do:
            <M-80 run GetAmountFormat
               (input  viCompanyCCId (iiCurrencyID), 
                input  ? (icCurrencyCode), 
                output vcFormatCC (ocFormat), 
                output viFcReturnSuper (oiReturnStatus)) in BClosingPostingsReport>
        end.  
        create tGLAutoBalClearSum.
        assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = trim(#T-35'Auto balance account activity in SC of &1 (Cr) is expected to be cleared. The amount &2 cleared with manual journal entries is expected to be the same.':255(226726845)T-35#).
        if icNumericFormat = session:numeric-format
        then assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,trim(string(vdAmountTemp, vcFormatCC)),trim(string(vdAmountTemp, vcFormatCC))).
        else assign vcFormatedAmount =  trim(replace(replace(replace(string(vdAmountTemp, vcFormatCC),".":U,"#":U),",":U,".":U),"#":U,",":U))
                    tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,
                                                                vcFormatedAmount,
                                                                vcFormatedAmount).       
    end. /* if vdAutCreditCC <> vdManPosDebitCC - vdManNegCreditCC */

    /* 5.	Balance of the Auto-balancing GL account is non zero */
    if (vdManPosDebitLC + vdManNegDebitLC + vdAutDebitLC <> vdManPosCreditLC + vdManNegCreditLC + vdAutCreditLC)
    then do:
        assign vdAmountTemp = <M-88 RoundAmount
                                   (input  vdManPosDebitLC + vdManNegDebitLC + vdAutDebitLC - (vdManPosCreditLC + vdManNegCreditLC + vdAutCreditLC) (idUnroundedAmount), 
                                    input  viCompanyLCId (iiCurrencyID), 
                                    input  ? (icCurrencyCode)) in BClosingPostingsReport>.
        if vcFormatLC = "":U 
        then do:
            <M-26 run GetAmountFormat
               (input  viCompanyLCId (iiCurrencyID), 
                input  ? (icCurrencyCode), 
                output vcFormatLC (ocFormat), 
                output viFcReturnSuper (oiReturnStatus)) in BClosingPostingsReport>
        end.  
        create tGLAutoBalClearSum.
        assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = trim(#T-13'Balance of the Auto-balancing GL account in BC is &1. It is expected to be zero.':255(247127101)T-13#).
        if icNumericFormat = session:numeric-format
        then assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,trim(string(vdAmountTemp, vcFormatLC)),trim(string(vdAmountTemp, vcFormatLC))).
        else assign vcFormatedAmount =  trim(replace(replace(replace(string(vdAmountTemp, vcFormatLC),".":U,"#":U),",":U,".":U),"#":U,",":U))
                    tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,
                                                                vcFormatedAmount,
                                                                vcFormatedAmount).       
    end. /* if (vdManPosDebitLC + vdManNegDebitLC + vdAutDebitLC <> vdManPosCreditLC + vdManNegCreditLC + vdAutCreditLC) */
    
    if (vdManPosDebitCC + vdManNegDebitCC + vdAutDebitCC <> vdManPosCreditCC + vdManNegCreditCC + vdAutCreditCC)
    then do:
        assign vdAmountTemp = <M-55 RoundAmount
                                 (input  vdManPosDebitCC + vdManNegDebitCC + vdAutDebitCC - (vdManPosCreditCC + vdManNegCreditCC + vdAutCreditCC) (idUnroundedAmount), 
                                  input  viCompanyCCId (iiCurrencyID), 
                                  input  ? (icCurrencyCode)) in BClosingPostingsReport>.
        if vcFormatCC = "":U 
        then do:
            <M-48 run GetAmountFormat
               (input  viCompanyCCId (iiCurrencyID), 
                input  ? (icCurrencyCode), 
                output vcFormatCC (ocFormat), 
                output viFcReturnSuper (oiReturnStatus)) in BClosingPostingsReport>
        end.  
        create tGLAutoBalClearSum.
        assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = trim(#T-82'Balance of the Auto-balancing GL account in SC is &1. It is expected to be zero.':255(175107973)T-82#).
        if icNumericFormat = session:numeric-format
        then assign tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,trim(string(vdAmountTemp, vcFormatCC)),trim(string(vdAmountTemp, vcFormatCC))).
        else assign vcFormatedAmount =  trim(replace(replace(replace(string(vdAmountTemp, vcFormatCC),".":U,"#":U),",":U,".":U),"#":U,",":U))
                    tGLAutoBalClearSum.tcGLAutoBalClearSumErr = substitute(tGLAutoBalClearSum.tcGLAutoBalClearSumErr,
                                                                vcFormatedAmount,
                                                                vcFormatedAmount).
    end. /* if (vdManPosDebitCC + vdManNegDebitCC + vdAutDebitCC <> vdManPosCreditCC + vdManNegCreditCC + vdAutCreditCC) */  

    if can-find(first tGLAutoBalClearSum)
    then leave MAIN_BLOCK.

    /* All validations passed, result is OK */
    assign olIsGLAutoBalClear = true.
end. /* MAIN_BLOCK */

assign oiReturnStatus = viLocalReturn.