project QadFinancials > class BBankEntry > method GetPossibleCollAllocationsCreditor
Description
GetPossibleCollAllocations; for creditor documents/creditor collections
Parameters
iiCompanyID | input | integer | Entity ID |
iiBankStateLineID | input | integer | BankStateLineID wherefor the allocations need to be proposed |
icBankStateLineTcRowid | input | character | BankStateLine TcRowid wherefor the allocations need to be proposed |
itFromRequestedDate | input | date | FromRequestedDate |
idTotalCollectionAmountTC | input | decimal | CollectionOriginalAmountTC (Credit or Debit) |
ilIncludeDebtor | input | logical | InlcudeDebtor |
ilIncludeCreditor | input | logical | InlcudeCreditor |
icBankCurrencyCode | input | character | Bank Currency Code |
icGLCode | input | character | GL code |
itBankStateLineValueDate | input | date | Bank State Line Value Date |
iiDocumentYear | input | integer | Document Year |
icDocumentType | input | character | document type |
iiDocumentNumber | input | integer | Document Number |
idBankRate | input | decimal | Bank Rate |
idBankRateScale | input | decimal | Bank Rate Scale |
iiCDocumentPrePrintedNumber | input | integer | |
icDocumentReference | input | character | |
icSelectionCode | input | character | |
tPossibleBankStateAlloc | output | temp-table | Possible records for BankStateAlloc |
tPossibleBankStateCollAlloc | output | temp-table | Possible records for BankStateAllocColl |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bbankentry.p)
assign vcDocumentTypeCreditors = {&DOCUMENTTYPECREDITORS}.
if iiDocumentYear <> 0 or
icDocumentType <> "":U or
iiDocumentNumber <> 0 or
iiCDocumentPrePrintedNumber <> 0 or
icDocumentReference <> "":U
then do:
<Q-1 run CDocumentByAllocationInfo (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input iiDocumentYear, (CDocumentYear)
input icDocumentType, (CDocumentType)
input iiDocumentNumber, (CDocumentNumber)
input itFromRequestedDate, (FromRequestedDate)
input idTotalCollectionAmountTC, (TotalCollectionAmount)
input icGLCode, (GLCode)
input {&DOCUMENTSTATUS-INCASSO} + ',':U + {&DOCUMENTSTATUS-DISCONT}, (CDocumentStatus)
input iiCDocumentPrePrintedNumber, (PrePrintedNumber)
input '*':U + icDocumentReference + '*':U, (CDocumentReference)
input '*':U + icSelectionCode + '*':U, (PaySelCode)
output dataset tqCDocumentByAllocationInfo) in BCDocument >
for each tqCDocumentByAllocationInfo where
tqCDocumentByAllocationInfo.tiCompany_ID = iiCompanyID and
tqCDocumentByAllocationInfo.tdCCollectionBalanceCreditTC <> 0 and
tqCDocumentByAllocationInfo.tdCCollectionBalanceCreditTC <> ?:
/*CA673304 removed condition tlDCollectionIsAutomatic
if not tqCDocumentByAllocationInfo.tlCCollectionIsExecuted
then next.*/
find first tPossibleBankStateAlloc where tPossibleBankStateAlloc.tc_Rowid = if num-entries(tqCDocumentByAllocationInfo.tc_Rowid) > 1
then entry(2, tqCDocumentByAllocationInfo.tc_Rowid)
else tqCDocumentByAllocationInfo.tc_Rowid
no-error.
if not available tPossibleBankStateAlloc
then do:
create tPossibleBankStateAlloc.
assign tPossibleBankStateAlloc.Company_ID = iiCompanyID
tPossibleBankStateAlloc.tcCompanyCode = vcCompanyCodeBE
tPossibleBankStateAlloc.CCollection_ID = tqCDocumentByAllocationInfo.tiCCollection_ID
tPossibleBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-CCOLL}
tPossibleBankStateAlloc.Currency_ID = ?
tPossibleBankStateAlloc.tcCurrencyCode = icBankCurrencyCode
tPossibleBankStateAlloc.tcDocCurrencyCode = if tqCDocumentByAllocationInfo.tcGLCurrencyCode= "":U or
tqCDocumentByAllocationInfo.tcGLCurrencyCode = ?
then vcCompanyLC
else tqCDocumentByAllocationInfo.tcGLCurrencyCode
tPossibleBankStateAlloc.tcLocalCurrencyCode = vcCompanyLC
tPossibleBankStateAlloc.BankStateLine_ID = iiBankStateLineID
tPossibleBankStateAlloc.BankStateAllocBankRate = idBankRate
tPossibleBankStateAlloc.BankStateAllocBankRteScale = idBankRateScale
tPossibleBankStateAlloc.tc_ParentRowid = icBankStateLineTcRowid
tPossibleBankStateAlloc.tc_Rowid = if num-entries(tqCDocumentByAllocationInfo.tc_Rowid) > 1
then entry(2, tqCDocumentByAllocationInfo.tc_Rowid)
else tqCDocumentByAllocationInfo.tc_Rowid
tPossibleBankStateAlloc.tiCollNumber = tqCDocumentByAllocationInfo.tiCCollectionNumber
tPossibleBankStateAlloc.tcCollReference = tqCDocumentByAllocationInfo.tcCCollectionReference
tPossibleBankStateAlloc.tcCollSelectionCode = tqCDocumentByAllocationInfo.tcCCollectionPaySelCodeList
tPossibleBankStateAlloc.tdCollBalance = tqCDocumentByAllocationInfo.tdCCollectionBalanceCreditTC
tPossibleBankStateAlloc.tcCollBalanceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.ttCollRequestedDate = tqCDocumentByAllocationInfo.ttCCollectionRequestedDate
tPossibleBankStateAlloc.tcDocNumberReference = string(tqCDocumentByAllocationInfo.tiCCollectionYear) + "/":U +
string(tqCDocumentByAllocationInfo.tiCCollectionNumber) + "/":U +
string(tqCDocumentByAllocationInfo.tcCCollectionReference)
tPossibleBankStateAlloc.tcNewBalanceCrDt = tPossibleBankStateAlloc.tcCollBalanceCrDt
tPossibleBankStateAlloc.tdNewBalanceTC = tqCDocumentByAllocationInfo.tdCCollectionBalanceCreditTC
tPossibleBankStateAlloc.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.tcDocBalanceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.tcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.tcCCCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}.
end. /* if not available tPossibleBankStateAlloc.. */
find first tPossibleBankStateCollAlloc where
tPossibleBankStateCollAlloc.tc_Rowid = entry(1, tqCDocumentByAllocationInfo.tc_RowId)
no-error.
if not available tPossibleBankStateCollAlloc
then do:
create tPossibleBankStateCollAlloc.
assign tPossibleBankStateCollAlloc.tc_ParentRowid = tPossibleBankStateAlloc.tc_Rowid
tPossibleBankStateCollAlloc.tc_Rowid = entry(1, tqCDocumentByAllocationInfo.tc_RowId)
tPossibleBankStateCollAlloc.Company_ID = tqCDocumentByAllocationInfo.tiCompany_ID
tPossibleBankStateCollAlloc.CDocument_ID = tqCDocumentByAllocationInfo.tiCDocument_ID
tPossibleBankStateCollAlloc.tiCDocumentYear = tqCDocumentByAllocationInfo.tiCDocumentYear
tPossibleBankStateCollAlloc.tiCDocumentNumber = tqCDocumentByAllocationInfo.tiCDocumentNumber
tPossibleBankStateCollAlloc.tcCDocumentType = tqCDocumentByAllocationInfo.tcCDocumentType
tPossibleBankStateCollAlloc.tcDocBusinessRelationCode = tqCDocumentByAllocationInfo.tcBusinessRelationCode
tPossibleBankStateCollAlloc.tcDocNumberReference = string(tqCDocumentByAllocationInfo.tiCDocumentYear) + "/":U +
string(tqCDocumentByAllocationInfo.tiCDocumentNumber) + "/":U +
string(tqCDocumentByAllocationInfo.tcCDocumentReference)
tPossibleBankStateCollAlloc.tdDocAmount = tqCDocumentByAllocationInfo.tdCDocumentOriginalCreditTC
tPossibleBankStateCollAlloc.tdDocAmountBC = tqCDocumentByAllocationInfo.tdCDocumentOriginalCreditBC
tPossibleBankStateCollAlloc.tcDocAmountCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateCollAlloc.tcDocCurrencyCode = tqCDocumentByAllocationInfo.tcDocumentCurrencyCode
tPossibleBankStateCollAlloc.tdDocExchangeRate = tqCDocumentByAllocationInfo.tdCDocumentExchangeRate
tPossibleBankStateCollAlloc.tdDocExchangeRateScale = tqCDocumentByAllocationInfo.tdCDocumentRateScale
tPossibleBankStateCollAlloc.tdDocCCExchangeRate = tqCDocumentByAllocationInfo.tdCDocumentCCRate
tPossibleBankStateCollAlloc.tdDocCCExchangeRateScale = tqCDocumentByAllocationInfo.tdCDocumentCCScale
tPossibleBankStateCollAlloc.BankStateAllocCollIsAlloc = false
tPossibleBankStateCollAlloc.tlDocIsBounced = false
tPossibleBankStateCollAlloc.tiCDocumentPrePrintedNumber = tqCDocumentByAllocationInfo.tiCDocumentPrePrintedNumber.
end. /* if not available tPossibleBankStateCollAlloc.. */
/* Add the checque number in the reference field */
if tqCDocumentByAllocationInfo.tiCDocumentPrePrintedNumber <> 0
then assign tPossibleBankStateCollAlloc.tcDocNumberReference =
tPossibleBankStateCollAlloc.tcDocNumberReference +
"/":U +
string (tqCDocumentByAllocationInfo.tiCDocumentPrePrintedNumber).
do viCounter = num-entries(vcDocumentTypeCreditors, chr(2)) to 2 by -2:
if entry(viCounter, vcDocumentTypeCreditors, chr(2)) = tqCDocumentByAllocationInfo.tcCDocumentType
then do:
assign tPossibleBankStateCollAlloc.tcDocType = entry(viCounter - 1, vcDocumentTypeCreditors, chr(2)).
leave.
end.
end.
end.
end.
else do:
<Q-2 run CCollectionByAllocation (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input ?, (CCollectionReference)
input itFromRequestedDate, (FromRequestedDate)
input idTotalCollectionAmountTC, (CCollectionOriginalTC)
input ?, (CCollectionID)
input icGLCode, (GLCode)
input ?, (GLId)
input '*':U + icSelectionCode + '*':U, (PaySelCode)
output dataset tqCCollectionByAllocation) in BCCollection >
<Q-3 run CDocumentByCollectionID (Start) in BCDocument >
for each tqCCollectionByAllocation where
tqCCollectionByAllocation.tdCCollectionBalanceCreditTC <> 0 and
tqCCollectionByAllocation.tdCCollectionBalanceCreditTC <> ?:
if tqCCollectionByAllocation.tlCCollectionIsAutomatic and
not tqCCollectionByAllocation.tlCCollectionIsExecuted
then next.
create tPossibleBankStateAlloc.
assign tPossibleBankStateAlloc.Company_ID = iiCompanyID
tPossibleBankStateAlloc.tcCompanyCode = vcCompanyCodeBE
tPossibleBankStateAlloc.CCollection_ID = tqCCollectionByAllocation.tiCCollection_ID
tPossibleBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-CCOLL}
tPossibleBankStateAlloc.Currency_ID = ?
tPossibleBankStateAlloc.tcCurrencyCode = icBankCurrencyCode
tPossibleBankStateAlloc.tcDocCurrencyCode = if tqCCollectionByAllocation.tcCurrencyCode = "":U or
tqCCollectionByAllocation.tcCurrencyCode = ?
then vcCompanyLC
else tqCCollectionByAllocation.tcCurrencyCode
tPossibleBankStateAlloc.tcLocalCurrencyCode = vcCompanyLC
tPossibleBankStateAlloc.BankStateLine_ID = iiBankStateLineID
tPossibleBankStateAlloc.BankStateAllocBankRate = idBankRate
tPossibleBankStateAlloc.BankStateAllocBankRteScale = idBankRateScale
tPossibleBankStateAlloc.tc_ParentRowid = icBankStateLineTcRowid
tPossibleBankStateAlloc.tc_Rowid = entry(1, tqCCollectionByAllocation.tc_Rowid)
tPossibleBankStateAlloc.tiCollNumber = tqCCollectionByAllocation.tiCCollectionNumber
tPossibleBankStateAlloc.tcCollReference = tqCCollectionByAllocation.tcCCollectionReference
tPossibleBankStateAlloc.tcCollSelectionCode = tqCCollectionByAllocation.tcCCollectionPaySelCodeList
tPossibleBankStateAlloc.tdCollBalance = tqCCollectionByAllocation.tdCCollectionBalanceCreditTC
tPossibleBankStateAlloc.tcCollBalanceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.ttCollRequestedDate = tqCCollectionByAllocation.ttCCollectionRequestedDate
tPossibleBankStateAlloc.tcDocNumberReference = string(tqCCollectionByAllocation.tiCCollectionYear) + "/":U +
string(tqCCollectionByAllocation.tiCCollectionNumber) + "/":U +
string(tqCCollectionByAllocation.tcCCollectionReference)
tPossibleBankStateAlloc.tcNewBalanceCrDt = tPossibleBankStateAlloc.tcCollBalanceCrDt
tPossibleBankStateAlloc.tdNewBalanceTC = tqCCollectionByAllocation.tdCCollectionBalanceCreditTC
tPossibleBankStateAlloc.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.tcDocBalanceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.tcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.tcCCCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-CREDIT}.
<Q-4 run CDocumentByCollectionID (all) (Read) (Cache)
(input tPossibleBankStateAlloc.Company_ID, (CompanyId)
input ?, (CDocumentID)
input tqCCollectionByAllocation.tiCCollection_ID, (CCollectionID)
input {&DOCUMENTSTATUS-INCASSO} + ',':U + {&DOCUMENTSTATUS-DISCONT}, (CDocumentStatus)
output dataset tqCDocumentByCollectionID) in BCDocument >
for each tqCDocumentByCollectionID:
create tPossibleBankStateCollAlloc.
assign tPossibleBankStateCollAlloc.tc_ParentRowid = tPossibleBankStateAlloc.tc_Rowid
tPossibleBankStateCollAlloc.tc_Rowid = entry(1, tqCDocumentByCollectionID.tc_RowId)
tPossibleBankStateCollAlloc.Company_ID = tqCDocumentByCollectionID.tiCompany_ID
tPossibleBankStateCollAlloc.CDocument_ID = tqCDocumentByCollectionID.tiCDocument_ID
tPossibleBankStateCollAlloc.tiCDocumentYear = tqCDocumentByCollectionID.tiCDocumentYear
tPossibleBankStateCollAlloc.tiCDocumentNumber = tqCDocumentByCollectionID.tiCDocumentNumber
tPossibleBankStateCollAlloc.tcCDocumentType = tqCDocumentByCollectionID.tcCDocumentType
tPossibleBankStateCollAlloc.tcDocBusinessRelationCode = tqCDocumentByCollectionID.tcBusinessRelationCode
tPossibleBankStateCollAlloc.tcDocNumberReference = string(tqCDocumentByCollectionID.tiCDocumentYear) + "/":U +
string(tqCDocumentByCollectionID.tiCDocumentNumber) + "/":U +
string(tqCDocumentByCollectionID.tcCDocumentReference)
tPossibleBankStateCollAlloc.tdDocAmount = tqCDocumentByCollectionID.tdCDocumentOriginalCreditTC
tPossibleBankStateCollAlloc.tdDocAmountBC = tqCDocumentByCollectionID.tdCDocumentOriginalCreditBC
tPossibleBankStateCollAlloc.tcDocAmountCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateCollAlloc.tcDocCurrencyCode = tqCDocumentByCollectionID.tcCurrencyCode
tPossibleBankStateCollAlloc.tdDocExchangeRate = tqCDocumentByCollectionID.tdCDocumentExchangeRate
tPossibleBankStateCollAlloc.tdDocExchangeRateScale = tqCDocumentByCollectionID.tdCDocumentRateScale
tPossibleBankStateCollAlloc.tdDocCCExchangeRate = tqCDocumentByCollectionID.tdCDocumentCCRate
tPossibleBankStateCollAlloc.tdDocCCExchangeRateScale = tqCDocumentByCollectionID.tdCDocumentCCScale
tPossibleBankStateCollAlloc.BankStateAllocCollIsAlloc = false
tPossibleBankStateCollAlloc.tlDocIsBounced = false
tPossibleBankStateCollAlloc.tiCDocumentPrePrintedNumber = tqCDocumentByCollectionID.tiCDocumentPrePrintedNumber.
/* Add the checque number in the reference field */
if tqCDocumentByCollectionID.tiCDocumentPrePrintedNumber <> 0
then assign tPossibleBankStateCollAlloc.tcDocNumberReference =
tPossibleBankStateCollAlloc.tcDocNumberReference +
"/":U +
string (tqCDocumentByCollectionID.tiCDocumentPrePrintedNumber).
do viCounter = num-entries(vcDocumentTypeCreditors, chr(2)) to 2 by -2:
if entry(viCounter, vcDocumentTypeCreditors, chr(2)) = tqCDocumentByCollectionID.tcCDocumentType
then do:
assign tPossibleBankStateCollAlloc.tcDocType = entry(viCounter - 1, vcDocumentTypeCreditors, chr(2)).
leave.
end.
end.
end.
end.
<Q-5 run CDocumentByCollectionID (Stop) in BCDocument >
end.