project QadFinancials > class BPosting > method CalculateCCAmount

Description

Procedure for calculating consolidated currency amounts of posting


Parameters


iiCompanyIDinputinteger
idPostingLineCreditLCinputdecimal
idPostingLineCreditTCinputdecimal
idPostingLineDebitLCinputdecimal
idPostingLineDebitTCinputdecimal
itPostingDateinputdate
icCurrencyCodeinputcharacter
itInvoiceExchangeRateDateinputdateIf this is set, then it will be used as the date to calculate the exchange rate - set according to flag on entity
bdCCExchangeRateinput-outputdecimal
bdCCExchangeRateScaleinput-outputdecimal
blCurrencyFetchedinput-outputlogical
odPostingLineCreditCCoutputdecimal
odPostingLineDebitCCoutputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.AddPostingLineTax
method BPosting.AddPostingLineTaxForSuspDel
method BPosting.ValidateComponentPreAssignPostingLine
method BJournalEntry.GetPostingAmountByPostingLineId
method BJournalEntry.GetPostingInfoByPostingLineIDTT
method BJournalEntry.UpdatePostinglineCCAmts


program code (program4/bposting.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.

CALCULATEBLOCK:
do:
    if icCurrencyCode = vcCompanyCC
    then assign odPostingLineCreditCC = idPostingLineCreditTC
                odPostingLineDebitCC  = idPostingLineDebitTC
                bdCCExchangeRate      = 1
                bdCCExchangeRateScale = 1.
    else do :
        if vlDomainIsStatutory = false
        then do:
            assign odPostingLineCreditCC  = idPostingLineCreditLC
                   odPostingLineDebitCC   = idPostingLineDebitLC.
              assign vhFcComponent = ?.            
        end. /* if vlDomainIsStatutory = false */
        else do:
            if not blCurrencyFetched
            then do:
                /* use the passed in exchange rate and scale if not ? or 0 */
                if bdCCExchangeRate = 0 or bdCCExchangeRate = ? or
                    bdCCExchangeRateScale = 0 or bdCCExchangeRateScale = ?
                then do:
                    if itInvoiceExchangeRateDate <> ?
                    then assign vtExchangeRateDate = itInvoiceExchangeRateDate.
                    else assign vtExchangeRateDate = itPostingDate.
                    <M-69 run GetExchangeRate
                        (input  iiCompanyID (iiCompanyID), 
                         input  ? (iiFromCurrencyID), 
                         input  icCurrencyCode (icFromCurrencyCode), 
                         input  viCompanyCCId (iiToCurrencyID), 
                         input  ? (icToCurrencyCode), 
                         input  ? (iiExchangeRateTypeID), 
                         input  {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode), 
                         input  vtExchangeRateDate (itValidityDate), 
                         output bdCCExchangeRate (odExchangeRate), 
                         output bdCCExchangeRateScale (odExchangeScaleFactor), 
                         output viFcReturnSuper (oiReturnStatus)) in BPosting>
                    if viFcReturnSuper <> 0
                    then assign viLocalReturnStatus = viFcReturnSuper.
                    if viFcReturnSuper < 0
                    then leave CALCULATEBLOCK.
                end. /* if bdCCExchangeRate = 0 */

                assign blCurrencyFetched = true.
            end. /*  if not olCurrencyFetched */
          
            if idPostingLineDebitTC <> 0 and
               idPostingLineDebitTC <> ?
               then assign odPostingLineDebitCC  =   <M-6 RoundAmount
                                                        (input   idPostingLineDebitTC * bdCCExchangeRate * bdCCExchangeRateScale (idUnroundedAmount), 
                                                         input  viCompanyCCId (iiCurrencyID), 
                                                         input  vcCompanyCC (icCurrencyCode)) in business>.
            if idPostingLineCreditTC <> 0 and
               idPostingLineCreditTC <> ?
               then assign odPostingLineCreditCC =  <M-7 RoundAmount
                                                       (input  idPostingLineCreditTC * bdCCExchangeRate * bdCCExchangeRateScale (idUnroundedAmount), 
                                                        input  viCompanyCCId (iiCurrencyID), 
                                                        input  vcCompanyCC (icCurrencyCode)) in business>.
        end. /* else do: */
    end. /* else do: */
end. /* CALCULATEBLOCK: */

assign oiReturnStatus = viLocalReturnStatus.