Parameters
iiDCollectionId | input | integer | |
itSpilDate | input | date | |
icFileFormat | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bdcollection.p)
/* Get the collection */
<Q-1 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-2 run SetMessage
(input trim(#T-18'The customer payment collection $1 cannot be found.':250(1635)T-18#) (icMessage),
input string(iiDCollectionId) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-2949':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign oiReturnStatus = -1.
return.
end.
/* Get the Current Company Name */
<Q-7 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-8 run BusinessRelationByIdCode (all) (Read) (NoCache)
(input tqCompanyPropertyByIdCode.tiBusinessRelation_ID, (BusinessRelationId)
input ?, (BusinessRelationCode)
output dataset tqBusinessRelationByIdCode) in BBusinessRelation >
find first tqBusinessRelationByIdCode where
tqBusinessRelationByIdCode.tiBusinessRelation_ID = tqCompanyPropertyByIdCode.tiBusinessRelation_ID
no-error.
if available tqBusinessRelationByIdCode
then assign vcCompanyName = tqBusinessRelationByIdCode.tcBusinessRelationName1.
end.
/* Get the Current Company BankNumber */
<Q-3 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 do:
assign vcBankNumber = tqBankNumberByParentID.tcBankNumber.
<Q-4 run BusinessRelationByIdCode (all) (Read) (NoCache)
(input tqBankNumberByParentID.tiBankBusinessRelation_ID, (BusinessRelationId)
input ?, (BusinessRelationCode)
output dataset tqBusinessRelationByIdCode) in BBusinessRelation >
find first tqBusinessRelationByIdCode where
tqBusinessRelationByIdCode.tiBusinessRelation_ID = tqBankNumberByParentID.tiBankBusinessRelation_ID
no-error.
if available tqBusinessRelationByIdCode
then assign vcBankName = tqBusinessRelationByIdCode.tcBusinessRelationName1.
end.
/* Start Record */
create tExport.
assign tExport.tcValue = "0360":U +
string(1, "99999999":U) +
fill(" ":U, 12) +
<M-5 FormatDateDDMMYY (input today (itDate)) in BDCollection> +
string(vcCompanyName, "x(24)":U) +
string(vcBankName, "x(24)":U) +
"4":U +
" ":U +
" ":U +
string(substr(vcBankNumber, 1, 5,"CHARACTER":U), "x(5)":U) +
string(substr(vcBankNumber, 6, 5,"CHARACTER":U), "x(5)":U) +
string(substr(vcBankNumber, 11, 11,"CHARACTER":U), "x(11)":U) +
fill(" ":U, 16) +
<M-6 FormatDateDDMMYY (input itSpilDate (itDate)) in BDCollection> +
fill(" ":U, 10) +
fill(" ":U, 15) +
fill(" ":U, 11 - length(tqDCollectionByID.tcDCollectionReference,"CHARACTER":U)) +
tqDCollectionByID.tcDCollectionReference
tExport.tiSeq = 1.
<Q-9 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 = 1
vdTotalLC = 0.
<Q-10 run DebtorByDebtor
(Start) in BDebtor >
for each tqDDocumentByCollectionID:
<Q-11 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-17 run ValidateByExportType (input icFileFormat (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-12 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 do:
assign vcDebtorBankNumber = tqBankNumberByParentID.tcBankNumber.
<Q-13 run BusinessRelationByIdCode (all) (Read) (NoCache)
(input tqBankNumberByParentID.tiBankBusinessRelation_ID, (BusinessRelationId)
input ?, (BusinessRelationCode)
output dataset tqBusinessRelationByIdCode) in BBusinessRelation >
find first tqBusinessRelationByIdCode where
tqBusinessRelationByIdCode.tiBusinessRelation_ID = tqBankNumberByParentID.tiBankBusinessRelation_ID
no-error.
if available tqBusinessRelationByIdCode
then assign vcDebtorBankName = tqBusinessRelationByIdCode.tcBusinessRelationName1.
end.
create tExport.
assign viA = viA + 1
vdTotalLC = vdTotalLC + tqDDocumentByCollectionID.tdDDocumentOriginalDebitLC
tExport.tcValue = "0660":U +
string(viA, "99999999":U) +
fill(" ":U, 6) +
fill(" ":U, 2) +
string("":U, "x(10)":U) +
string(tqDebtorByDebtor.tcBusinessRelationName1, "x(24)":U) +
string(vcDebtorBankName, "x(24)":U) +
(if icFileFormat = {&DCOLLECTIONEXPORTTYPE-LCR} then "1":U else "3":U) +
fill(" ":U, 2) +
string(substr(vcDebtorBankNumber, 1, 5,"CHARACTER":U), "x(5)":U) +
string(substr(vcDebtorBankNumber, 6, 5,"CHARACTER":U), "x(5)":U) +
string(substr(vcDebtorBankNumber, 11, 11,"CHARACTER":U), "x(11)":U) +
string(tqDDocumentByCollectionID.tdDDocumentOriginalDebitLC * 100, "999999999999":U) +
fill(" ":U, 4) +
<M-14 FormatDateDDMMYY (input itSpilDate (itDate)) in BDCollection> +
<M-15 FormatDateDDMMYY (input today (itDate)) in BDCollection> +
fill(" ":U, 20) +
fill(" ":U, 10 - length(tqDCollectionByID.tcDCollectionReference,"CHARACTER":U)) +
tqDCollectionByID.tcDCollectionReference
tExport.tiSeq = viA.
create tExport.
assign viA = viA + 1
tExport.tcValue = "1660":U +
string(viA, "99999999":U) +
fill(" ":U, 6) +
string(tqDebtorByDebtor.tcAddressStreet1, "x(32)":U) +
string(tqDebtorByDebtor.tcAddressCity, "x(32)":U) +
string(tqDebtorByDebtor.tcAddressZip, "x(31)":U) +
fill(" ":U, 47)
tExport.tiSeq = viA.
end.
end.
<Q-16 run DebtorByDebtor
(Stop) in BDebtor >
/* EndRecord */
create tExport.
assign viA = viA + 1
tExport.tcValue = "0860":U +
string(viA, "99999999":U) +
fill(" ":U, 90) +
string(vdTotalLC * 100, "999999999999":U) +
fill(" ":U, 46)
tExport.tiSeq = viA.