project QadFinancials > class BBankEntry > method DefaultBankStateAllocBank

Description

Default the Bank State Alloc Bank Fields, this method can be called by UI


Parameters


icDocCurrencyCodeinputcharacterDocument Currency Code
icCurrencyCodeinputcharacterCurrency Code : bank state currency code
idBankStateLineExtBankRateinputdecimalBank State Line Ext Bank Rate : Bank exchange rate in original currency
idBankStateLineExtBankRateScaleinputdecimal
icBankStateLineExtCurrencyinputcharacterBank State Line Ext Currency : original Currency Code
idBankStateAllocAmountTCinputdecimalBank State Allocation Amount in TC
idBankStateAllocAmountLCinputdecimalBank State Allocation Amount in LC
idBankStateAllocDiscountTCinputdecimalBank State Allocation Discount in TC
idBankStateAllocDiscountLCinputdecimalBank State Allocation Discount in LC
itBankStateLineValueDateinputdateBank State Line Value Date
idDocExchangeRateinputdecimalDocument Exchange Rate
idDocExchangeRateScaleinputdecimalDocument Scale Factor
ilIsPrepaymentinputlogicalIdentify whether the it is creating a prepayment.
idBankStateAllocWHTAmtTCinputdecimalBank State Allocation - WHT Amount TC
odBankStateAllocBankAmountTCoutputdecimalBank State Alloc Bank Amount TC : Allocation Amount in Bank Currency
odBankStateAllocBankAmountLCoutputdecimalBank State Alloc Bank Amount LC : Allocation amount in LC for bank currency
odBankStateAllocBankRateoutputdecimalBank State Alloc Bank Rate : Accounting Exchange Rate in bank currency
otBankStateAllocBankValueDateoutputdateBank State Alloc Bank Value Date : Validity Date in bank currency
odBankStateAllocBankDiscTCoutputdecimalBank Discount TC
odBankStateAllocBankDiscLCoutputdecimalBank Discount BC
odBankStateAllocBankRateScaleoutputdecimal
odBankStateAllocBankWHTAmtTCoutputdecimalBank State Allocation - Bank WHT Amount TC
odBankStateAllocBankWHTAmtLCoutputdecimalBank State Allocation - Bank WHT Amount LC
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankEntry.AddBankEntryAllocateDocument
method BBankEntry.CreateDeduction
method BBankEntry.CreatePrepayment

QadFitnesse
method BBankEntry.AddBankEntryAllocationV02


program code (program3/bbankentry.p)

