project QadFinancials > class BBankImportLine > method GetDDocumentByBankImpLine

Description

This method searches for Debtor Document which matches information from data incoming bank.


Parameters


oiDDocumentIdoutputintegermatched DDocument ID
oiDDocumentYearoutputintegermatched DDocument Year
ocDDocumentTypeoutputcharactermatched DDocument Type
oiDDocumentNumberoutputintegermatched DDocument Number
iiCurrencyIDinputintegerCurrency ID
ilIsClearErrMsginputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankImportLine.ProcessBankImpLineDDocStatusChg
method BBankImportLine.ProcessBankImpLineNewBankEntry


program code (program6/bbankimportline.p)

/* =================================================================================================== */
/* Method      : GetDDocumentByBankImpLine                                                             */
/* Desc        : This method searches for Debtor Document which matches information from data comming  */
/*               bank                                                                                  */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (O)  DDocumentId          ID of the find document                                          */
/*          (O)  DDocumentYear        Year of the DDocument                                            */
/*          (O)  DDocumentType        Type of the DDocument                                            */
/*          (O)  DDocumentNumber      Number of the document                                           */
/* =================================================================================================== */

/* =================================================================================================== */
/* if using custom matching logic, then return directly without executing standard matching logic.     */
/* =================================================================================================== */
if vlUseCustomMatching = yes
then return.

if ilIsClearErrMsg = ? then assign ilIsClearErrMsg = false.

assign oiReturnStatus = -98
       vcParam = '':U
       vcCriteria = '':U.

/* =================================================================================================== */
/* Default output values                                                                               */
/* =================================================================================================== */
assign oiDDocumentId     = ?
       oiDDocumentYear   = ?
       ocDDocumentType   = ?
       oiDDocumentNumber = ?.

