project QadFinancials > class BAPMatching > method GetPendingVouchersAssignCostMethodsCCRate

Description

GetPendingVouchersAssignCostMethodsCCRate: submethod of GetPendingVouchers that is located in the same segment and that takes care of assigning the Cost-method related fields in tPendingVoucher and the assigning of the CCRate and CCScale


Parameters


icAPMatchingTcRowidinputcharacterAPMatchingTcRowid
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAPMatching.GetPendingVouchersLogCharges
method BAPMatching.GetPendingVouchersNoLogCharges
method BAPMatching.GetPendingVouchersPOShipper


program code (program7/bapmatching.p)

    
    /* ================================================================================================ */
    /* GetPendingVouchersAssignCostMethods: submethod of GetPendingVouchers that is located in the same */
    /* segment and that takes care of assigning the Cost-method related fields in tPendingVoucherAPM    */
    /* ================================================================================================ */
    
    /* ===================================================== */
    /* Default return-status                                 */
    /* Check the required record-availability                */
    /* ===================================================== */
    assign oiReturnStatus = -98.
    if not available tPendingVoucherAPM
    then do :
        assign oiReturnStatus  = -3
               vcMsgAPMatching = trim(substitute(#T-2'Internal error: information is missing.':255(49818)T-2#)) + chr(10) + 
                                 trim(substitute(#T-3'Missing record available: &1.':234(56668)T-3#,"tPendingVoucherAPM":U)) .
        <M-1 run SetMessage (input  vcMsgAPMatching (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  '':U (icRowid), 
                     input  'QadFin-5765':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        Return.
    end. /* if not avail tPendingVoucherAPM */
    
    /* ======================================================= */
    /* Make sure the correct APMatching record is available    */
    /* ======================================================= */
    if not available tAPMatching or 
       tAPMatching.tc_Rowid <> icAPMatchingTcRowid
    then Find tAPMatching where 
              tAPMatching.tc_Rowid = icAPMatchingTcRowid
              no-lock no-error. /* no error handling needed here as this is checked before */
    
    /* ======================================================= */
    /* Call method in BCosting the returns the costing methods */
    /* ======================================================= */
    if tPendingVoucherAPM.APMatchingLnPvodOrderType = {&APMATCHINGLNPVODORDERTYPE-PURCHASE} and
       tPendingVoucherAPM.APMatchingLnPvodItemType <> {&APMATCHINGLNPVODITEMTYPE-MEMO}
    then do:
        <M-4 run ApiGetCostingMethod
           (input  tPendingVoucherAPM.APMatchingLnPvodSite (icSite), 
            input  tPendingVoucherAPM.APMatchingLnPvodItem (icPart), 
            output vcDummy (ocGLCostSet), 
            output tPendingVoucherAPM.APMatchingLnPvodCostMtdGL (ocGLCostMethod), 
            output vcDummy (ocCurrentCostSet), 
            output tPendingVoucherAPM.APMatchingLnPvodCostMtdCur (ocCurrentCostMethod), 
            output viFcReturnSuper (oiReturnStatus)) in BMfgCosting>
        if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then Return.
    end. /* if tPendingVoucherAPM.APMatchingLnPvodOrderType = {&APMATCHINGLNPVODORDERTYPE-PURCHASE} */
    else assign tPendingVoucherAPM.APMatchingLnPvodCostMtdGL  = {&COSTMETHOD-NONE}
                tPendingVoucherAPM.APMatchingLnPvodCostMtdCur = {&COSTMETHOD-NONE}. 
            
    /* ============================================================================================================= */
    /* Assign the Rate between LC and SC (Statutory Currency). In this exceptional case the SC is based upon the LC  */
    /* as this is so on the operational - side where the PO-receipt posting is always made in LC (TC = LC). We thus  */
    /* have to do the same for the posting-lines that inverse some of the posting-lines of the PO-receipt posting.   */
    /* If SC = LC then this will be 1, else we will call GetExchangeRate                                             */
    /* ============================================================================================================= */
    if viCompanyCCId = viCompanyLCId
    then assign tPendingVoucherAPM.APMatchingLnPvodCCRate  = 1
                tPendingVoucherAPM.APMatchingLnPvodCCScale = 1.
    else if vcCompanyCC <> tPendingVoucherAPM.APMatchingLnPvodCurrency
    then do:
        <M-22 run GetExchangeRate
           (input  tAPMatching.Company_ID (iiCompanyID), 
            input  viCompanyLCId (iiFromCurrencyID), 
            input  ? (icFromCurrencyCode), 
            input  viCompanyCCId (iiToCurrencyID), 
            input  ? (icToCurrencyCode), 
            input  ? (iiExchangeRateTypeID), 
            input  {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode), 
            input  tPendingVoucherAPM.ttAPMatchingLnPvodEffDate (itValidityDate), 
            output tPendingVoucherAPM.APMatchingLnPvodCCRate (odExchangeRate), 
            output tPendingVoucherAPM.APMatchingLnPvodCCScale (odExchangeScaleFactor), 
            output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then Return.
    end. /* not if viCompanyCCId = viCompanyLCId */
    
    /* ===================================================== */
    /* Default return-status                                 */
    /* ===================================================== */
    if oiReturnStatus = -98
    then assign oiReturnStatus= 0.