assign vdExchangeRate = 0
           vdExchangeRateScale = 0
           vcExchangeRateTypeCode = <M-9 GetExchangeRateType () in BBankEntry>.

    /* ====================== */
    /* replace unknown values */
    /* ====================== */
    if icDocCurrencyCode = ? then assign icDocCurrencyCode = "":U.
    if icCurrencyCode = ? then assign icCurrencyCode = "":U.
    if idBankStateLineExtBankRate = ? then assign idBankStateLineExtBankRate = 0.
    if idBankStateLineExtBankRateScale = ? then assign idBankStateLineExtBankRateScale = 1.
    if icBankStateLineExtCurrency = ? then assign icBankStateLineExtCurrency = "":U.
    if idBankStateAllocAmountTC = ? then assign idBankStateAllocAmountTC = 0.
    if idBankStateAllocDiscountTC = ? then assign idBankStateAllocDiscountTC = 0.
    if idDocExchangeRate = ? then assign idDocExchangeRate = 0.
    if idDocExchangeRateScale = ? then assign idDocExchangeRateScale = 0.
    if idBankStateAllocWHTAmtTC = ? then assign idBankStateAllocWHTAmtTC = 0.

    /* ===================== */
    /* calculate the amounts */
    /* ===================== */
    if icDocCurrencyCode = icCurrencyCode
    then assign odBankStateAllocBankAmountTC  = idBankStateAllocAmountTC
                odBankStateAllocBankWHTAmtTC  = idBankStateAllocWHTAmtTC
                odBankStateAllocBankRate      = 1
                odBankStateAllocBankRateScale = 1
                vdDiscountTC                  = idBankStateAllocDiscountTC
                vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC
                vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC.
    else if idBankStateLineExtBankRate <> 0 and
            icBankStateLineExtCurrency  = icDocCurrencyCode
         then assign odBankStateAllocBankAmountTC = <M-16 RoundAmount
                                                       (input  idBankStateAllocAmountTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale (idUnroundedAmount), 
                                                        input  0 (iiCurrencyID), 
                                                        input  icBankStateLineExtCurrency (icCurrencyCode)) in business>
                     vdDiscountTC                 = <M-17 RoundAmount
                                                       (input  idBankStateAllocDiscountTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale (idUnroundedAmount), 
                                                        input  0 (iiCurrencyID), 
                                                        input  icBankStateLineExtCurrency (icCurrencyCode)) in business>
                     odBankStateAllocBankWHTAmtTC = <M-64 RoundAmount
                                                       (input  idBankStateAllocWHTAmtTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale (idUnroundedAmount), 
                                                        input  0 (iiCurrencyID), 
                                                        input  icBankStateLineExtCurrency (icCurrencyCode)) in BBankEntry>                                                        
                     vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale
                     vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale.
        
         else do:
             if idDocExchangeRate <> 0 and idDocExchangeRateScale <> 0 and vcCompanyLC = icCurrencyCode
             then assign odBankStateAllocBankAmountTC = <M-25 RoundAmount
                                                           (input  idBankStateAllocAmountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount), 
                                                            input  0 (iiCurrencyID), 
                                                            input  icCurrencyCode (icCurrencyCode)) in business>
                         vdDiscountTC                 = <M-26 RoundAmount
                                                           (input  idBankStateAllocDiscountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount), 
                                                            input  0 (iiCurrencyID), 
                                                            input  icCurrencyCode (icCurrencyCode)) in business>
                         odBankStateAllocBankWHTAmtTC = <M-66 RoundAmount
                                                           (input  idBankStateAllocWHTAmtTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount), 
                                                            input  0 (iiCurrencyID), 
                                                            input  icCurrencyCode (icCurrencyCode)) in BBankEntry>                                   
                         vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC * idDocExchangeRate * idDocExchangeRateScale
                         vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC * idDocExchangeRate * idDocExchangeRateScale.
             else do:
                <M-69 run GetExchangeRate
                   (input  viCompanyId (iiCompanyID), 
                    input  ? (iiFromCurrencyID), 
                    input  icDocCurrencyCode (icFromCurrencyCode), 
                    input  ? (iiToCurrencyID), 
                    input  icCurrencyCode (icToCurrencyCode), 
                    input  ? (iiExchangeRateTypeID), 
                    input  vcExchangeRateTypeCode (icExchangeRateTypeCode), 
                    input  itBankStateLineValueDate (itValidityDate), 
                    output vdExchangeRate (odExchangeRate), 
                    output vdExchangeRateScale (odExchangeScaleFactor), 
                    output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                 if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
                 then assign oiReturnStatus = viFcReturnSuper. 
                 if oiReturnStatus < 0
                 then return.
                 assign odBankStateAllocBankAmountTC = <M-20 RoundAmount
                                                          (input  idBankStateAllocAmountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount), 
                                                           input  0 (iiCurrencyID), 
                                                           input  icCurrencyCode (icCurrencyCode)) in business>
                        vdDiscountTC                 = <M-21 RoundAmount
                                                          (input  idBankStateAllocDiscountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount), 
                                                           input  0 (iiCurrencyID), 
                                                           input  icCurrencyCode (icCurrencyCode)) in business>
                        odBankStateAllocBankWHTAmtTC = <M-58 RoundAmount
                                                          (input  idBankStateAllocWHTAmtTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount), 
                                                           input  0 (iiCurrencyID), 
                                                           input  icCurrencyCode (icCurrencyCode)) in BBankEntry>                                                                
                        vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC * vdExchangeRate * vdExchangeRateScale
                        vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC * vdExchangeRate * vdExchangeRateScale.
             end.
         end.

    /* If it is not creating a prepayment, calculate the LC via the exchange rate in DB. */
    if ilIsPrepayment = false
    then do:
        /* rate between banking currency and local currency of the company the banking entry is created in. */
        if icCurrencyCode = vcCompanyLC
        then assign odBankStateAllocBankRate      = 1
                    odBankStateAllocBankRateScale = 1.
    
        else  if icBankStateLineExtCurrency = vcCompanyLC 
                 
             then assign odBankStateAllocBankRate      = 1 / idBankStateLineExtBankRate
                         odBankStateAllocBankRateScale = idBankStateLineExtBankRateScale.
             else do:
                <M-70 run GetExchangeRate
                   (input  viCompanyId (iiCompanyID), 
                    input  ? (iiFromCurrencyID), 
                    input  icCurrencyCode (icFromCurrencyCode), 
                    input  viCompanyLCId (iiToCurrencyID), 
                    input  ? (icToCurrencyCode), 
                    input  ? (iiExchangeRateTypeID), 
                    input  vcExchangeRateTypeCode (icExchangeRateTypeCode), 
                    input  itBankStateLineValueDate (itValidityDate), 
                    output odBankStateAllocBankRate (odExchangeRate), 
                    output odBankStateAllocBankRateScale (odExchangeScaleFactor), 
                    output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
                then assign oiReturnStatus = viFcReturnSuper.           
                if oiReturnStatus < 0
                then return.
             end.
    
        /* ================================================================== */
        /* calculate Allocation LC in Bank currency and give date right value */
        /* ================================================================== */
        assign otBankStateAllocBankValueDate = itBankStateLineValueDate
               odBankStateAllocBankAmountLC  = <M-22 RoundAmount
                                                  (input  vdUnroundBankStateAllocAmountTC * odBankStateAllocBankRate * odBankStateAllocBankRateScale (idUnroundedAmount), 
                                                   input  viCompanyLCId (iiCurrencyID), 
                                                   input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
               /* S_BTS 2617 */
               /*odBankStateAllocBankDiscTC               = vdDiscountTC*/
               odBankStateAllocBankDiscTC    = <M-23 RoundAmount
                                                  (input  vdDiscountTC (idUnroundedAmount), 
                                                   input  0 (iiCurrencyID), 
                                                   input  icCurrencyCode (icCurrencyCode)) in BApplicationProperty>
               /* E_BTS 2617 */
               odBankStateAllocBankDiscLC    = <M-24 RoundAmount
                                                  (input  vdDiscountTC * odBankStateAllocBankRate * odBankStateAllocBankRateScale (idUnroundedAmount), 
                                                   input  viCompanyLCId (iiCurrencyID), 
                                                   input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
               odBankStateAllocBankWHTAmtLC  = <M-68 RoundAmount
                                                  (input  vdUnroundBankStateAllocWHTAmtTC * odBankStateAllocBankRate * odBankStateAllocBankRateScale (idUnroundedAmount), 
                                                   input  viCompanyLCId (iiCurrencyID), 
                                                   input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.
    end.
    /* If it is creating a prepayment, assign the LC values and then calculate the exchangerate via LC and TC fields. */
    else do:
        if idDocExchangeRate <> 0 and idDocExchangeRateScale <> 0 and vcCompanyLC = icCurrencyCode
             then assign odBankStateAllocBankAmountTC = <M-91 RoundAmount
                                                           (input  idBankStateAllocAmountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount), 
                                                            input  0 (iiCurrencyID), 
                                                            input  icCurrencyCode (icCurrencyCode)) in business>
                         vdDiscountTC                 = <M-7 RoundAmount
                                                           (input  idBankStateAllocDiscountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount), 
                                                            input  0 (iiCurrencyID), 
                                                            input  icCurrencyCode (icCurrencyCode)) in business>
                        vdUnroundBankStateAllocAmountTC=idBankStateAllocAmountTC *  idDocExchangeRate * idDocExchangeRateScale.
        
        assign odBankStateAllocBankAmountLC = <M-13 RoundAmount
                                                 (input  idBankStateAllocAmountLC (idUnroundedAmount), 
                                                  input  0 (iiCurrencyID), 
                                                  input  vcCompanyLC (icCurrencyCode)) in business>
               odBankStateAllocBankRate = odBankStateAllocBankAmountLC / odBankStateAllocBankAmountTC.
    end.