project QadFinancials > class BDDocument > method AdditionalUpdatesGetBankGLInfo


Parameters


ilErrorIfNoDiscountAccountinputlogical
ilErrorIfNoCurrencyinputlogical
ocDiscountGLAccountoutputcharacterDiscount account as defined on bank GL account
ocInterestGLAccountoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDDocument.AdditionalUpdatesDCollection
method BDDocument.AdditionalUpdatesPostingPrePayment
method BDDocument.AdditionalUpdatesPostingXrefDIDisc
method BDDocument.AdditionalUpdatesPostingXrefDIInt
method BDDocument.AdditionalUpdatesDCollectionCopy


program code (program5/bddocument.p)

assign ocDiscountGLAccount = ?.

/* Check in local cache temp table whether details have been read already */
find tBankGLInfoDDoc where
     tBankGLInfoDDoc.tcBankGLCode = tDDocument.tcGLCode
     no-error.

/* If not available, get definition from database */
if not available tBankGLInfoDDoc
then do:
    if not vlIsQStartedGLByBankInfo
    then do:
        <Q-6 run GLByBankInfo (Start) in BGL >
        assign vlIsQStartedGLByBankInfo = true.
    end.

    <Q-7 run GLByBankInfo (all) (Read) (NoCache)
       (input tDDocument.Company_ID, (CompanyId)
        input ?, (GLID)
        input tDDocument.tcGLCode, (GLCode)
        output dataset tqGLByBankInfo) in BGL>

    find first tqGLByBankInfo where
               tqGLByBankInfo.tcGLCode = tDDocument.tcGLCode
               no-error.

    if not available tqGLByBankInfo
    then do:
        <M-8 run SetMessage
           (input  trim(#T-11'The discount account and currency for bank account $1 cannot be found.':250(1660)T-11#) (icMessage), 
            input  tDDocument.tcGLCode (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  tDDocument.tc_Rowid (icRowid), 
            input  'QADFIN-2566':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDDocument>

        assign oiReturnStatus = -1.
        return.
    end.

 /* if the interest account is not populate then use the discount account instead */
    create tBankGLInfoDDoc.
    assign tBankGLInfoDDoc.tcBankGLCode   = tDDocument.tcGLCode
           tBankGLInfoDDoc.tcCurrencyCode = if tqGLByBankInfo.tlGLIsLocalCurrency
                                            then vcCompanyLC
                                            else tqGLByBankInfo.tcCurrencyCode
           tBankGLInfoDDoc.tcDiscGLCode   = tqGLByBankInfo.tcBankARDiscountGLCode
           tBankGLInfoDDoc.tcIntGLCode    = if tqGLByBankInfo.tcBankARInterestGLCode <> "" then tqGLByBankInfo.tcBankARInterestGLCode
                                            else tqGLByBankInfo.tcBankARDiscountGLCode.
end.

if ilErrorIfNoDiscountAccount      and
  (tBankGLInfoDDoc.tcDiscGLCode = "":U or
   tBankGLInfoDDoc.tcDiscGLCode = ?)
then do:
    <M-9 run SetMessage
       (input  trim(#T-12'No discount account is defined for bank account $1.':250(919)T-12#) (icMessage), 
        input  tDDocument.tcGLCode (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  tDDocument.tc_Rowid (icRowid), 
        input  'QADFIN-2567':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDDocument>

    assign oiReturnStatus = -1.
end.

if ilErrorIfNoCurrency               and
  (tBankGLInfoDDoc.tcCurrencyCode = "":U or
   tBankGLInfoDDoc.tcCurrencyCode = ?)
then do:
    <M-10 run SetMessage
       (input  trim(#T-13'No currency is defined for bank account $1.':250(920)T-13#) (icMessage), 
        input  tDDocument.tcGLCode (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  tDDocument.tc_Rowid (icRowid), 
        input  'QADFIN-2565':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDDocument>

    assign oiReturnStatus = -1.
end.

/* Return value */
assign 
    ocDiscountGLAccount = tBankGLInfoDDoc.tcDiscGLCode
    ocInterestGLAccount = tBankGLInfoDDoc.tcIntGLCode.