project QadFinancials > class BClosingPostingsReport > method FAControlGLBalance

report procedure


Parameters


icLanguageCodeinputcharacterLanguage Code.
tFilterinputtemp-tableTemp table to store input parameters.
dcrFAControlGLBalanceoutputdatasetDataset of FAControlGLBalance.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bclosingpostingsreport.p)

empty temp-table tqFAControlGLBalance.

<M-1 run GetReportLabels (input  'FAControlGLBalance':U (icReportName), 
                          input  icLanguageCode (icLanguageCode), 
                          input  tFilter (tFilter), 
                          output tqHeader (tqHeader), 
                          output tqFilter (tqFilter), 
                          output tqText (tqText), 
                          output oiReturnStatus (oiReturnStatus)) in BClosingPostingsReport>
                          
if oiReturnStatus <> 0
then return.

<M-2 run SetDataItemsBasedOnFilterTT (output oiReturnStatus (oiReturnStatus)) in BClosingPostingsReport>

if viPeriodPeriodFilter = ? or viPeriodYearFilter = ?
then do:
    <M-12 run SetMessage
          (input  #T-13'The GL Period filter requires a value.':50(2285)T-13# (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-4337':U (icFcMsgNumber), 
           input  '':U (icFcExplanation), 
           input  '':U (icFcIdentification), 
           input  '':U (icFcContext), 
           output oiReturnStatus (oiReturnStatus)) in BClosingPostingsReport>
    assign oiReturnStatus = -1.                     
end.
else assign viYearPeriod = viPeriodYearFilter * 100 + viPeriodPeriodFilter.

<Q-3 run BaseFixedAssetControlGL (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input viYearPeriod, (TillYearPeriod)
           output dataset tqBaseFixedAssetControlGL) in BClosingPostingsReport >
