Description
Default Values DInvoiceBank
Parameters
| iiDInvoiceId | input | integer | |
| icRowId | input | character | |
| idDInvoiceOriginalTC | input | decimal | |
| iiDebtorId | input | integer | |
| tApiDInvoiceBank | output | temp-table | |
| tApiDInvoiceBankPayCode | output | temp-table | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdinvoice.p)
<Q-10 run BankNumberForCIDefault (all) (Read) (NoCache)
(input iiDebtorId, (ParentObjectId)
input ?, (BankNumberIsDefault)
input true, (BankNumberIsActive)
input ?, (CompanyId)
output dataset tqBankNumberForCIDefault) in BBankNumber >
/* Find active defeault banknumber for current entity */
find first tqBankNumberForCIDefault where
tqBankNumberForCIDefault.tiParentObject_ID = iiDebtorId and
tqBankNumberForCIDefault.tlBankNumberIsDefault = true and
tqBankNumberForCIDefault.tlBankNumberIsActive = true and
tqBankNumberForCIDefault.tiCompany_ID = viCompanyId
no-error.
/* If can not find banknumber in the previous step just find the active banknumber for current entity */
if not available tqBankNumberForCIDefault
then find first tqBankNumberForCIDefault where
tqBankNumberForCIDefault.tiParentObject_ID = iiDebtorId and
tqBankNumberForCIDefault.tlBankNumberIsActive = true and
tqBankNumberForCIDefault.tiCompany_ID = viCompanyId
no-error.
/* If can not find banknumber in the previous step just find the first active banknumber for the customer */
if not available tqBankNumberForCIDefault
then find first tqBankNumberForCIDefault where
tqBankNumberForCIDefault.tiParentObject_ID = iiDebtorId and
tqBankNumberForCIDefault.tlBankNumberIsActive = true and
tqBankNumberForCIDefault.tlBankNumberIsDefault = true
no-error.
if available tqBankNumberForCIDefault
then do:
/* First clear the existing stuff */
for each tDInvoiceBank where
tDInvoiceBank.tc_ParentRowid = icRowId :
for each tDInvoiceBankPayCode where
tDInvoiceBankPayCode.tc_ParentRowid = tDInvoiceBank.tc_Rowid:
if tDInvoiceBankPayCode.tc_Status = "N":U
then delete tDInvoiceBankPayCode.
else assign tDInvoiceBankPayCode.tc_Status = "D":U.
end. /* for each tDInvoiceBankPayCode where */
if tDInvoiceBank.tc_Status = "N":U
then delete tDInvoiceBank.
else assign tDInvoiceBank.tc_Status = "D":U.
end. /* for each tDInvoiceBank where */
<M-11 run AddDetailLine
(input 'DInvoiceBank':U (icTable),
input icRowId (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
assign tDInvoiceBank.DInvoice_ID = iiDInvoiceId
tDInvoiceBank.BankNumber_ID = tqBankNumberForCIDefault.tiBankNumber_ID
tDInvoiceBank.tcBankNumberExtension = tqBankNumberForCIDefault.tcBankNumberExtension
tDInvoiceBank.tiParentObject_ID = tqBankNumberForCIDefault.tiParentObject_ID
tDInvoiceBank.tcBankNumber = tqBankNumberForCIDefault.tcBankNumberFormatted
tDInvoiceBank.tcBankNumberSwiftCode = tqBankNumberForCIDefault.tcBankNumberSwiftCode
tDInvoiceBank.tcBankNumberValidation = tqBankNumberForCIDefault.tcBankNumberValidation
tDInvoiceBank.tcBusinessRelationCode = tqBankNumberForCIDefault.tcBusinessRelationCode
tDInvoiceBank.DInvoiceBankToPayTC = idDInvoiceOriginalTC.
<Q-18 run BankNumberForPayFormatBank (all) (Read) (NoCache)
(input ?, (CompanyId)
input tqBankNumberForCIDefault.tiParentObject_ID, (ParentObjectID)
input tqBankNumberForCIDefault.tiBankNumber_ID, (BankNumberID)
output dataset tqBankNumberForPayFormatBank) in BBankNumber >
find first tqBankNumberForPayFormatBank where
tqBankNumberForPayFormatBank.tiParentObject_ID = tqBankNumberForCIDefault.tiParentObject_ID and
tqBankNumberForPayFormatBank.tiBankNumber_ID = tqBankNumberForCIDefault.tiBankNumber_ID
no-error.
assign tDInvoiceBank.tcCompanyCode = if available tqBankNumberForPayFormatBank
then tqBankNumberForPayFormatBank.tcCompanyCode
else "":U.
if tqBankNumberForCIDefault.tiBankPayFormat_ID <> 0 and
tqBankNumberForCIDefault.tiBankPayFormat_ID <> ?
then do:
<Q-12 run BankPayFormatByID (all) (Read) (NoCache)
(input tqBankNumberForCIDefault.tiBankPayFormat_ID, (BankPayFormatId)
input ?, (CompanyId)
output dataset tqBankPayFormatByID) in BBankPayFormat >
find first tqBankPayFormatByID where
tqBankPayFormatByID.tiBankPayFormat_ID = tqBankNumberForCIDefault.tiBankPayFormat_ID
no-error.
if available tqBankPayFormatByID
then do:
assign tDInvoiceBank.tcOwnBankNumber = tqBankPayFormatByID.tcBankNumber
tDInvoiceBank.tcOwnGLCode = tqBankPayFormatByID.tcGLCode
tDInvoiceBank.tcPayFormatTypeCode = tqBankPayFormatByID.tcPayFormatTypeCode
tDInvoiceBank.tcPayFormatTypePayInstrument = "?":U.
assign vcPAYFORMATPAYINSTRUMENTS ={&PAYFORMATPAYINSTRUMENTS}.
do viCounter = num-entries(vcPAYFORMATPAYINSTRUMENTS,chr(2)) to 1 by -2 :
if entry(viCounter,vcPAYFORMATPAYINSTRUMENTS,chr(2)) = tqBankPayFormatByID.tcPayFormatTypePayInstrument
then do :
assign tDInvoiceBank.tcPayFormatTypePayInstrument = entry(viCounter - 1,vcPAYFORMATPAYINSTRUMENTS,chr(2)) no-error.
leave.
end. /* if entry */
end.
end.
end. /* if tiBankPayFormat_ID <> 0 */
create tApiDInvoiceBank.
raw-transfer tDInvoiceBank to tApiDInvoiceBank.
<M-13 run CreateDIBankPayCode
(input tDInvoiceBank.DInvoiceBank_ID (iiDInvoiceBankId),
input tDInvoiceBank.tc_Rowid (icDInvoiceBankRowid),
input tDInvoiceBank.BankNumber_ID (iiBankNumberId),
output tApiDInvoiceBankPayCode (tApiDInvoiceBankPayCode),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.