project QadFinancials > class BDebtorReport > method DebtorAgingHistAcroDomainDrafts
Parameters
idCurrExchangeRate | input | decimal | |
idCurrExchangeRateSF | input | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program7/bdebtorreport.p)
/* ================================================================================ */
/* Process the tqGetDraftInvoicesforDAAB and create tqDebtorAgingHistAcroDomain */
/* ================================================================================ */
assign vcPIPDescription = {&GLTYPECODE-DDOC-TR}.
for each tqGetDraftInvoicesforDAAB
break by tqGetDraftInvoicesforDAAB.tiDDocument_ID:
if first-of(tqGetDraftInvoicesforDAAB.tiDDocument_ID)
then do:
/* If "Within terms = no", skip all drafts that aren't due yet */
if vcDebtorAgingHistDateTypeFilter = {&DEBTORAGINGDATETYPE-INVOICEDATE}
then vtDateForAgingCalculate = tqGetDraftInvoicesforDAAB.ttDDocumentCreationDate.
else vtDateForAgingCalculate = tqGetDraftInvoicesforDAAB.ttDDocumentDueDate.
assign vlSkip = vlInvoicesWithinTermsFilter = false and vtDateForAgingCalculate >= vtDateForAgeingCalcFilter
vdBalanceCC = 0
vdBalanceLC = 0
vdBalanceTC = 0
viPostingYear = trunc (tqGetDraftInvoicesforDAAB.tiPostingYearPeriod / 100,0)
viPostingPeriod = tqGetDraftInvoicesforDAAB.tiPostingYearPeriod mod 100
vtPostingDate = tqGetDraftInvoicesforDAAB.ttPostingDate.
end.
if vlSkip
then next.
/* Calcualate the balance of the draft DDocument --> DDocumentPostingLine --> PostingLine */
assign vdBalanceCC = vdBalanceCC + tqGetDraftInvoicesforDAAB.tdPostingLineDebitCC - tqGetDraftInvoicesforDAAB.tdPostingLineCreditCC
vdBalanceLC = vdBalanceLC + tqGetDraftInvoicesforDAAB.tdPostingLineDebitLC - tqGetDraftInvoicesforDAAB.tdPostingLineCreditLC
vdBalanceTC = vdBalanceTC + tqGetDraftInvoicesforDAAB.tdPostingLineDebitTC - tqGetDraftInvoicesforDAAB.tdPostingLineCreditTC.
/* calculate the Year Period and PostingDate as this is not kept in DDocument */
if tqGetDraftInvoicesforDAAB.ttPostingDate < vtPostingDate
then assign viPostingYear = trunc (tqGetDraftInvoicesforDAAB.tiPostingYearPeriod / 100,0)
viPostingPeriod = tqGetDraftInvoicesforDAAB.tiPostingYearPeriod mod 100
vtPostingDate = tqGetDraftInvoicesforDAAB.ttPostingDate.
/* create the cr result set */
if last-of (tqGetDraftInvoicesforDAAB.tiDDocument_ID) and
(vdBalanceCC <> 0 or vdBalanceLC <> 0 or vdBalanceTC <> 0)
then do:
case vcReportingCurrencyFilter:
when {&CURRENCYTYPE-CC}
then assign vdBalanceXC = vdBalanceCC
vdOriginal1XC = vdOriginal1CC.
when {&CURRENCYTYPE-LC}
then assign vdBalanceXC = vdBalanceLC
vdOriginal1XC = vdOriginal1LC.
when {&CURRENCYTYPE-TC}
then assign vdBalanceXC = vdBalanceTC
vdOriginal1XC = vdOriginal1TC.
end. /* case */
/* tqDebtorAgingHistAcroDomain */
create tqDebtorAgingHistAcroDomain.
assign tqDebtorAgingHistAcroDomain.tcDebtorCode = tqGetDraftInvoicesforDAAB.tcDebtorCode
tqDebtorAgingHistAcroDomain.tcDebtorTypeCode = tqGetDraftInvoicesforDAAB.tcDebtorTypeCode
tqDebtorAgingHistAcroDomain.tcDebtorTypeDescription = tqGetDraftInvoicesforDAAB.tcDebtorTypeDescription
tqDebtorAgingHistAcroDomain.tdDebtorPercTurnOverCredLim = tqGetDraftInvoicesforDAAB.tdDebtorPercTurnOverCredLim
tqDebtorAgingHistAcroDomain.tdDebtorFixedCredLimTC = tqGetDraftInvoicesforDAAB.tdDebtorFixedCredLimTC
tqDebtorAgingHistAcroDomain.tiBusinessRelation_ID = tqGetDraftInvoicesforDAAB.tiBusinessRelation_ID
tqDebtorAgingHistAcroDomain.tcBusinessRelationCode = tqGetDraftInvoicesforDAAB.tcBusinessRelationCode
tqDebtorAgingHistAcroDomain.tcBusinessRelationName1 = tqGetDraftInvoicesforDAAB.tcBusinessRelationName1
tqDebtorAgingHistAcroDomain.tcBusinessRelationName2 = tqGetDraftInvoicesforDAAB.tcBusinessRelationName2
tqDebtorAgingHistAcroDomain.tcBusinessRelationSearchName = tqGetDraftInvoicesforDAAB.tcBusinessRelationSearchName
tqDebtorAgingHistAcroDomain.tcControlGLCode = 'PIP'
tqDebtorAgingHistAcroDomain.tcControlGLDescription = vcPIPDescription
tqDebtorAgingHistAcroDomain.tcCurrencyCode = tqGetDraftInvoicesforDAAB.tcCurrencyCode
tqDebtorAgingHistAcroDomain.tcCurrencyDescription = tqGetDraftInvoicesforDAAB.tcCurrencyDescription
tqDebtorAgingHistAcroDomain.tiCurrencyNumberOfDecimals = tqGetDraftInvoicesforDAAB.tiCurrencyNumberOfDecimals
tqDebtorAgingHistAcroDomain.tiDInvoice_ID = tqGetDraftInvoicesforDAAB.tiDDocument_ID
tqDebtorAgingHistAcroDomain.ttDInvoiceDate = tqGetDraftInvoicesforDAAB.ttDDocumentCreationDate
tqDebtorAgingHistAcroDomain.tcDInvoiceDescription = tqGetDraftInvoicesforDAAB.tcDDocumentReference
tqDebtorAgingHistAcroDomain.ttDInvoiceDueDate = tqGetDraftInvoicesforDAAB.ttDDocumentDueDate
tqDebtorAgingHistAcroDomain.tiDInvoiceReminderCount = ?
tqDebtorAgingHistAcroDomain.tcDInvoiceType = tqGetDraftInvoicesforDAAB.tcDDocumentType
tqDebtorAgingHistAcroDomain.tcJournalCode = tqGetDraftInvoicesforDAAB.tcPayFormatTypeCode
tqDebtorAgingHistAcroDomain.tiPeriodPeriod = viPostingPeriod
tqDebtorAgingHistAcroDomain.tiPeriodYear = viPostingYear
tqDebtorAgingHistAcroDomain.tiPostingVoucher = tqGetDraftInvoicesforDAAB.tiDDocumentNumber
tqDebtorAgingHistAcroDomain.tiDInvoiceVoucher = tqGetDraftInvoicesforDAAB.tiDDocumentNumber
tqDebtorAgingHistAcroDomain.tcSortByFilter2 = vcSortByNameFilter
tqDebtorAgingHistAcroDomain.tcDivisionCode = ''
tqDebtorAgingHistAcroDomain.tcDivisionDescription = ''
tqDebtorAgingHistAcroDomain.tcCostCentreDescription = ''
tqDebtorAgingHistAcroDomain.tcCostCentreCode = ''
tqDebtorAgingHistAcroDomain.tcProjectCode = ''
tqDebtorAgingHistAcroDomain.tcProjectDescription = ''
tqDebtorAgingHistAcroDomain.tdBalanceTC = vdBalanceTC
tqDebtorAgingHistAcroDomain.tdBalanceXC = vdBalanceXC * idCurrExchangeRate * idCurrExchangeRateSF
tqDebtorAgingHistAcroDomain.tdAgeingPeriod1BalanceXC = 0
tqDebtorAgingHistAcroDomain.tdAgeingPeriod2BalanceXC = 0
tqDebtorAgingHistAcroDomain.tdAgeingPeriod3BalanceXC = 0
tqDebtorAgingHistAcroDomain.tdAgeingPeriod4BalanceXC = 0
tqDebtorAgingHistAcroDomain.tdAgeingPeriod5BalanceXC = 0
tqDebtorAgingHistAcroDomain.tcCompanyCode = tqGetDraftInvoicesforDAAB.tcCompanyCode
tqDebtorAgingHistAcroDomain.tcDebtorCurrency = tqGetDraftInvoicesforDAAB.tcDebtorCurrency.
find first tAgeingPeriod where
tAgeingPeriod.ttAgeingPeriodFromDate <= vtDateForAgingCalculate and
tAgeingPeriod.ttAgeingPeriodToDate >= vtDateForAgingCalculate no-error.
if available tAgeingPeriod
then case tAgeingPeriod.tiAgeingPeriodSeq:
when 1
then assign tqDebtorAgingHistAcroDomain.tdAgeingPeriod1BalanceXC = vdBalanceXC * idCurrExchangeRate * idCurrExchangeRateSF.
when 2
then assign tqDebtorAgingHistAcroDomain.tdAgeingPeriod2BalanceXC = vdBalanceXC * idCurrExchangeRate * idCurrExchangeRateSF.
when 3
then assign tqDebtorAgingHistAcroDomain.tdAgeingPeriod3BalanceXC = vdBalanceXC * idCurrExchangeRate * idCurrExchangeRateSF.
when 4
then assign tqDebtorAgingHistAcroDomain.tdAgeingPeriod4BalanceXC = vdBalanceXC * idCurrExchangeRate * idCurrExchangeRateSF.
when 5
then assign tqDebtorAgingHistAcroDomain.tdAgeingPeriod5BalanceXC = vdBalanceXC * idCurrExchangeRate * idCurrExchangeRateSF.
end case.
end. /* if last-of (tqGetDraftInvoicesforDAAB.tiDDocument_ID) */
end. /* for each tqGetDraftInvoicesforDAAB */