Parameters
iiDCollectionId | input | integer | |
ilDuplicate | input | logical | |
itSpilDate | input | date | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bdcollection.p)
/* Get the collection */
<Q-12 run DCollectionByID (all) (Read) (NoCache)
(input ?, (CompanyId)
input iiDCollectionId, (CollectionId)
output dataset tqDCollectionByID) in BDCollection >
find tqDCollectionByID where
tqDCollectionByID.tiDCollection_ID = iiDCollectionId
no-error.
if not available tqDCollectionByID
then do:
<M-13 run SetMessage
(input trim(#T-28'Customer payment collection with ID $1 not found.':255(999890810)T-28#) (icMessage),
input string(iiDCollectionId) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-2948':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign oiReturnStatus = -1.
return.
end.
/* Get Company Name and City */
<Q-14 run CompanyPropertyByIdCode (all) (Read) (NoCache)
(input tqDCollectionByID.tiCompany_ID, (CompanyId)
input ?, (CompanyPropertyId)
input ?, (BusinessRelationId)
input ?, (CurrencyId)
input ?, (CompanyPropertyCode)
input ?, (CompanyCode)
input ?, (BusinessRelationCode)
input ?, (CurrencyCode)
output dataset tqCompanyPropertyByIdCode) in BCompanyProperty >
find first tqCompanyPropertyByIdCode where
tqCompanyPropertyByIdCode.tiCompany_ID = tqDCollectionByID.tiCompany_ID
no-error.
if available tqCompanyPropertyByIdCode
then do:
<Q-15 run AddressByAddressType (all) (Read) (NoCache)
(input tqCompanyPropertyByIdCode.tiBusinessRelation_ID, (BusinessRelationId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressByAddressType) in BBusinessRelation >
find first tqAddressByAddressType where
tqAddressByAddressType.tiBusinessRelation_ID = tqCompanyPropertyByIdCode.tiBusinessRelation_ID and
tqAddressByAddressType.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-HEADOFFICE}
no-error.
if available tqAddressByAddressType
then assign vcCompanyName = tqAddressByAddressType.tcBusinessRelationName1
vcCompanyCity = tqAddressByAddressType.tcAddressCity.
end.
/* Get the Current Company BankNumber */
<Q-16 run BankNumberByParentID (all) (Read) (NoCache)
(input tqDCollectionByID.tiGL_ID, (ParentObjectId)
input {&BANKNUMBERPARENTTYPE-GL}, (BankNumberParentType)
input true, (BankNumberIsDefault)
input tqDCollectionByID.tiCompany_ID, (CompanyId)
output dataset tqBankNumberByParentID) in BBankNumber >
find first tqBankNumberByParentID
no-error.
if available tqBankNumberByParentID
then assign vcBankNumber = string(decimal(replace(tqBankNumberByParentID.tcBankNumber, ".":U, "":U)),">>>>>99999999":U).
/* Create the headerrecord 1 (Bestandverloopinfo) */
create tExport.
assign tExport.tcValue = "0001":U +
"A":U +
<M-17 FormatDateDDMMYY (input today (itDate)) in BDCollection> +
"CLIEOP03":U +
string(vcCompanyName, "x(5)":U) +
string(day(today), "99":U) +
"01":U +
(if ilDuplicate
then "2":U
else "1":U) +
string("", "x(21)":U)
tExport.tiSeq = 1.
/* Create the headerrecord 2 (Batchvoorloopinfo) */
create tExport.
assign tExport.tcValue = "0010":U +
"B":U +
"10":U +
string(trim(vcBankNumber), "x(10)":U) +
"0001":U +
"EUR":U +
string("":U, "x(26)":U)
tExport.tiSeq = 2.
/* Create the headerrecord 3 (Opdrachtgever info) */
create tExport.
assign tExport.tcValue = "0030B1":U +
<M-18 FormatDateDDMMYY (input itSpilDate (itDate)) in BDCollection> +
string(vcCompanyName, "x(35)":U) +
"P":U +
string("":U, "x(2)":U)
tExport.tiSeq = 3.
/* Create payrecords 1 (Transactieinfo) */
<Q-19 run DDocumentByCollectionID (all) (Read) (NoCache)
(input tqDCollectionByID.tiCompany_ID, (CompanyId)
input tqDCollectionByID.tiDCollection_ID, (DCollectionID)
input ?, (DDocumentID)
input {&DOCUMENTSTATUS-INCASSO} + ',':U + {&DOCUMENTSTATUS-DISCONT}, (DDocumentStatus)
output dataset tqDDocumentByCollectionID) in BDDocument >
assign viA = 3
vdTotalBankNrs = 0
vdTotalLC = 0
viPostCounter = 0.
<Q-20 run DebtorByDebtor
(Start) in BDebtor >
for each tqDDocumentByCollectionID:
<Q-21 run DebtorByDebtor (first) (Read) (NoCache)
(input tqDCollectionByID.tiCompany_ID, (CompanyId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
input tqDDocumentByCollectionID.tiDebtor_ID, (DebtorId)
input ?, (DebtorCode)
output dataset tqDebtorByDebtor) in BDebtor >
find first tqDebtorByDebtor
no-error.
if available tqDebtorByDebtor
then do:
<M-25 run ValidateByExportType
(input {&DCOLLECTIONEXPORTTYPE-CLIEOP03} (icBankFileFormat),
input tqDebtorByDebtor.tiDebtor_ID (iiDebtorID),
input tqDebtorByDebtor.tcDebtorCode (icDebtorCode),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper < 0
then do:
assign oiReturnStatus = -1.
return.
END.
/* Get the Debtor BankNumber */
<Q-23 run BankNumberByParentID (all) (Read) (NoCache)
(input tqDebtorByDebtor.tiDebtor_ID, (ParentObjectId)
input {&BANKNUMBERPARENTTYPE-DEBTOR}, (BankNumberParentType)
input true, (BankNumberIsDefault)
input tqDCollectionByID.tiCompany_ID, (CompanyId)
output dataset tqBankNumberByParentID) in BBankNumber >
find first tqBankNumberByParentID
no-error.
if available tqBankNumberByParentID
then assign vcDebtorBankNumber = tqBankNumberByParentID.tcBankNumber.
create tExport.
assign vcDebtorName = tqDebtorByDebtor.tcBusinessRelationName1
vcDebtorCity = tqDebtorByDebtor.tcAddressCity
viPostCounter = viPostCounter + 1
viA = viA + 1
vdTotalLC = vdTotalLC + tqDDocumentByCollectionID.tdDDocumentOriginalDebitLC * 100
vdTotalBankNrs = vdTotalBankNrs + decimal(vcDebtorBankNumber) + decimal(vcBankNumber)
tExport.tcValue = "0100A":U +
"1001":U +
string(tqDDocumentByCollectionID.tdDDocumentOriginalDebitLC * 100, "999999999999":U) +
string(trim(vcDebtorBankNumber), "9999999999":U) +
string(trim(vcBankNumber), "9999999999":U) +
fill("":U, 42)
tExport.tiSeq = viA.
create tExport.
assign viA = viA + 1
tExport.tcValue = "0110B":U +
string(vcDebtorName, "x(35)":U) +
fill("":U, 10)
tExport.tiSeq = viA.
create tExport.
assign viA = viA + 1
tExport.tcValue = "0113B":U +
string(vcDebtorCity, "x(35)":U) +
fill("":U, 10)
tExport.tiSeq = viA.
create tExport.
assign viA = viA + 1
tExport.tcValue = "0160A":U +
string(tqDDocumentByCollectionID.tcDDocumentReference, "x(16)":U) +
fill("":U, 29)
tExport.tiSeq = viA.
/* Create payrecords 3 (Naam begunstigde info) */
create tExport.
assign viA = viA + 1
tExport.tcValue = "0170B":U +
string(vcCompanyName, "x(24)":U) +
fill("":U, 10)
tExport.tiSeq = viA.
/* Create payrecords 4 (Woonplaats begunstigde info) */
create tExport.
assign viA = viA + 1
tExport.tcValue = "0173B":U +
string(vcCompanyCity, "x(35)":U) +
fill("":U, 10)
tExport.tiSeq = viA.
end.
end.
<Q-24 run DebtorByDebtor
(Stop) in BDebtor >
/* Endrecord 1 (batchsluitinfo) */
create tExport.
assign viA = viA + 1
vcTotalBankNrs = <M-27 LessSignificantX
(input vdTotalBankNrs (idValueIn),
input 9 (iiX)) in BDCollection>
tExport.tcValue = "9990A":U +
string(vdTotalLC * 100, "999999999999999999":U) +
string(vcTotalBankNrs, "9999999999":U) +
string(viPostCounter, "9999999":U) +
string("":U, "x(10)":U)
tExport.tiSeq = viA.
/* Endrecord 2 (Bestandssluitinfo) */
create tExport.
assign viA = viA + 1
tExport.tcValue = "9999A":U + string("":U, "x(45)":U)
tExport.tiSeq = viA.