Description
This method searches for Creditor Document which matches information from data incoming bank.
Parameters
oiCDocumentId | output | integer | matched CDocument ID |
oiCDocumentYear | output | integer | matched CDocument Year |
ocCDocumentType | output | character | matched CDocument Type |
oiCDocumentNumber | output | integer | matched CDocument Number |
iiCurrencyID | input | integer | CDocument Currency ID |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bbankimportline.p)
/* =================================================================================================== */
/* Method : GetCDocumentByBankImpLine */
/* Desc : This method searches for Creditor Document which matches information from data coming */
/* bank */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (O) CDocumentId ID of the find CDocument */
/* (O) CDocumentYear Year of the CDocument */
/* (O) CDocumentType Type of the CDocument */
/* (O) CDocumentNumber Number of the CDocument */
/* =================================================================================================== */
/* The system uses 6 ways (cascaded) to find for the supplier payment */
/* It always uses the Creditor_ID, Currency_ID and tiOwnBankNumber_ID */
/* 1 Using BankImpLinePaymentNbr for CDocumentPrePrintedNumber */
/* 2 Using BankImpLinePaymentRef for CDocumentPrePrintedNumber */
/* 3 Using BankImpLinePaymentNbr for CDocumentReference */
/* 4 Using BankImpLinePaymentRef for CDocumentReference */
/* 5 Using BankImpLinePaymentNbr for CDocumentNumber */
/* 6 Not using any of the above , but using Amount */
/* =================================================================================================== */
/* =================================================================================================== */
/* if using custom matching logic, then return directly without executing standard matching logic. */
/* =================================================================================================== */
if vlUseCustomMatching = yes
then return.
assign oiReturnStatus = -98
vcParam = '':U
vcInputParam = '':U.
/* =================================================================================================== */
/* Default output values */
/* =================================================================================================== */
assign oiCDocumentId = ?
oiCDocumentYear = ?
ocCDocumentType = ?
oiCDocumentNumber = ?.
/* =================================================================================================== */
/* Validate input parameters */
/* =================================================================================================== */
if not available tBankImpLine
then do:
assign vcMessage = trim(#T-6'Missing definition of imported bank line.':255(67965)T-6#).
<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-7631':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 */
empty temp-table tqCDocumentForBankImport.
/* =================================================================================================== */
/* 1. Try to find Creditor Document: use BankImpLinePaymentNbr for CDocumentPrePrintedNumber */
/* =================================================================================================== */
empty temp-table tqCDocumentForBankImport.
assign vcExcludeCDocStatusList = 'XYZ'.
if tBankImpLine.BankImpLinePaymentNbr <> ? and
tBankImpLine.BankImpLinePaymentNbr <> '':U
then do:
assign viPrePrintedNumber = integer(tBankImpLine.BankImpLinePaymentNbr) no-error.
if not error-status:error
then do:
assign vcTrace = '1. use BankImpLinePaymentNbr for CDocumentPrePrintedNumber'.
<M-14 run AddInfoToCtLog
(input vcTrace (icTrace),
input ? (icParam1),
input ? (icParam2),
input ? (idParam3),
input ? (idParam4),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
<Q-11 run CDocumentForBankImport (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (CreditorCode)
input tBankImpLine.Creditor_ID, (CreditorId)
input iiCurrencyID, (CurrencyId)
input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
input ?, (CDocumentOriginalCreditTC)
input ?, (CDocumentReference)
input viPrePrintedNumber, (CDocumentPrePrintedNumber)
input ?, (CDocumentNumber)
input vcExcludeCDocStatusList, (ExcludeCDocStatusList)
output dataset tqCDocumentForBankImport) in BCDocument>
find first tqCDocumentForBankImport no-error.
assign vcInputParam = "CDocumentPrePrintedNumber = " + tBankImpLine.BankImpLinePaymentNbr.
end.
end. /* if tBankImpLine.BankImpLinePaymentNbr <> ? */
/* =================================================================================================== */
/* 2. Try to find Creditor Document: use BankImpLinePaymentRef for CDocumentPrePrintedNumber */
/* =================================================================================================== */
if not available tqCDocumentForBankImport and
tBankImpLine.BankImpLinePaymentRef <> ? and
tBankImpLine.BankImpLinePaymentRef <> '':U
then do:
/* use BankImpLinePaymentRef asd PrePrinted Number */
assign viPrePrintedNumber = integer(tBankImpLine.BankImpLinePaymentRef) no-error.
if not error-status:error
then do:
assign vcTrace = '2. use BankImpLinePaymentRef for CDocumentPrePrintedNumber'.
<M-83 run AddInfoToCtLog
(input vcTrace (icTrace),
input ? (icParam1),
input ? (icParam2),
input ? (idParam3),
input ? (idParam4),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
<Q-12 run CDocumentForBankImport (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (CreditorCode)
input tBankImpLine.Creditor_ID, (CreditorId)
input iiCurrencyID, (CurrencyId)
input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
input ?, (CDocumentOriginalCreditTC)
input ?, (CDocumentReference)
input viPrePrintedNumber, (CDocumentPrePrintedNumber)
input ?, (CDocumentNumber)
input vcExcludeCDocStatusList, (ExcludeCDocStatusList)
output dataset tqCDocumentForBankImport) in BCDocument>
find first tqCDocumentForBankImport no-error.
assign vcInputParam = "CDocumentPrePrintedNumber = " + tBankImpLine.BankImpLinePaymentRef.
end.
end. /* if not available tqCDocumentForBankImport */
/* =================================================================================================== */
/* 3. Try to find Creditor Document: use BankImpLinePaymentNbr for CDocumentReference */
/* =================================================================================================== */
if not available tqCDocumentForBankImport and
tBankImpLine.BankImpLinePaymentNbr <> ? and
tBankImpLine.BankImpLinePaymentNbr <> '':U
then do:
assign vcTrace = '3. use BankImpLinePaymentNbr for CDocumentReference'.
<M-60 run AddInfoToCtLog
(input vcTrace (icTrace),
input ? (icParam1),
input ? (icParam2),
input ? (idParam3),
input ? (idParam4),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
<Q-8 run CDocumentForBankImport (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (CreditorCode)
input tBankImpLine.Creditor_ID, (CreditorId)
input iiCurrencyID, (CurrencyId)
input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
input ?, (CDocumentOriginalCreditTC)
input tBankImpLine.BankImpLinePaymentNbr, (CDocumentReference)
input ?, (CDocumentPrePrintedNumber)
input ?, (CDocumentNumber)
input vcExcludeCDocStatusList, (ExcludeCDocStatusList)
output dataset tqCDocumentForBankImport) in BCDocument>
find first tqCDocumentForBankImport no-error.
assign vcInputParam = "Reference = " + tBankImpLine.BankImpLinePaymentNbr.
end. /* if tBankImpLine.BankImpLinePaymentNbr <> ? */
/* =================================================================================================== */
/* 4. Try to find Creditor Document: use BankImpLinePaymentRef for CDocumentReference */
/* =================================================================================================== */
if not available tqCDocumentForBankImport and
tBankImpLine.BankImpLinePaymentRef <> ? and
tBankImpLine.BankImpLinePaymentRef <> '':U
then do:
assign vcTrace = '4. use BankImpLinePaymentRef for CDocumentReference'.
<M-87 run AddInfoToCtLog
(input vcTrace (icTrace),
input ? (icParam1),
input ? (icParam2),
input ? (idParam3),
input ? (idParam4),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
<Q-9 run CDocumentForBankImport (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (CreditorCode)
input tBankImpLine.Creditor_ID, (CreditorId)
input iiCurrencyID, (CurrencyId)
input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
input ?, (CDocumentOriginalCreditTC)
input tBankImpLine.BankImpLinePaymentRef, (CDocumentReference)
input ?, (CDocumentPrePrintedNumber)
input ?, (CDocumentNumber)
input vcExcludeCDocStatusList, (ExcludeCDocStatusList)
output dataset tqCDocumentForBankImport) in BCDocument>
find first tqCDocumentForBankImport no-error.
assign vcInputParam = "Reference = " + tBankImpLine.BankImpLinePaymentRef.
end. /* if not available tqCDocumentForBankImport */
/* =================================================================================================== */
/* 5. Try to find Creditor Document: use BankImpLinePaymentNbr for CDocumentNumber */
/* =================================================================================================== */
if not available tqCDocumentForBankImport and
tBankImpLine.BankImpLinePaymentNbr <> ? and
tBankImpLine.BankImpLinePaymentNbr <> '':U
then do:
assign viCDocumentNumber = integer(tBankImpLine.BankImpLinePaymentNbr) no-error.
if not error-status:error and viCDocumentNumber <> 0
then do:
assign vcTrace = '5. BankImpLinePaymentNbr for CDocumentNumber'.
<M-67 run AddInfoToCtLog
(input vcTrace (icTrace),
input ? (icParam1),
input ? (icParam2),
input ? (idParam3),
input ? (idParam4),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
<Q-76 run CDocumentForBankImport (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (CreditorCode)
input tBankImpLine.Creditor_ID, (CreditorId)
input iiCurrencyID, (CurrencyId)
input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
input ?, (CDocumentOriginalCreditTC)
input ?, (CDocumentReference)
input ?, (CDocumentPrePrintedNumber)
input viCDocumentNumber, (CDocumentNumber)
input vcExcludeCDocStatusList, (ExcludeCDocStatusList)
output dataset tqCDocumentForBankImport) in BCDocument>
find first tqCDocumentForBankImport no-error.
end.
end. /* if tBankImpLine.BankImpLinePaymentNbr <> ? */
/* =================================================================================================== */
/* 6. Try to find Creditor Document by Creditor and Amount */
/* =================================================================================================== */
if not available tqCDocumentForBankImport and
tBankImpLine.Creditor_ID <> 0 and
tBankImpLine.Creditor_ID <> ? and
tBankImpLine.BankImpLineAmountTC <> 0 and
tBankImpLine.BankImpLineAmountTC <> ?
then do:
assign vcTrace = '6. Use BankImpLineAmountTC for CDocumentOriginalCreditTC'.
<M-41 run AddInfoToCtLog
(input vcTrace (icTrace),
input ? (icParam1),
input ? (icParam2),
input ? (idParam3),
input ? (idParam4),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
assign vcExcludeCDocStatusList = {&DOCUMENTSTATUS-PAID} + "," + {&DOCUMENTSTATUS-BOUNCED}.
<Q-10 run CDocumentForBankImport (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (CreditorCode)
input tBankImpLine.Creditor_ID, (CreditorId)
input iiCurrencyID, (CurrencyId)
input tBankImpLine.tiOwnBankNumber_ID, (OwnBankNumberId)
input abs(tBankImpLine.BankImpLineAmountTC), (CDocumentOriginalCreditTC)
input ?, (CDocumentReference)
input ?, (CDocumentPrePrintedNumber)
input ?, (CDocumentNumber)
input vcExcludeCDocStatusList, (ExcludeCDocStatusList)
output dataset tqCDocumentForBankImport) in BCDocument>
find first tqCDocumentForBankImport no-error.
assign vcInputParam = "AmountTC = " + string(abs(tBankImpLine.BankImpLineAmountTC)) +
";DocStatus = " + {&DOCUMENTSTATUS-PAID}.
end. /* if not available tqCDocumentForBankImport */
for each tqCDocumentForBankImport:
<M-54 run CheckIfDocumentIsProcessed
(input tqCDocumentForBankImport.tiCDocument_ID (iiDocID),
output vlIsCDocProcessed (olIsProcessed),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
if viFcReturnSuper < 0
then assign oiReturnStatus = -1.
if vlIsCDocProcessed = true
then next .
assign viUnprocessedCDocID = tqCDocumentForBankImport.tiCDocument_ID.
leave.
end. /*for each tqCDocumentForBankImport: */
find first tqCDocumentForBankImport where
tqCDocumentForBankImport.tiCDocument_ID = viUnprocessedCDocID
no-error.
/* =================================================================================================== */
/* If there was not found any Creditor Document, just report error */
/* =================================================================================================== */
if not available tqCDocumentForBankImport
then do:
assign vcMessage = #T-7'The supplier payment for this transaction line cannot be found. You can manually select a different supplier payment.':255(68522)T-7#.
<M-5 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-7632':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
assign oiReturnStatus = -1.
end. /* if not available tqCDocumentForBankImport */
/* Create Processing Info */
if oiReturnStatus <> -1
then assign vcParam = "CDocumentYear = " + string(tqCDocumentForBankImport.tiCDocumentYear) +
";CDocumentType = " + tqCDocumentForBankImport.tcCDocumentType +
";CDocumentNumber = " + string(tqCDocumentForBankImport.tiCDocumentNumber) +
";CDocumentReference = " + tqCDocumentForBankImport.tcCDocumentReference.
else assign vcInputParam = '':U.
<M-88 run CreateBankImpLineProcessInfo
(input 'CDocumentForBankImport':U (icProcessName),
input #T-19'Get supplier payment info':255(738594193)T-19# (icProcessDesc),
input vcParam (icProcessResult),
input vcInputParam (icProcessParam),
input 'GetCDocumentByBankImpLine':U (icParentRowName),
input oiReturnStatus (iiProcessStatus),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
if oiReturnStatus = -1 then return.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
assign oiCDocumentId = tqCDocumentForBankImport.tiCDocument_ID
oiCDocumentYear = tqCDocumentForBankImport.tiCDocumentYear
ocCDocumentType = tqCDocumentForBankImport.tcCDocumentType
oiCDocumentNumber = tqCDocumentForBankImport.tiCDocumentNumber.
if oiReturnStatus = -98 then assign oiReturnStatus = 0.