project QadFinancials > class BDebtor > method ValBankNumberandPayCodeRef
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdebtor.p)
for each tBankNumberRefDebtor where
tBankNumberRefDebtor.BankNumberParentType = {&BANKNUMBERPARENTTYPE-DEBTOR} and
tBankNumberRefDebtor.ParentObject_ID = t_sDebtor.Debtor_ID and
tBankNumberRefDebtor.BankNumberIsActive = true and
tBankNumberRefDebtor.tc_Status = "N":U or
tBankNumberRefDebtor.tc_Status = "C":U :
assign vcCustomerCountryCode = ""
vcOwnBankCountryCode = "".
/* Determine customer's bank's country (converting business relation code to ID) */
viBankBusinessRelationID = 0.
if(tBankNumberRefDebtor.tcBankBusinessRelationCode <> '' and tBankNumberRefDebtor.tcBankBusinessRelationCode <> ?) then do:
<Q-39 run BusinessRelationPrim (all) (Read) (NoCache)
(input ?, (BusinessRelationId)
input tBankNumberRefDebtor.tcBankBusinessRelationCode, (BusinessRelationCode)
output dataset tqBusinessRelationPrim) in BBusinessRelation >
for first tqBusinessRelationPrim:
viBankBusinessRelationID = tqBusinessRelationPrim.tiBusinessRelation_ID.
end.
end. /* if(tBankNumberRefDebtor.tcBankBusinessRelationCode <> '' */
if(viBankBusinessRelationID <> 0) then do:
<Q-35 run AddressByAddressType (all) (Read) (NoCache)
(input viBankBusinessRelationID, (BusinessRelationId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressByAddressType) in BBusinessRelation >
for first tqAddressByAddressType:
vcCustomerCountryCode = tqAddressByAddressType.tcCountryCode.
end.
end. /* if(tBankNumberRefDebtor.BankBusinessRelation_ID <> 0) */
/* Determine customer's country if customer's bank does not have a country */
if(vcCustomerCountryCode = '') then do:
<Q-29 run AddressByAddressType (all) (Read) (NoCache)
(input t_sDebtor.BusinessRelation_ID, (BusinessRelationId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressByAddressType) in BBusinessRelation >
for first tqAddressByAddressType no-lock:
assign vcCustomerCountryCode = tqAddressByAddressType.tcCountryCode.
end.
end. /* if(vcCustomerCountryCode */
/* Determine own bank's country */
viOwnBankNumberID = 0.
<Q-40 run BankNumberByParentTypeDefAct (all) (Read) (NoCache)
(input ?, (ParentObjectId)
input {&BANKNUMBERPARENTTYPE-GL}, (BankNumberParentType)
input ?, (BankNumberIsDefault)
input ?, (CompanyId)
input ?, (Active)
input tBankNumberRefDebtor.tcOwnBankNumber, (BankNumber)
input ?, (BankNumberExtension)
output dataset tqBankNumberByParentTypeDefAct) in BBankNumber >
/* Find unique own GL bank */
find first tqBankNumberByParentTypeDefAct no-error.
if(available(tqBankNumberByParentTypeDefAct)) then do:
viOwnBankNumberID = tqBankNumberByParentTypeDefAct.tiBankNumber_ID.
end.
<Q-37 run BankNumberByIDAllInfo (all) (Read) (NoCache)
(input viOwnBankNumberID, (BankNumber_ID)
input ?, (BankNumberIsDefault)
output dataset tqBankNumberByIDAllInfo) in BBankNumber >
for first tqBankNumberByIDAllInfo:
if(tqBankNumberByIDAllInfo.tiBankBusinessRelation_ID <> 0 and tqBankNumberByIDAllInfo.tiBankBusinessRelation_ID <> ?) then do:
<Q-38 run AddressByAddressType (all) (Read) (NoCache)
(input tqBankNumberByIDAllInfo.tiBankBusinessRelation_ID, (BusinessRelationId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressByAddressType) in BBusinessRelation >
for first tqAddressByAddressType:
vcOwnBankCountryCode = tqAddressByAddressType.tcCountryCode.
end. /* for first tqAddressByAddressType */
end. /* if(tqBankNumberByIDAllInfo.tiBankBusinessRelation_ID <> 0) */
end. /* for first tqBankNumberByIDAllInfo */
if (tBankNumberRefDebtor.BankPayFormat_ID <> 0 and
tBankNumberRefDebtor.BankPayFormat_ID <> ?)
then do:
<Q-19 run BankPayFormatByID (all) (Read) (NoCache)
(input tBankNumberRefDebtor.BankPayFormat_ID, (BankPayFormatId)
input ?, (CompanyId)
output dataset tqBankPayFormatByID) in BBankPayFormat >
end.
for each tqBankPayFormatByID no-lock:
/* Determine company's country if own bank does not have a country */
if(vcOwnBankCountryCode = '') then do:
<Q-26 run CompanyPropertyForAllData (all) (Read) (NoCache)
(input tqBankPayFormatByID.tiCompany_ID, (CompanyId)
output dataset tqCompanyPropertyForAllData) in BCompanyProperty >
for each tqCompanyPropertyForAllData no-lock:
<Q-30 run AddressByAddressType (all) (Read) (NoCache)
(input tqCompanyPropertyForAllData.tiBusinessRelation_ID, (BusinessRelationId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressByAddressType) in BBusinessRelation >
for each tqAddressByAddressType no-lock:
assign vcOwnBankCountryCode = tqAddressByAddressType.tcCountryCode.
end.
end.
end. /* if(vcOwnBankCountryCode */
/* Inland or Both */
if tqBankPayFormatByID.tcPayFormatTypePayType = {&PAYFORMATPAYTYPE-INLAND}
then do:
if vcCustomerCountryCode <> vcOwnBankCountryCode
then do:
assign vcMessage = trim(substitute(#T-22'Only Payment Formats of Pay Type &1 or &2 are allowed when Own Bank Country and Customer Country are different.':249(999890803)T-22#,{&PAYFORMATPAYTYPE-FOREIGN-TR},{&PAYFORMATPAYTYPE-BOTH-TR})) + chr(10) +
trim(substitute(#T-32'Country code of the own Bank: &1.':233(59623)T-32#,vcOwnBankCountryCode)) + chr(10) +
trim(substitute(#T-33'Country code of the Customer: &1.':222(59621)T-33#,vcCustomerCountryCode)).
oiReturnStatus = -1.
if available t_sDebtor
then assign vcMessage = vcMessage + chr(10) + trim(substitute(#T-34'Customer: &1.':222(59624)T-34#,t_sDebtor.DebtorCode)).
<M-20 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tBankNumberRefDebtor.BankNumberValidation':U (icFieldName),
input tBankNumberRefDebtor.BankNumberValidation (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tBankNumberRefDebtor.tc_Rowid (icRowid),
input 'QadFin-6007':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
end.
end.
/* Foreign or Both */
else if tqBankPayFormatByID.tcPayFormatTypePayType = {&PAYFORMATPAYTYPE-FOREIGN}
then do:
if vcCustomerCountryCode = vcOwnBankCountryCode
then do:
assign vcMessage =
trim(substitute(#T-23'Only Payment Formats of Pay Type &1 or &2 are allowed when Own Bank Country and Customer Country are same':120(999890804)T-23#,{&PAYFORMATPAYTYPE-INLAND-TR},{&PAYFORMATPAYTYPE-BOTH-TR}))
oiReturnStatus = -1.
<M-21 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tBankNumberRefDebtor.BankNumberValidation':U (icFieldName),
input tBankNumberRefDebtor.BankNumberValidation (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tBankNumberRefDebtor.tc_Rowid (icRowid),
input 'QadFin-6008':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
end.
end.
end.
end.
/* Allow only one bank number to be set as default */
for each tBankNumberRefDebtor where
tBankNumberRefDebtor.BankNumberParentType = {&BANKNUMBERPARENTTYPE-DEBTOR} and
tBankNumberRefDebtor.ParentObject_ID = t_sDebtor.Debtor_ID and
tBankNumberRefDebtor.BankNumberIsActive = true and
tBankNumberRefDebtor.BankNumberIsDefault = true and
tBankNumberRefDebtor.tc_Status <> 'D':U :
if vcPrevCompanyCode = tBankNumberRefDebtor.tcCompanyCode
then assign viCount = viCount + 1.
assign vcPrevCompanyCode = tBankNumberRefDebtor.tcCompanyCode.
end.
if viCount > 0
then do:
assign oiReturnStatus = -1.
<M-41 run SetMessage
(input trim(#T-42'Only one Bank Number may be set as default':120(65742)T-42#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7458':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
end.
assign
viCount = 0
vcPrevCompanyCode = "".
/* Allow only one bank number to be set as the SB default */
for each tBankNumberRefDebtor where
tBankNumberRefDebtor.BankNumberParentType = {&BANKNUMBERPARENTTYPE-DEBTOR} and
tBankNumberRefDebtor.ParentObject_ID = t_sDebtor.Debtor_ID and
tBankNumberRefDebtor.BankNumberIsActive = true and
tBankNumberRefDebtor.BankNumberIsSBDef = true and
tBankNumberRefDebtor.tc_Status <> 'D':U :
if vcPrevCompanyCode = tBankNumberRefDebtor.tcCompanyCode
then assign viCount = viCount + 1.
assign vcPrevCompanyCode = tBankNumberRefDebtor.tcCompanyCode.
end.
if viCount > 0
then do:
assign oiReturnStatus = -1.
<M-49 run SetMessage
(input trim(#T-50'Only one Bank Number may be set as a Self-Bill default':120(733754435)T-50#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9675':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
end.