/* =================================================================================================== */
/* Validate input parameters                                                                           */
/* =================================================================================================== */
if not available tBankImpLine
then do:
    assign vcMessage = trim(#T-2'Missing definition of imported bank line.':255(67965)T-2#).
    <M-1 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'S':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-7591':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
    assign oiReturnStatus = -1.
    return.
end. /* if not available tBankImpLine */


assign vcExcludeDDocStatusList = {&DOCUMENTSTATUS-PAID} + "," + {&DOCUMENTSTATUS-BOUNCED}.

/* =================================================================================================== */
/* Start queryies                                                                                      */
/* =================================================================================================== */
<Q-9 run DDocumentForBankImport  (Start) in BDDocument >


/* =================================================================================================== */
/* If the document was selected by user already, just get detail information                           */
/* =================================================================================================== */
empty temp-table tqDDocumentForBankImport.

if tBankImpLine.DDocument_ID <> ? and
   tBankImpLine.DDocument_ID <> 0
then do:
    <Q-8 run DDocumentForBankImport (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input ?, (Reference)
        input ?, (OwnBankNumberId)
        input ?, (AmountTC)
        input ?, (IncassoSelectCode)
        input ?, (DebtorId)
        input ?, (DebtorCode)
        input tBankImpLine.DDocument_ID, (DDocumentId)
        input iiCurrencyID, (CurrencyID)
        input vcExcludeDDocStatusList, (ExcludeDDocStatusList)
        output dataset tqDDocumentForBankImport) in BDDocument>
    
    find first tqDDocumentForBankImport no-error.

    assign vcCriteria = "DDocument_ID = " + string(tBankImpLine.DDocument_ID).
end.

/* =================================================================================================== */
/* Try to find Debtor Document by Payment number (check number)                                        */
/* =================================================================================================== */
if not available tqDDocumentForBankImport  and
   tBankImpLine.BankImpLinePaymentNbr <> ? and
   tBankImpLine.BankImpLinePaymentNbr <> '':U
then do:
    <Q-3 run DDocumentForBankImport (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input tBankImpLine.BankImpLinePaymentNbr, (Reference)
        input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
        input ?, (AmountTC)
        input ?, (IncassoSelectCode)
        input ?, (DebtorId)
        input ?, (DebtorCode)
        input ?, (DDocumentId)
        input iiCurrencyID, (CurrencyID)
        input vcExcludeDDocStatusList, (ExcludeDDocStatusList)
        output dataset tqDDocumentForBankImport) in BDDocument>
    
    find first tqDDocumentForBankImport no-error.
    assign vcCriteria = "Reference = " + tBankImpLine.BankImpLinePaymentNbr.
end. /* if tBankImpLine.BankImpLinePaymentNbr <> ? */

/* =================================================================================================== */
/* Try to find Debtor Document by Payment reference                                                    */
/* =================================================================================================== */
if not available tqDDocumentForBankImport  and
   tBankImpLine.BankImpLinePaymentRef <> ? and
   tBankImpLine.BankImpLinePaymentRef <> '':U
then do:
    <Q-4 run DDocumentForBankImport (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input tBankImpLine.BankImpLinePaymentRef, (Reference)
        input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
        input ?, (AmountTC)
        input ?, (IncassoSelectCode)
        input ?, (DebtorId)
        input ?, (DebtorCode)
        input ?, (DDocumentId)
        input iiCurrencyID, (CurrencyID)
        input vcExcludeDDocStatusList, (ExcludeDDocStatusList)
        output dataset tqDDocumentForBankImport) in BDDocument>
    find first tqDDocumentForBankImport no-error.
    assign vcCriteria = "Reference = " + tBankImpLine.BankImpLinePaymentRef.
end. /* if not available tqDDocumentForBankImport */


/* =================================================================================================== */
/* Try to find Debtor Document by Debtor and Amount                                                    */
/* =================================================================================================== */
if not available tqDDocumentForBankImport and
   tBankImpLine.Debtor_ID <> 0            and
   tBankImpLine.Debtor_ID <> ?            and
   tBankImpLine.BankImpLineAmountTC <> 0  and
   tBankImpLine.BankImpLineAmountTC <> ?
then do:
    <Q-5 run DDocumentForBankImport (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input ?, (Reference)
        input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
        input tBankImpLine.BankImpLineAmountTC, (AmountTC)
        input ?, (IncassoSelectCode)
        input tBankImpLine.Debtor_ID, (DebtorId)
        input ?, (DebtorCode)
        input ?, (DDocumentId)
        input iiCurrencyID, (CurrencyID)
        input vcExcludeDDocStatusList, (ExcludeDDocStatusList)
        output dataset tqDDocumentForBankImport) in BDDocument>
    find first tqDDocumentForBankImport no-error.
    assign vcCriteria = "DebtorCode = " + tBankImpLine.BankImpLineDebtorCode + 
                        ";AmountTC = " + string(tBankImpLine.BankImpLineAmountTC).
end. /* if not available tqDDocumentForBankImport */

if available tqDDocumentForBankImport
then assign oiDDocumentId     = tqDDocumentForBankImport.tiDDocument_ID
            oiDDocumentYear   = tqDDocumentForBankImport.tiDDocumentYear
            ocDDocumentType   = tqDDocumentForBankImport.tcDDocumentType
            oiDDocumentNumber = tqDDocumentForBankImport.tiDDocumentNumber
            vcParam = "Customer Payment:(DDocumentYear = " + string(oiDDocumentYear) + 
                      ";DDocumentType = " + ocDDocumentType + 
                      ";DDocumentNumber = " + string(oiDDocumentNumber) + ");".

/* =================================================================================================== */
/* Stop queryies                                                                                       */
/* =================================================================================================== */
<Q-10 run DDocumentForBankImport  (Stop) in BDDocument >

/* =================================================================================================== */
/* If there was not found any Debtor Document, just report error                                       */
/* =================================================================================================== */
if oiDDocumentId = ?
then do:
    if not ilIsClearErrMsg
    then do:
        assign vcMessage = #T-6'The customer payment for this transaction line cannot be found. You can manually select a different customer payment.':255(68524)T-6#.
        <M-7 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-7595':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
    end.
    assign oiReturnStatus = -1.
end. /* if not available tqDDocumentForBankImport */

/* Create Processing Info */
<M-39 run CreateBankImpLineProcessInfo
   (input  'DDocumentForBankImport':U (icProcessName), 
    input  #T-42'Get customer payment info':255(35347084)T-42# (icProcessDesc), 
    input  if oiReturnStatus = -1 then '':U else vcParam (icProcessResult), 
    input  if oiReturnStatus = -1 then '':U else vcCriteria (icProcessParam), 
    input  'GetDDocumentByBankImpLine':U (icParentRowName), 
    input  oiReturnStatus (iiProcessStatus), 
    output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.