project QadFinancials > class BBankEntry > method ValidateComponentPreUpdateBankStateAlloc

Description

update the lc amount in alloc


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankEntry.ValidateComponent


program code (program4/bbankentry.p)

/* ==================================== */
/* give some db fields the right value  */
/* ==================================== */
if can-find (first t_sBankStateAlloc where
                   t_sBankStateAlloc.tc_Status <> "":U and
                   t_sBankStateAlloc.CInvoice_ID <> 0 and
                   t_sBankStateAlloc.CInvoice_ID <> ?)
then do:                           
    for each t_sBankStateAlloc where
            (t_sBankStateAlloc.tc_Status = "C":U or
             t_sBankStateAlloc.tc_Status = "N":U) and
            (t_sBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-CCOLL} or
             t_sBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-DCOLL}) :
        find first t_sBankStateLine where
                   t_sBankStateLine.tc_Rowid = t_sBankStateAlloc.tc_ParentRowid 
                   no-error.
        if not available t_sBankStateLine
        then leave.

        find first t_sBankState where
                   t_sBankState.tc_Rowid = t_sBankStateLine.tc_ParentRowid 
                   no-error.
        if not available t_sBankState
        then leave.

        if t_sBankStateAlloc.tcDocCurrencyCode = vcCompanyLC
        then assign t_sBankStateAlloc.BankStateAllocAmountLC = t_sBankStateAlloc.BankStateAllocAmountTC.
        else do:
            /*JBA BTS 4906 use the correct exchange rate type*/
            assign vcExchangeRateType = <M-80 GetExchangeRateType () in BBankEntry>.
            <M-24 run GetExchangeRate
                (input  t_sBankState.Company_ID (iiCompanyID), 
                 input  ? (iiFromCurrencyID), 
                 input  t_sBankStateAlloc.tcDocCurrencyCode (icFromCurrencyCode), 
                 input  viCompanyLCID (iiToCurrencyID), 
                 input  ? (icToCurrencyCode), 
                 input  ? (iiExchangeRateTypeID), 
                 input  vcExchangeRateType (icExchangeRateTypeCode), 
                 input  t_sBankStateLine.BankStateLineValueDate (itValidityDate), 
                 output vdBankStateAllocExchangeRate (odExchangeRate), 
                 output vdBankStateAllocExchRateScale (odExchangeScaleFactor), 
                 output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
            if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
            then assign oiReturnStatus = viFcReturnSuper.

            assign t_sBankStateAlloc.BankStateAllocAmountLC = <M-65 RoundAmount
          (input  t_sBankStateAlloc.BankStateAllocAmountTC * vdBankStateAllocExchangeRate * vdBankStateAllocExchRateScale (idUnroundedAmount), 
           input  viCompanyLCId (iiCurrencyID), 
           input  vcCompanyLC (icCurrencyCode)) in business>.
                /* round(t_sBankStateAlloc.BankStateAllocAmountTC * vdBankStateAllocExchangeRate * vdBankStateAllocExchRateScale, viCompanyLCDec). */
        end.
    end.

/*BKW: Hold amount validation */

    /* BLF-4149
     * Method ValidateHoldAmountAndLockPayment does not do updates,
     * so this instance of BCInvoice should not be added to current transaction.
     */
    <I-29 {bFcStartAndOpenInstance
         &CLASS                = "BCInvoice"}>
    
    for each t_sBankStateAlloc where
            (t_sBankStateAlloc.tc_Status = "C":U or
             t_sBankStateAlloc.tc_Status = "N":U) and
            (t_sBankStateAlloc.CInvoice_ID <> 0 and
             t_sBankStateAlloc.CInvoice_ID <> ?):

        <M-32 run ValidateHoldAmountAndLockPayment
           (input  t_sBankStateAlloc.CInvoice_ID (iiCInvoiceID), 
            input  t_sBankStateAlloc.BankStateAllocAmountTC (idAllocAmount), 
            input  '' (icFieldName), 
            input  '' (icFieldValue), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        if(viFcReturnSuper < 0) then
            oiReturnStatus = viFcReturnSuper.
    end.
    
    <I-45 {bFcCloseAndStopInstance
         &CLASS           = "BCInvoice"}>
end. /* if can-find (first */
/*BKW*/