project QadFinancials > class BPaymentSelection > method Calculate01

Description

BTS=3934 - The code from the calculate method was moved into this method to improve performance towards the CalculatePaySelLine. As both methods are defined in Segment 3, no parameters have to be used and the index on rowid-parentrowid can be used.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.Calculate


program code (program3/bpaymentselection.p)

assign vlQCI = false
       vlQDI = false
       vlQPP = false.
       
for each tPaySel:
    <M-1 run ApiBankNumberInfo (input  tPaySel.GL_ID (iiGL_ID), 
                                input  '':U (icGLCode), 
                                output vcBankNumber (ocBankNumber), 
                                output vcBankCurrencyCode (ocBankCurrencyCode), 
                                output vdBankBalanceBC (odBankBalanceBC), 
                                output viBankNumber_ID (oiBankNumber_ID), 
                                output viNumberOfDecimals (oiNumberOfDecimals), 
                                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
    assign tPaySel.tcBankNumber                = vcBankNumber
           tPaySel.tcPaySelCurrencyCode        = vcBankCurrencyCode
           tPaySel.tiNumDec                    = viNumberOfDecimals 
           tPaySel.tdBankAccountTotalBalanceBC = vdBankBalanceBC
           tPaySel.tcCreditTR                  = {&CREDITDEBITABBREVIATION-CREDIT-TR}
           tPaySel.tcDebitTR                   = {&CREDITDEBITABBREVIATION-DEBIT-TR}.
    
    <Q-19 run BankPayFormatByID (all) (Read) (NoCache)
       (input tPaySel.BankPayFormat_ID, (BankPayFormatId)
        input ?, (CompanyId)
        output dataset tqBankPayFormatByID) in BBankPayFormat >
    
    for each tqBankPayFormatByID where
        tqBankPayFormatByID.tiBankPayFormat_ID = tPaySel.BankPayFormat_ID
        no-lock:
        assign tPaySel.tcPayFormatTypeCode          = tqBankPayFormatByID.tcPayFormatTypeCode
               /* XS PWI 02/10/2007 NEW : now retrieved based on bankpayformat_id */
               tPaySel.tcBankNumber                 = tqBankPayFormatByID.tcBankNumber
               tPaySel.tcPayFormatTypePayInstrument = tqBankPayFormatByID.tcPayFormatTypePayInstrument
               tPaySel.tcBankNumberFormatted        = tqBankPayFormatByID.tcBankNumberFormatted
               tPaySel.tlBankNumberIsBankCharge     = tqBankPayFormatByID.tlBankNumberIsBankCharge
               tPaySel.tiOwnBankNumberId            = tqBankPayFormatByID.tiBankNumber_ID. 
     end.
    /* fill the calc fields of the PaySelLines */
    <M-10 run CalculatePaySelLine (input  no (ilPrepaymentOnly), 
                                   output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
   
    if viFcReturnSuper < 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.

    /* Fill in calculated fields for PaySelPayCode */
    <M-17 run CalculateHeaderPayAttributes
       (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>

    if viFcReturnSuper < 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.

end.


for each tPaySel:
    /* get Posting Information */
    if  tPaySel.GL_ID <> 0 and 
        tPaySel.GL_ID <> ?
    then do:
        <Q-5 run GLByPaySel (all) (Read) (Cache)
          (input viCompanyId, (CompanyId)
           input tPaySel.GL_ID, (GL_ID)
           output dataset tqGLByPaySel) in BGL >
        find first tqGLByPaySel no-error.
        if available tqGLByPaySel
        then assign tPaySel.tcAPDiscountAccountGLCode = tqGLByPaySel.tcBankAPDiscountGLCode
                    tPaySel.tcAPDiscountAccountGLDesc = tqGLByPaySel.tcBankAPDiscountGLDesc
                    tPaySel.tcGLDescription           = tqGLByPaySel.tcGLDescription.

        <M-18 run GetPaymentInstrument
           (input  tPaySel.BankPayFormat_ID (iiBankPayFormatID), 
            output vcPaymentInstrument (ocPaymentInstrument), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>            
                                
        <M-14 run DefaultValuesDocumentType
           (input  vcPaymentInstrument (icDocumentType), 
            input  tPaySel.GL_ID (iiBankGLID), 
            input  tPaySel.tcGLCode (icBankGLCode), 
            output tPaySel.tcTransferAccountGLCode (ocGLCode), 
            output tPaySel.tcTransferAccountGLDesc (ocGLDescription), 
            output tPaySel.tcPostingJournal (ocJournalCode), 
            output tPaySel.tlCreditDirectlyOnBank (olCreditDirectlyOnBank), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
    end.
    for each tPaySelPayCode where tPaySelPayCode.PaySel_ID = tPaySel.PaySel_ID no-lock:
        find first tPaySelPayCodeRef where
             tPaySelPayCodeRef.tc_Rowid = tPaySelPayCode.tc_Rowid
        no-error.
        if not available tPaySelPayCodeRef
        then do:
            create tPaySelPayCodeRef.
            buffer-copy tPaySelPayCode to tPaySelPayCodeRef. 
        end.
    end.
end.