Description
This method get the creditor based on the information of Bank Import Line.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bbankimportline.p)
/* =================================================================================================== */
/* Method : GetCreditorByBankImpLine */
/* Desc : This method get the creditor based on the information of BankImpLine */
/* !!! This method has to be in the same segment as parent methods (expects correct */
/* record in table tBankImpLine) - segment 6 */
/* =================================================================================================== */
/* =================================================================================================== */
/* if using custom matching logic, then return directly without executing standard matching logic. */
/* =================================================================================================== */
/* =================================================================================================== */
/* The search is a cascaded search of */
/* Try 1 : By CreditorCode */
/* Try 2 : By Bank Number */
/* Try 3 : By Business Relation remittance address */
/* Try 4 : By Creditor name and Address */
/* Try 5 : By CreditorName */
/* =================================================================================================== */
if vlUseCustomMatching = yes
then return.
assign oiReturnStatus = -98
vlQAddStarted = false
vlCreditorCodeIsOK = false
vcParam = '':U
vcCriteira = '':U.
/* =================================================================================================== */
/* Validate input parameters */
/* =================================================================================================== */
if not available tBankImpLine
then do:
assign vcMessage = trim(#T-13'Missing definition of imported bank line.':255(67965)T-13#).
<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-7671':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
assign oiReturnStatus = -1.
return.
end.
/* =================================================================================================== */
/* Preconditions */
/* =================================================================================================== */
if tBankImpLine.Creditor_ID = 0 then assign tBankImpLine.Creditor_ID = ?.
/* If creditor is known, there is not need to lookup it again */
if tBankImpLine.Creditor_ID <> ? and (tBankImpLine.BankImpLineCreditorCode = "" or tBankImpLine.BankImpLineCreditorCode =?)
then do:
assign oiReturnStatus = 0.
return.
end.
/* =================================================================================================== */
/* Get Creditor by the information in the Bank Import Line */
/* =================================================================================================== */
/* Trye 1 : Get Creditor by Code */
if tBankImpLine.BankImpLineCreditorCode <> "":U and
tBankImpLine.BankImpLineCreditorCode <> ?
then do:
<Q-15 run CreditorByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tBankImpLine.BankImpLineCreditorCode, (CreditorCode)
output dataset tqCreditorByCode) in BCreditor >
find first tqCreditorByCode no-error.
if available tqCreditorByCode
then do:
assign tBankImpLine.Creditor_ID = tqCreditorByCode.tiCreditor_ID
vlCreditorCodeIsOK = true.
/* Create Processing Info */
assign vcCriteira = "BankImpLineCreditorCode = " + tBankImpLine.BankImpLineCreditorCode.
vcParam = "CreditorCode = " + tqCreditorByCode.tcCreditorCode.
<M-11 run CreateBankImpLineProcessInfo
(input 'CreditorByCode':U (icProcessName),
input #T-39'Get supplier info':255(959221706)T-39# (icProcessDesc),
input vcParam (icProcessResult),
input vcCriteira (icProcessParam),
input 'GetCreditorByBankImpLine':U (icParentRowName),
input 0 (iiProcessStatus),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
end. /* if tBankImpLine.BankImpLineCreditorCode <> "":U and tBankImpLine.BankImpLineCreditorCode <> ? */
/* Trye 2 : Get Creditor by it's bank Number */
if tBankImpLine.Creditor_ID = ? and
tBankImpLine.BankImpLineBankNumber <> "":U and
tBankImpLine.BankImpLineBankNumber <> ?
then do:
/* Create Processing Info */
<M-67 run CreateBankImpLineProcessInfo
(input 'GetBankNumberByNumber':U (icProcessName),
input #T-51'Get supplier info':255(959221706)T-51# (icProcessDesc),
input ? (icProcessResult),
input ? (icProcessParam),
input 'GetCreditorByBankImpLine':U (icParentRowName),
input 0 (iiProcessStatus),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
<M-3 run GetBankNumberByNumber
(input {&BANKNUMBERPARENTTYPE-CREDITOR} (icBankNumberParentType),
input tBankImpLine.BankImpLineBankNumber (icBankNumber),
output viDummy (oiBankNumberId),
output vcDummy (ocBankNumber),
output viCreditorId (oiParentObjectId),
output vcDummy (ocParentObjectCode),
output viDummy (oiCurrencyId),
output vcDummy (ocCurrencyCode),
output viTransactionCompanyId (oiTransactionCompanyId),
input ? (icBankImpCurrencyCode),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
if viCreditorId <> ? and viCreditorId <> 0
then do:
assign tBankImpLine.Creditor_ID = viCreditorId.
assign vcParam = '':U.
<M-75 run UpdateBankImpLineProcessResult
(input 'GetBankNumberByNumber':U (icProcessName),
input 0 (iiProcessStatus),
input vcParam (icProcessResult),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
end. /* if tBankImpLine.BankImpLineBankNumber <> "":U and tBankImpLine.BankImpLineBankNumber <> ? */
/* Try 3 : Get Creditor by it's business relation remittance address */
if tBankImpLine.Creditor_ID = ? and
((tBankImpLine.BankImpLineCreditorCode <> "":U and tBankImpLine.BankImpLineCreditorCode <> ?) or
(tBankImpLine.BankImpLineCreditorName <> "":U and tBankImpLine.BankImpLineCreditorName <> ?))
then do:
if not vlQAddStarted
then do:
<Q-16 run AddressForCreditor (Start) in BBusinessRelation >
assign vlQAddStarted = true.
end.
<Q-17 run AddressForCreditor (all) (Read) (NoCache)
(input ?, (AddressCity)
input ?, (AddressCountry)
input ?, (AddressLine)
input tBankImpLine.BankImpLineCreditorCode, (AddressSearchName)
input {&ADDRESSTYPECODESYSTEM-REMITTANCE}, (AddressTypeCode)
input ?, (AddressZip)
input ?, (BusinessRelationName)
input ?, (CompanyId)
input tBankImpLine.BankImpLineCreditorName, (AddressName)
input ?, (AddressID)
output dataset tqAddressForCreditor) in BBusinessRelation >
find first tqAddressForCreditor no-error.
if available tqAddressForCreditor
then do:
assign tBankImpLine.Creditor_ID = tqAddressForCreditor.tiCreditor_ID.
/* Create Processing Info */
assign vcParam = "CreditorCode = " + tqAddressForCreditor.tcCreditorCode
vcCriteira = "AddressSearchName = " + tBankImpLine.BankImpLineCreditorCode +
";AddressTypeCode = " + {&ADDRESSTYPECODESYSTEM-REMITTANCE} +
";AddressName = " + tBankImpLine.BankImpLineCreditorName.
<M-41 run CreateBankImpLineProcessInfo
(input 'AddressForCreditor':U (icProcessName),
input #T-76'Get supplier info':255(959221706)T-76# (icProcessDesc),
input vcParam (icProcessResult),
input vcCriteira (icProcessParam),
input 'GetCreditorByBankImpLine':U (icParentRowName),
input 0 (iiProcessStatus),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
end. /* if (tBankImpLine.BankImpLineCreditorCode <> "":U and tBankImpLine.BankImpLineCreditorCode <> ?) or */
/* Try 4 : Get debtor by Supplier name and Address */
if tBankImpLine.Creditor_ID = ? and
((tBankImpLine.BankImpLineCreditorName <> "":U and tBankImpLine.BankImpLineCreditorName <> ?) or
(tBankImpLine.BankImpLineAddressCity <> "":U and tBankImpLine.BankImpLineAddressCity <> ?) or
(tBankImpLine.BankImpLineAddressCountry <> "":U and tBankImpLine.BankImpLineAddressCountry <> ?) or
(tBankImpLine.BankImpLineAddressLine <> "":U and tBankImpLine.BankImpLineAddressLine <> ?) or
(tBankImpLine.BankImpLineAddressZip <> "":U and tBankImpLine.BankImpLineAddressZip <> ?))
then do:
if not vlQAddStarted
then do:
<Q-21 run AddressForCreditor (Start) in BBusinessRelation >
assign vlQAddStarted = true.
end.
<Q-18 run AddressForCreditor (all) (Read) (NoCache)
(input tBankImpLine.BankImpLineAddressCity, (AddressCity)
input tBankImpLine.BankImpLineAddressCountry, (AddressCountry)
input tBankImpLine.BankImpLineAddressLine, (AddressLine)
input ?, (AddressSearchName)
input ?, (AddressTypeCode)
input tBankImpLine.BankImpLineAddressZip, (AddressZip)
input tBankImpLine.BankImpLineCreditorName, (BusinessRelationName)
input ?, (CompanyId)
input ?, (AddressName)
input ?, (AddressID)
output dataset tqAddressForCreditor) in BBusinessRelation >
find first tqAddressForCreditor no-error.
if available tqAddressForCreditor
then do:
assign tBankImpLine.Creditor_ID = tqAddressForCreditor.tiCreditor_ID.
/* Create Processing Info */
assign vcParam = "CreditorCode = " + tqAddressForCreditor.tcCreditorCode
vcCriteira = "AddressCity = " + tBankImpLine.BankImpLineAddressCity +
";AddressCountry = " + tBankImpLine.BankImpLineAddressCountry +
";AddressLine = " + tBankImpLine.BankImpLineAddressLine +
";AddressZip = " + tBankImpLine.BankImpLineAddressZip +
";BusinessRelationName = " + tBankImpLine.BankImpLineCreditorName.
<M-24 run CreateBankImpLineProcessInfo
(input 'AddressForCreditor':U (icProcessName),
input #T-15'Get supplier info':255(959221706)T-15# (icProcessDesc),
input vcParam (icProcessResult),
input vcCriteira (icProcessParam),
input 'GetCreditorByBankImpLine':U (icParentRowName),
input 0 (iiProcessStatus),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
end. /* if (tBankImpLine.BankImpLineCreditorName <> "":U and tBankImpLine.BankImpLineCreditorName <> ?) or */
/* Try 5 : Get Supplier by Supplier name */
if tBankImpLine.Creditor_ID = ? and
tBankImpLine.BankImpLineCreditorName <> "":U and
tBankImpLine.BankImpLineCreditorName <> ?
then do:
if not vlQAddStarted
then do:
<Q-20 run AddressForCreditor (Start) in BBusinessRelation >
assign vlQAddStarted = true.
end.
<Q-19 run AddressForCreditor (all) (Read) (NoCache)
(input tBankImpLine.BankImpLineAddressCity, (AddressCity)
input tBankImpLine.BankImpLineAddressCountry, (AddressCountry)
input tBankImpLine.BankImpLineAddressLine, (AddressLine)
input ?, (AddressSearchName)
input ?, (AddressTypeCode)
input tBankImpLine.BankImpLineAddressZip, (AddressZip)
input tBankImpLine.BankImpLineCreditorName, (BusinessRelationName)
input ?, (CompanyId)
input ?, (AddressName)
input ?, (AddressID)
output dataset tqAddressForCreditor) in BBusinessRelation >
find first tqAddressForCreditor no-error.
if available tqAddressForCreditor
then do:
assign tBankImpLine.Creditor_ID = tqAddressForCreditor.tiCreditor_ID.
/* Create Processing Info */
assign vcParam = "CreditorCode = " + tqAddressForCreditor.tcCreditorCode
vcCriteira = "BusinessRelationName = " + tBankImpLine.BankImpLineCreditorName.
<M-43 run CreateBankImpLineProcessInfo
(input 'AddressForCreditor':U (icProcessName),
input #T-47'Get supplier info':255(959221706)T-47# (icProcessDesc),
input vcParam (icProcessResult),
input vcCriteira (icProcessParam),
input 'GetCreditorByBankImpLine':U (icParentRowName),
input 0 (iiProcessStatus),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
end. /* if tBankImpLine.BankImpLineCreditorName <> "":U and tBankImpLine.BankImpLineCreditorName <> ? */
/* Stop started queries */
if vlQAddStarted
then do:
<Q-22 run AddressForCreditor (Stop) in BBusinessRelation >
end.
/* ============================================================= */
/* Get the BankImpLineCreditorCode if it is still not filled in */
/* ============================================================= */
if tBankImpLine.Creditor_ID <> 0 and tBankImpLine.Creditor_ID <> ? and vlCreditorCodeIsOK = false
then do:
<Q-57 run CreditorPrim (all) (Read) (NoCache)
(input ?, (CompanyId)
input tBankImpLine.Creditor_ID, (CreditorId)
input '':U, (CreditorCode)
output dataset tqCreditorPrim) in BCreditor>
find first tqCreditorPrim no-error.
if available tqCreditorPrim
then do:
assign tBankImpLine.BankImpLineCreditorCode = tqCreditorPrim.Tccreditorcode.
/* Create Processing Info */
assign vcParam = "CreditorCode = " + tBankImpLine.BankImpLineCreditorCode
vcCriteira = "CreditorId = " + string(tBankImpLine.Creditor_ID).
<M-30 run CreateBankImpLineProcessInfo
(input 'CreditorPrim':U (icProcessName),
input #T-5'Get supplier info':255(959221706)T-5# (icProcessDesc),
input vcParam (icProcessResult),
input vcCriteira (icProcessParam),
input 'GetCreditorByBankImpLine':U (icParentRowName),
input 0 (iiProcessStatus),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
end.
/* If supplier has not been found, report this */
if tBankImpLine.Creditor_ID = ? or tBankImpLine.Creditor_ID = 0
then do:
assign vcMessage = trim(substitute(#T-14'The specified supplier code (&1) is not defined in the system. Select an existing supplier.':255(68417)t-14#,
trim(tBankImpLine.BankImpLineCreditorCode))).
<M-12 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tBankImpLine.BankImpLineCreditorCode':U (icFieldName),
input tBankImpLine.BankImpLineCreditorCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7672':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
assign oiReturnStatus = -1.
end.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.