project QadFinancials > class BBankEntry > method GetPossibleCollAllocationsDebtor
Description
GetPossibleCollAllocations; for debtor documents/debtor 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 |
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 vcDocumentTypeDebtors = {&DOCUMENTTYPEDEBTORS}.
if iiDocumentYear <> 0 or
icDocumentType <> "":U or
iiDocumentNumber <> 0
then do:
<Q-1 run DDocumentForBankEntry (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input iiDocumentYear, (DDocumentYear)
input icDocumentType, (DDocumentType)
input iiDocumentNumber, (DDocumentNumber)
input itFromRequestedDate, (FromRequestedDate)
input idTotalCollectionAmountTC, (TotalCollectionAmount)
input icGLCode, (GLCode)
input {&DOCUMENTSTATUS-INCASSO} + ',':U + {&DOCUMENTSTATUS-DISCONT}, (DDocumentStatus)
input '*':U + icDocumentReference + '*':U, (DocumentReference)
input '*':U + icSelectionCode + '*':U, (IncSelCode)
output dataset tqDDocumentForBankEntry) in BDDocument >
for each tqDDocumentForBankEntry where
tqDDocumentForBankEntry.tiCompany_ID = iiCompanyID and
tqDDocumentForBankEntry.tdDCollectionBalanceDebitTC <> 0 and
tqDDocumentForBankEntry.tdDCollectionBalanceDebitTC <> ?:
/*CA673304 removed condition tlDCollectionIsAutomatic
if not tqDDocumentForBankEntry.tlDCollectionIsExecuted
then next.*/
find first tPossibleBankStateAlloc where
tPossibleBankStateAlloc.tc_Rowid = if num-entries(tqDDocumentForBankEntry.tc_Rowid) > 2
then entry(3, tqDDocumentForBankEntry.tc_Rowid)
else tqDDocumentForBankEntry.tc_Rowid
no-error.
if not available tPossibleBankStateAlloc
then do:
create tPossibleBankStateAlloc.
assign tPossibleBankStateAlloc.Company_ID = iiCompanyID
tPossibleBankStateAlloc.tcCompanyCode = vcCompanyCodeBE
tPossibleBankStateAlloc.DCollection_ID = tqDDocumentForBankEntry.tiDCollection_ID
tPossibleBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-DCOLL}
tPossibleBankStateAlloc.Currency_ID = ?
tPossibleBankStateAlloc.tcCurrencyCode = icBankCurrencyCode
tPossibleBankStateAlloc.tcDocCurrencyCode = if tqDDocumentForBankEntry.tcGLCurrencyCode = "":U or
tqDDocumentForBankEntry.tcGLCurrencyCode = ?
then vcCompanyLC
else tqDDocumentForBankEntry.tcGLCurrencyCode
tPossibleBankStateAlloc.tcLocalCurrencyCode = vcCompanyLC
tPossibleBankStateAlloc.BankStateLine_ID = iiBankStateLineID
tPossibleBankStateAlloc.BankStateAllocBankRate = idBankRate
tPossibleBankStateAlloc.BankStateAllocBankRteScale = idBankRateScale
tPossibleBankStateAlloc.tc_ParentRowid = icBankStateLineTcRowid
tPossibleBankStateAlloc.tc_Rowid = if num-entries(tqDDocumentForBankEntry.tc_Rowid) > 2
then entry(3, tqDDocumentForBankEntry.tc_Rowid)
else tqDDocumentForBankEntry.tc_Rowid
tPossibleBankStateAlloc.tiCollNumber = tqDDocumentForBankEntry.tiDCollectionNumber
tPossibleBankStateAlloc.tcCollReference = tqDDocumentForBankEntry.tcDCollectionReference
tPossibleBankStateAlloc.tcCollSelectionCode = tqDDocumentForBankEntry.tcDCollectionIncSelCodeList
tPossibleBankStateAlloc.tdCollBalance = tqDDocumentForBankEntry.tdDCollectionBalanceDebitTC
tPossibleBankStateAlloc.tcCollBalanceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.ttCollRequestedDate = tqDDocumentForBankEntry.ttDCollectionRequestedDate
tPossibleBankStateAlloc.tcDocNumberReference = string(tqDDocumentForBankEntry.tiDCollectionYear) + "/":U +
string(tqDDocumentForBankEntry.tiDCollectionNumber) + "/":U +
string(tqDDocumentForBankEntry.tcDCollectionReference)
tPossibleBankStateAlloc.tcNewBalanceCrDt = tPossibleBankStateAlloc.tcCollBalanceCrDt
tPossibleBankStateAlloc.tdNewBalanceTC = tqDDocumentForBankEntry.tdDCollectionBalanceDebitTC
tPossibleBankStateAlloc.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.tcDocBalanceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.tcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.tcCCCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}.
end. /* if not available tPossibleBankStateAlloc.. */
find first tPossibleBankStateCollAlloc where
tPossibleBankStateCollAlloc.tc_Rowid = entry(1, tqDDocumentForBankEntry.tc_RowId)
no-error.
if not available tPossibleBankStateCollAlloc
then do:
create tPossibleBankStateCollAlloc.
assign tPossibleBankStateCollAlloc.tc_ParentRowid = tPossibleBankStateAlloc.tc_Rowid
tPossibleBankStateCollAlloc.tc_Rowid = entry(1, tqDDocumentForBankEntry.tc_RowId)
tPossibleBankStateCollAlloc.Company_ID = tqDDocumentForBankEntry.tiCompany_ID
tPossibleBankStateCollAlloc.DDocument_ID = tqDDocumentForBankEntry.tiDDocument_ID
tPossibleBankStateCollAlloc.tiDDocumentYear = tqDDocumentForBankEntry.tiDDocumentYear
tPossibleBankStateCollAlloc.tiDDocumentNumber = tqDDocumentForBankEntry.tiDDocumentNumber
tPossibleBankStateCollAlloc.tcDDocumentType = tqDDocumentForBankEntry.tcDDocumentType
tPossibleBankStateCollAlloc.tcDocBusinessRelationCode = tqDDocumentForBankEntry.tcBusinessRelationCode
tPossibleBankStateCollAlloc.tcDocNumberReference = trim(string(tqDDocumentForBankEntry.tiDDocumentYear)) + "/":U + trim(string(tqDDocumentForBankEntry.tiDDocumentNumber)) + "/":U + string(tqDDocumentForBankEntry.tcDDocumentReference)
tPossibleBankStateCollAlloc.tdDocAmount = tqDDocumentForBankEntry.tdDDocumentOriginalDebitTC
tPossibleBankStateCollAlloc.tdDocAmountBC = tqDDocumentForBankEntry.tdDDocumentOriginalDebitBC
tPossibleBankStateCollAlloc.tcDocAmountCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateCollAlloc.tcDocCurrencyCode = tqDDocumentForBankEntry.tcDocumentCurrencyCode
tPossibleBankStateCollAlloc.tdDocExchangeRate = tqDDocumentForBankEntry.tdDDocumentExchangeRate
tPossibleBankStateCollAlloc.tdDocExchangeRateScale = tqDDocumentForBankEntry.tdDDocumentRateScale
tPossibleBankStateCollAlloc.tdDocCCExchangeRate = tqDDocumentForBankEntry.tdDDocumentCCRate
tPossibleBankStateCollAlloc.tdDocCCExchangeRateScale = tqDDocumentForBankEntry.tdDDocumentCCScale
tPossibleBankStateCollAlloc.BankStateAllocCollIsAlloc = false
tPossibleBankStateCollAlloc.tlDocIsBounced = false.
end. /* if not available tPossibleBankStateCollAlloc .. */
do viCounter = num-entries(vcDocumentTypeDebtors, chr(2)) to 2 by -2:
if entry(viCounter, vcDocumentTypeDebtors, chr(2)) = tqDDocumentForBankEntry.tcDDocumentType
then do:
assign tPossibleBankStateCollAlloc.tcDocType = entry(viCounter - 1, vcDocumentTypeDebtors, chr(2)).
leave.
end.
end.
end.
end.
else do:
<Q-2 run DCollectionByAllocation (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input ?, (DCollectionID)
input ?, (DCollectionReference)
input idTotalCollectionAmountTC, (DCollectionOriginalTC)
input itFromRequestedDate, (FromRequestedDate)
input ?, (GLId)
input icGLCode, (GLCode)
input '*':U + icSelectionCode + '*':U, (IncSelCode)
output dataset tqDCollectionByAllocation) in BDCollection >
<Q-5 run DDocumentByCollectionID (Start) in BDDocument >
for each tqDCollectionByAllocation where
tqDCollectionByAllocation.tdDCollectionBalanceDebitTC <> 0 and
tqDCollectionByAllocation.tdDCollectionBalanceDebitTC <> ?:
if tqDCollectionByAllocation.tlDCollectionIsAutomatic and
not tqDCollectionByAllocation.tlDCollectionIsExecuted
then next.
create tPossibleBankStateAlloc.
assign tPossibleBankStateAlloc.Company_ID = iiCompanyID
tPossibleBankStateAlloc.tcCompanyCode = vcCompanyCodeBE
tPossibleBankStateAlloc.DCollection_ID = tqDCollectionByAllocation.tiDCollection_ID
tPossibleBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-DCOLL}
tPossibleBankStateAlloc.Currency_ID = ?
tPossibleBankStateAlloc.tcCurrencyCode = icBankCurrencyCode
tPossibleBankStateAlloc.tcDocCurrencyCode = if tqDCollectionByAllocation.tcCurrencyCode = "":U or
tqDCollectionByAllocation.tcCurrencyCode = ?
then vcCompanyLC
else tqDCollectionByAllocation.tcCurrencyCode
tPossibleBankStateAlloc.tcLocalCurrencyCode = vcCompanyLC
tPossibleBankStateAlloc.BankStateLine_ID = iiBankStateLineID
tPossibleBankStateAlloc.BankStateAllocBankRate = idBankRate
tPossibleBankStateAlloc.BankStateAllocBankRteScale = idBankRateScale
tPossibleBankStateAlloc.tc_ParentRowid = icBankStateLineTcRowid
tPossibleBankStateAlloc.tc_Rowid = entry(1, tqDCollectionByAllocation.tc_Rowid)
tPossibleBankStateAlloc.tiCollNumber = tqDCollectionByAllocation.tiDCollectionNumber
tPossibleBankStateAlloc.tcCollReference = tqDCollectionByAllocation.tcDCollectionReference
tPossibleBankStateAlloc.tcCollSelectionCode = tqDCollectionByAllocation.tcDCollectionIncSelCodeList
tPossibleBankStateAlloc.tdCollBalance = tqDCollectionByAllocation.tdDCollectionBalanceDebitTC
tPossibleBankStateAlloc.tcCollBalanceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.ttCollRequestedDate = tqDCollectionByAllocation.ttDCollectionRequestedDate
tPossibleBankStateAlloc.tcDocNumberReference = string(tqDCollectionByAllocation.tiDCollectionYear) + "/":U +
string(tqDCollectionByAllocation.tiDCollectionNumber) + "/":U +
string(tqDCollectionByAllocation.tcDCollectionReference)
tPossibleBankStateAlloc.tcNewBalanceCrDt = tPossibleBankStateAlloc.tcCollBalanceCrDt
tPossibleBankStateAlloc.tdNewBalanceTC = tqDCollectionByAllocation.tdDCollectionBalanceDebitTC
tPossibleBankStateAlloc.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
tPossibleBankStateAlloc.tcDocBalanceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.tcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateAlloc.tcCCCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}.
<Q-4 run DDocumentByCollectionID (all) (Read) (NoCache)
(input tPossibleBankStateAlloc.Company_ID, (CompanyId)
input tqDCollectionByAllocation.tiDCollection_ID, (DCollectionID)
input ?, (DDocumentID)
input {&DOCUMENTSTATUS-INCASSO} + ',':U + {&DOCUMENTSTATUS-DISCONT}, (DDocumentStatus)
output dataset tqDDocumentByCollectionID) in BDDocument >
for each tqDDocumentByCollectionID:
create tPossibleBankStateCollAlloc.
assign tPossibleBankStateCollAlloc.tc_ParentRowid = tPossibleBankStateAlloc.tc_Rowid
tPossibleBankStateCollAlloc.tc_Rowid = entry(1, tqDDocumentByCollectionID.tc_RowId)
tPossibleBankStateCollAlloc.Company_ID = tqDDocumentByCollectionID.tiCompany_ID
tPossibleBankStateCollAlloc.DDocument_ID = tqDDocumentByCollectionID.tiDDocument_ID
tPossibleBankStateCollAlloc.tiDDocumentYear = tqDDocumentByCollectionID.tiDDocumentYear
tPossibleBankStateCollAlloc.tiDDocumentNumber = tqDDocumentByCollectionID.tiDDocumentNumber
tPossibleBankStateCollAlloc.tcDDocumentType = tqDDocumentByCollectionID.tcDDocumentType
tPossibleBankStateCollAlloc.tcDocBusinessRelationCode = tqDDocumentByCollectionID.tcBusinessRelationCode
tPossibleBankStateCollAlloc.tcDocNumberReference = string(tqDDocumentByCollectionID.tiDDocumentYear) + "/":U +
string(tqDDocumentByCollectionID.tiDDocumentNumber) + "/":U +
string(tqDDocumentByCollectionID.tcDDocumentReference)
tPossibleBankStateCollAlloc.tdDocAmount = tqDDocumentByCollectionID.tdDDocumentOriginalDebitTC
tPossibleBankStateCollAlloc.tdDocAmountBC = tqDDocumentByCollectionID.tdDDocumentOriginalDebitBC
tPossibleBankStateCollAlloc.tcDocAmountCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
tPossibleBankStateCollAlloc.tcDocCurrencyCode = tqDDocumentByCollectionID.tcCurrencyCode
tPossibleBankStateCollAlloc.tdDocExchangeRate = tqDDocumentByCollectionID.tdDDocumentExchangeRate
tPossibleBankStateCollAlloc.tdDocExchangeRateScale = tqDDocumentByCollectionID.tdDDocumentRateScale
tPossibleBankStateCollAlloc.tdDocCCExchangeRate = tqDDocumentByCollectionID.tdDDocumentCCRate
tPossibleBankStateCollAlloc.tdDocCCExchangeRateScale = tqDDocumentByCollectionID.tdDDocumentCCScale
tPossibleBankStateCollAlloc.BankStateAllocCollIsAlloc = false
tPossibleBankStateCollAlloc.tlDocIsBounced = false.
do viCounter = num-entries(vcDocumentTypeDebtors, chr(2)) to 2 by -2:
if entry(viCounter, vcDocumentTypeDebtors, chr(2)) = tqDDocumentByCollectionID.tcDDocumentType
then do:
assign tPossibleBankStateCollAlloc.tcDocType = entry(viCounter - 1, vcDocumentTypeDebtors, chr(2)).
leave.
end.
end.
end.
end.
<Q-6 run DDocumentByCollectionID (Stop) in BDDocument >
end.