project QadFinancials > class BBankEntry > method ValidateComponentPreExchRateTol

Description

Validates that the exchange rate is within the tolerance specified for the invoice's company.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankEntry.ValidateComponent


program code (program4/bbankentry.p)

/* =================================================================================================== */
/* Method      : ValidateExchangeRateTolerance                                                         */
/* Desc        : This method validates, whether exchange rate between bank entry and supplier invoice  */
/*               is within defined percentage defined on entity level                                  */
/* =================================================================================================== */
/* Clear the temporary table with Company definition first */
empty temp-table tqCompanyPropertyByIdCode.

/* Go through all undeleted records */
for each t_sBankState where
         t_sBankState.tc_Status          <> "D":U,
    each t_sBankStateLine where
         t_sBankStateLine.tc_ParentRowid  = t_sBankState.tc_Rowid and 
         t_sBankStateLine.tc_Status      <> "D":U,
    each t_sBankStateAlloc where
         t_sBankStateAlloc.tc_ParentRowid = t_sBankStateLine.tc_Rowid and 
         t_sBankStateAlloc.tc_Status      <> "D":U :
    

    /* Get tollerance values from company definition */
    <M-33 run ValidateComponentPreExchRateTolGetPerc
       (input  t_sBankStateAlloc.Company_ID (iiCompanyId), 
        output vdARExchangeRateTolerance (odARExchangeRateTolerance), 
        output vdAPExchangeRateTolerance (odAPExchangeRateTolerance), 
        output vcCompany (ocCompanyCode), 
        output viFcReturnSuper (oiReturnStatus)) in BBankEntry>    
    if viFcReturnSuper <> 0 and oiReturnStatus > 0 then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper <  0 then next.
    
    /* Check whether supplier invoice is within exchange rate tolerance (AP) */
    if t_sBankStateAlloc.CInvoice_ID <> 0 and t_sBankStateAlloc.CInvoice_ID <> ? and
       vdAPExchangeRateTolerance     <> 0 and vdAPExchangeRateTolerance     <> ? and
       t_sBankStateAlloc.BankStateAllocBankAmountLC <> 0
    then do:
        
        if t_sBankStateAlloc.BankStateAllocDifferenceLC / t_sBankStateAlloc.BankStateAllocBankAmountLC * 100 >
           vdAPExchangeRateTolerance
        then do:
            assign vcMessage = trim(subst(#T-6'AP Exchange Tolerance is exceeding the limit of (&1) defined in the Entity (&2).':255(85277662)T-6#,string(vdAPExchangeRateTolerance),string(vcCompany))).
            <M-22 run SetMessage
               (input  vcMessage (icMessage), 
                input  '' (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sBankStateAlloc.tc_RowID (icRowid), 
                input  'QadFin-95609':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
            assign oiReturnStatus = -1.
        end. /* if(t_sBankStateAlloc.BankStateAllocDifferenceLC... */
    end. /* if(t_sBankStateAlloc.CInvoice_ID <> 0... */

    /* Check whether customer invoice is within exchange rate tolerance (AP) */
    if t_sBankStateAlloc.DInvoice_ID <> 0 and t_sBankStateAlloc.DInvoice_ID <> ? and
       vdARExchangeRateTolerance     <> 0 and vdARExchangeRateTolerance     <> ? and
       t_sBankStateAlloc.BankStateAllocBankAmountLC <> 0
    then do:
        if t_sBankStateAlloc.BankStateAllocDifferenceLC / t_sBankStateAlloc.BankStateAllocBankAmountLC * 100 >
           vdARExchangeRateTolerance 
        then do:
            assign vcMessage = trim(subst(#T-75'AR Exchange Tolerance is exceeding the limit of (&1) defined in the Entity (&2).':255(606970807)T-75#,string(vdARExchangeRateTolerance),string(vcCompany))).
            <M-83 run SetMessage
               (input  vcMessage (icMessage), 
                input  '' (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sBankStateAlloc.tc_RowID (icRowid), 
                input  'QadFin-446575':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
            assign oiReturnStatus = -1.
        end. /* if(t_sBankStateAlloc.BankStateAllocDifferenceLC... */
    end. /* if(t_sBankStateAlloc.DInvoice_ID <> 0... */

    /* ========================================================================== */
    /* Validate whether exchange rate tollerance is also correct for payment of   */
    /* payment documents and payment selections. All these are members of payment */
    /* collections                                                                */
    /* ========================================================================== */
    for each t_sBankStateAllocColl where
             t_sBankStateAllocColl.tc_ParentRowid = t_sBankStateAlloc.tc_Rowid and
             t_sBankStateAllocColl.tc_Status     <> "D":U :

        /* Get tollerance values from company definition */
        <M-87 run ValidateComponentPreExchRateTolGetPerc
           (input  t_sBankStateAllocColl.Company_ID (iiCompanyId), 
            output vdARExchangeRateTolerance (odARExchangeRateTolerance), 
            output vdAPExchangeRateTolerance (odAPExchangeRateTolerance), 
            output vcCompany (ocCompanyCode), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>    
        if viFcReturnSuper <> 0 and oiReturnStatus > 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper <  0 then next.
    
        /* Supplier payment document */
        if t_sBankStateAllocColl.CDocument_ID <> ? and t_sBankStateAllocColl.CDocument_ID <> 0 and
           vdAPExchangeRateTolerance          <> 0 and vdAPExchangeRateTolerance          <> ? and
           t_sBankStateAllocColl.BankStateAllocCollBankAmLC <> 0
        then do:
             if t_sBankStateAllocColl.BankStateAllocCollDiffLC / t_sBankStateAllocColl.BankStateAllocCollBankAmLC * 100
                > vdAPExchangeRateTolerance
             then do:
                 assign vcMessage = trim(subst(#T-58'AP Exchange Tolerance is exceeding the limit of (&1) defined in the Entity (&2).':255(85277662)T-58#,string(vdAPExchangeRateTolerance),string(vcCompany))).
                 <M-69 run SetMessage
                    (input  vcMessage (icMessage), 
                     input  '' (icArguments), 
                     input  '' (icFieldName), 
                     input  '' (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  t_sBankStateAllocColl.tc_RowID (icRowid), 
                     input  'QadFin-719308':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                assign oiReturnStatus = -1.
            end.
        end. /* if t_sBankStateAllocColl.CDocument_ID <> ? and ... */

        /* Customer payment document */
        if t_sBankStateAllocColl.DDocument_ID <> ? and t_sBankStateAllocColl.DDocument_ID <> 0 and
           vdARExchangeRateTolerance          <> 0 and vdARExchangeRateTolerance          <> ? and
           t_sBankStateAllocColl.BankStateAllocCollBankAmLC <> 0
        then do:
             if t_sBankStateAllocColl.BankStateAllocCollDiffLC / t_sBankStateAllocColl.BankStateAllocCollBankAmLC * 100
                > vdARExchangeRateTolerance
             then do:
                 assign vcMessage = trim(subst(#T-21'AR Exchange Tolerance is exceeding the limit of (&1) defined in the Entity (&2).':255(606970807)T-21#,string(vdARExchangeRateTolerance),string(vcCompany))).
                 <M-61 run SetMessage
                    (input  vcMessage (icMessage), 
                     input  '' (icArguments), 
                     input  '' (icFieldName), 
                     input  '' (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  t_sBankStateAllocColl.tc_RowID (icRowid), 
                     input  'QadFin-660410':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                assign oiReturnStatus = -1.
            end.
        end. /* if t_sBankStateAllocColl.DDocument_ID <> ? and ... */
    end. /* for each t_sBankStateAllocColl where */

end. /* for each t_sBankStateAlloc where */