<Q-14 run PostingHistByGLAndJournalType  (Start) in BClosingPostingsReport >
<Q-8 run GetNotLinkedFAAmounts  (Start) in BClosingPostingsReport >                                 
for each tqBaseFixedAssetControlGL break by tqBaseFixedAssetControlGL.tcGLCode by tqBaseFixedAssetControlGL.tcFAAssetCode by tqBaseFixedAssetControlGL.tiPostingLine_ID:
/*for each tqBaseFixedAssetControlGL break by tqBaseFixedAssetControlGL.tcGLCode by tqBaseFixedAssetControlGL.tcFAAssetCode:*/
    if first-of(tqBaseFixedAssetControlGL.tcGLCode)
    then do:
    /*we have to null all values*/
        assign vdPostingCreditCC    = 0
            vdPostingCreditLC       = 0
            vdPostingDebitCC        = 0
            vdPostingDebitLC        = 0
            vdPostingHistCreditCC   = 0
            vdPostingHistCreditLC   = 0
            vdPostingHistDebitCC    = 0
            vdPostingHistDebitLC    = 0
            vdUnlinkedCreditCC      = 0
            vdUnlinkedCreditLC      = 0
            vdUnlinkedDebitCC       = 0
            vdUnlinkedDebitLC       = 0.
        
        empty temp-table tFAValuesRef.           
    end.
    
    if last-of(tqBaseFixedAssetControlGL.tiPostingLine_ID)
    then do:
        assign vdPostingCreditCC    = vdPostingCreditCC + tqBaseFixedAssetControlGL.tdPostingLineCreditCC
            vdPostingCreditLC       = vdPostingCreditLC + tqBaseFixedAssetControlGL.tdPostingLineCreditLC
            vdPostingDebitCC        = vdPostingDebitCC  + tqBaseFixedAssetControlGL.tdPostingLineDebitCC       
            vdPostingDebitLC        = vdPostingDebitLC  + tqBaseFixedAssetControlGL.tdPostingLineDebitLC.
    end.            
                        
    /*single fixed asset code and its amounts*/
    if last-of(tqBaseFixedAssetControlGL.tcFAAssetCode)
    then do:
        create tFAValuesRef.
        buffer-copy tqBaseFixedAssetControlGL to tFAValuesRef.                                        
        assign tFAValuesRef.tdPostingLineCreditCC   = vdPostingCreditCC
            tFAValuesRef.tdPostingLineCreditLC      = vdPostingCreditLC
            tFAValuesRef.tdPostingLineDebitCC       = vdPostingDebitCC
            tFAValuesRef.tdPostingLineDebitLC       = vdPostingDebitLC.
    end.        
        
    if last-of(tqBaseFixedAssetControlGL.tcGLCode)
    then do:                
        if vlNotLinkedFilter <> no
        then do:
            <Q-11 run GetNotLinkedFAAmounts (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input tqBaseFixedAssetControlGL.tiGL_ID, (GLID)
           input viYearPeriod, (TillYearPeriod)
           output dataset tqGetNotLinkedFAAmounts) in BClosingPostingsReport >
            for each tqGetNotLinkedFAAmounts:                                 
                if tqGetNotLinkedFAAmounts.tiFACapital_ID = 0 and
                   tqGetNotLinkedFAAmounts.tcJournalTypeCode <> {&JOURNALTYPE-YEARLYCLOSING}
                then do:
                    assign vdUnlinkedCreditCC   = vdUnlinkedCreditCC + tqGetNotLinkedFAAmounts.tdPostingLineCreditCC
                        vdUnlinkedCreditLC      = vdUnlinkedCreditLC + tqGetNotLinkedFAAmounts.tdPostingLineCreditLC
                        vdUnlinkedDebitCC       = vdUnlinkedDebitCC  + tqGetNotLinkedFAAmounts.tdPostingLineDebitCC
                        vdUnlinkedDebitLC       = vdUnlinkedDebitLC  + tqGetNotLinkedFAAmounts.tdPostingLineDebitLC.       
                end.        
            end.                
        end.        
    
        <Q-16 run PostingHistByGLAndJournalType (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input tqBaseFixedAssetControlGL.tiGL_ID, (GL_ID)
           input ?, (GLCode)
           input viYearPeriod, (YearPeriod)
           output dataset tqPostingHistByGLAndJournalType) in BClosingPostingsReport >                                     
                                         
        for each tqPostingHistByGLAndJournalType:
            if tqPostingHistByGLAndJournalType.tcJournalTypeCode <> {&JOURNALTYPE-YEARLYCLOSING}
            then 
            assign vdPostingHistCreditCC    = vdPostingHistCreditCC + tqPostingHistByGLAndJournalType.tdPostingHistBalanceCreditCC
                vdPostingHistCreditLC       = vdPostingHistCreditLC + tqPostingHistByGLAndJournalType.tdPostingHistBalanceCreditLC
                vdPostingHistDebitCC        = vdPostingHistDebitCC  + tqPostingHistByGLAndJournalType.tdPostingHistBalanceDebitCC
                vdPostingHistDebitLC        = vdPostingHistDebitLC  + tqPostingHistByGLAndJournalType.tdPostingHistBalanceDebitLC.
        end.  
        /*if there is a differ we print it*/
        if (vdPostingCreditCC <> vdPostingHistCreditCC or
            vdPostingCreditLC <> vdPostingHistCreditLC or
            vdPostingDebitCC  <> vdPostingHistDebitCC  or 
            vdPostingDebitLC  <> vdPostingHistDebitLC)
        then do:
            /*fixed asset rows - rowtype = DET*/
            for each tFAValuesRef:
                create tqFAControlGLBalance.                       
                buffer-copy tFAValuesRef to tqFAControlGLBalance.
                assign tqFAControlGLBalance.tcRowCode   = '1DET':U.
            end.           
            
            /*unlinked postings - rowtype = UNLINK*/
            if(vdUnlinkedCreditCC <> 0 or vdUnlinkedCreditLC <> 0 or
               vdUnlinkedDebitCC  <> 0 or vdUnlinkedDebitLC  <> 0)
            then do:                    
                create tqFAControlGLBalance.
                assign tqFAControlGLBalance.tcGLCode                = tqBaseFixedAssetControlGL.tcGLCode
                    tqFAControlGLBalance.tcRowCode                  = '2UNLINK':U
                    tqFAControlGLBalance.tdPostingLineCreditCC      = vdUnlinkedCreditCC
                    tqFAControlGLBalance.tdPostingLineCreditLC      = vdUnlinkedCreditLC
                    tqFAControlGLBalance.tdPostingLineDebitCC       = vdUnlinkedDebitCC
                    tqFAControlGLBalance.tdPostingLineDebitLC       = vdUnlinkedDebitLC.
            end.                    
            
            /*gl summary - rowtype = GL*/
            create tqFAControlGLBalance.
            assign tqFAControlGLBalance.tcGLCode                = tqBaseFixedAssetControlGL.tcGLCode
                tqFAControlGLBalance.tcRowCode                  = '3GL':U
                tqFAControlGLBalance.tdPostingLineCreditCC      = vdPostingCreditCC
                tqFAControlGLBalance.tdPostingLineCreditLC      = vdPostingCreditLC
                tqFAControlGLBalance.tdPostingLineDebitCC       = vdPostingDebitCC
                tqFAControlGLBalance.tdPostingLineDebitLC       = vdPostingDebitLC.
                
            /*postinghist - rowtype = HIST*/                
            create tqFAControlGLBalance.
            assign tqFAControlGLBalance.tcGLCode                = tqBaseFixedAssetControlGL.tcGLCode
                tqFAControlGLBalance.tcRowCode                  = '4HIST':U
                tqFAControlGLBalance.tdPostingLineCreditCC      = vdPostingHistCreditCC
                tqFAControlGLBalance.tdPostingLineCreditLC      = vdPostingHistCreditLC
                tqFAControlGLBalance.tdPostingLineDebitCC       = vdPostingHistDebitCC
                tqFAControlGLBalance.tdPostingLineDebitLC       = vdPostingHistDebitLC.
                
            /*difference - rowtype = DIFF*/                
            create tqFAControlGLBalance.
            assign tqFAControlGLBalance.tcGLCode                = tqBaseFixedAssetControlGL.tcGLCode
                tqFAControlGLBalance.tcRowCode                  = '5DIFF':U
                tqFAControlGLBalance.tdPostingLineCreditCC      = vdPostingCreditCC - vdPostingHistCreditCC
                tqFAControlGLBalance.tdPostingLineCreditLC      = vdPostingCreditLC - vdPostingHistCreditLC
                tqFAControlGLBalance.tdPostingLineDebitCC       = vdPostingDebitCC  - vdPostingHistDebitCC
                tqFAControlGLBalance.tdPostingLineDebitLC       = vdPostingDebitLC  - vdPostingHistDebitLC.                                   
        end.                                                                                        
    end.   
end. 
<Q-9 run GetNotLinkedFAAmounts  (Stop) in BClosingPostingsReport >
<Q-15 run PostingHistByGLAndJournalType  (Stop) in BClosingPostingsReport >