project QadFinancials > class TSetStatutoryCurrency > method SetStatutoryCurrencyBasedOnTCPosting

Description

Assign the Statutory Currency amounts based on the amounts in TC and the exchange rate between TC and the newly entered SC.


Parameters


ocErrorMessageoutputcharacter
oiPostingLineCounteroutputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method TSetStatutoryCurrency.SetStatutoryCurrencyBasedOnTC


program code (program1/tsetstatutorycurrency.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.
       
STATCURRBLOCK:
do:   
    /* ======================================================================== */
    /* Update Postings                                                          */
    /* ======================================================================== */
    /* Go through each company of domain */
    for each Company of Domains no-lock,
        each Posting of Company no-lock,
        first Journal of Posting no-lock Transaction:
            
        assign vlIsPostingProcessed = false.

        
        /* Calculate posting date. Normally this is the date of posting, except case of reopeing balances */
        assign vtPostingPostingDate = Posting.PostingDate.

        if Posting.PostingPeriod = 00                                                                     and
           Posting.PostingText = #T-91'Year-End Closing: Bal. Sheet Reopening.':200(999890465)T-91#
        then assign vtPostingPostingDate = Posting.PostingDate - 1.
        
        /* Matching Postings are converted later on */
        if can-find(first APMAtching where
                          APMatching.Posting_ID = Posting.Posting_ID)
        then next.

        
        /* Clear all SC amounts that are incorrect and delete all posting lines previsously generated by this utility */
        <M-42 run PostingClearPreviousBalSCLines
           (output vcTempErrorMessage (ocErrorMessage), 
            output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
        assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
        if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper <  0 then leave STATCURRBLOCK.

        /* Check whether this posting was created for the Supplier payment */
        if not vlIsPostingProcessed
        then do:
            <M-46 run PostingForCDocument
               (input-output oiPostingLineCounter (biPostingLineCounter), 
                output vlIsPostingProcessed (olPostingIsProcessed), 
                output vcPostCCBalanceTo (ocPostCCBalanceTo), 
                output vcTempErrorMessage (ocErrorMessage), 
                output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
            assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
            if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
            if viFcReturnSuper <  0 then leave STATCURRBLOCK.
        end.

        /* Check whether this posting was created for the Customer payment */
        if not vlIsPostingProcessed
        then do:
            <M-96 run PostingForDDocument
               (input-output oiPostingLineCounter (biPostingLineCounter), 
                output vlIsPostingProcessed (olPostingIsProcessed), 
                output vcPostCCBalanceTo (ocPostCCBalanceTo), 
                output vcTempErrorMessage (ocErrorMessage), 
                output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
            assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
            if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
            if viFcReturnSuper <  0 then leave STATCURRBLOCK.
        end.

        /* Check whether this posting was created for the Open item adjustment */
        if not vlIsPostingProcessed
        then do:
            <M-50 run PostingForOIA
               (input-output oiPostingLineCounter (biPostingLineCounter), 
                output vlIsPostingProcessed (olPostingIsProcessed), 
                output vcPostCCBalanceTo (ocPostCCBalanceTo), 
                output vcTempErrorMessage (ocErrorMessage), 
                output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
            assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
            if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
            if viFcReturnSuper <  0 then leave STATCURRBLOCK.
        end.
        
        /* Check whether this posting was created for the Banking entry */
        if not vlIsPostingProcessed
        then do:
            <M-39 run PostingForBankCashEntry
               (input-output oiPostingLineCounter (biPostingLineCounter), 
                output vlIsPostingProcessed (olPostingIsProcessed), 
                output vcPostCCBalanceTo (ocPostCCBalanceTo), 
                output vcTempErrorMessage (ocErrorMessage), 
                output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
            assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
            if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
            if viFcReturnSuper <  0 then leave STATCURRBLOCK.
        end.
        
        /* Process any other posting */
        if not vlIsPostingProcessed
        then do:
            <M-84 run PostingForOthers
               (input-output oiPostingLineCounter (biPostingLineCounter), 
                output vlIsPostingProcessed (olPostingIsProcessed), 
                output vcPostCCBalanceTo (ocPostCCBalanceTo), 
                output vcTempErrorMessage (ocErrorMessage), 
                output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
            assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
            if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
            if viFcReturnSuper <  0 then leave STATCURRBLOCK.
        end.
                
        /* Create additional line to balance whole posting in Statutory currency */
        <M-40 run PostingCCBalance
           (input  vcPostCCBalanceTo (icPostCCBalanceTo), 
            output vcTempErrorMessage (ocErrorMessage), 
            output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
        assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.  
        if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper <  0 then leave STATCURRBLOCK.

    end. /* for each company where */
end. /* STATCURRBLOCK */

assign oiReturnStatus = viLocalReturnStatus.