Parameters
itAgingDate | input | date | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdebtorreport.p)
empty temp-table tqDebtorBillingAABMR.
<Q-74 run DebtorBillingAABMR (all) (Read) (NoCache)
(input viDRCurrentCompany_ID, (CompanyId)
input vcFromDebtorCodeFilter, (FromDebtorCode)
input vcToDebtorCodeFilter, (ToDebtorCode)
input vcCandoDebtorCodeFilter, (CandoDebtorCode)
input vcFromBRCodeFilter, (FromBRCode)
input vcToBRCodeFilter, (ToBRCode)
input vcCandoBRCodeFilter, (CandoBRCode)
input vcFromDivisionCodeFilter, (FromDivisionCode)
input vcToDivisionCodeFilter, (ToDivisionCode)
input vcCandoDivisionCodeFilter, (CandoDivisionCode)
input vcFromJournalCodeFilter, (FromJournalCode)
input vcToJournalCodeFilter, (ToJournalCode)
input vcCandoJournalCodeFilter, (CandoJournalCode)
input vcCurrencyCodeFilter, (CurrencyCode)
input itAgingDate, (AgeingDate)
input vcCandoDContrGLCodeFilter, (CanDoGLCode)
input vcFromDContrGLCodeFilter, (FromGLCode)
input vcToDContrGLCodeFilter, (ToGLCode)
input vcCanDoCostCentreCodeFilter1, (CanDoCCCode)
input vcFromCostCentreCodeFilter1, (FromCCCode)
input vcToCostCentreCodeFilter1, (ToCCCode)
input vcCandoProjectCodeFilter, (CanDoProjectCode)
input vcFromProjectCodeFilter, (FromProjectCode)
input vcToProjectCodeFilter, (ToProjectCode)
input vcDebtorTypeFilter, (DebtorTypeCode)
input viToYearPeriodFilter, (EndOfYearPeriod)
input vcSalespersonFilter, (Salesperson)
input vcPaymentGroupFilter, (PaymentGroup)
input vcDInvoiceCompanyIdList, (DInvoiceCompanyIds)
output dataset tqDebtorBillingAABMR) in BDebtorReport>
if vcDRCompanyFilter = "":U or vcDRCompanyFilter = ? then
do:
<Q-80 run SelectCompany (all) (Read) (NoCache)
(input viDRCurrentCompany_ID, (CompanyId)
output dataset tqSelectCompany) in BCompany>
for first tqSelectCompany:
vcDRCompanyFilter = tqSelectCompany.tcCompanyCode.
end.
end.
/* Main Loop: Process each Invoice */
for each tqDebtorBillingAABMR
break by tqDebtorBillingAABMR.tiDInvoice_ID:
if first-of(tqDebtorBillingAABMR.tiDInvoice_ID)
then do:
assign vlSkip = false
vdBalanceCC = 0
vdBalanceLC = 0
vdBalanceTC = 0.
/* If "Within terms = no", skip all invoices that aren't due yet */
if vlInvoicesWithinTermsFilter = false
then do :
if tqDebtorBillingAABMR.ttBillDueDate >= vtDateForAgeingCalcFilter
then assign vlSkip = true.
end. /* if vlInvoicesWithinTermsFilter = false */
end. /* if first-of(tqDebtorBillingAABMR.tiDInvoice_ID) */
if vlSkip then next.
assign vdBalanceTC = vdBalanceTC + tqDebtorBillingAABMR.tdPostingLineDebitTC - tqDebtorBillingAABMR.tdPostingLineCreditTC
vdBalanceLC = vdBalanceLC + tqDebtorBillingAABMR.tdPostingLineDebitLC - tqDebtorBillingAABMR.tdPostingLineCreditLC
vdBalanceCC = vdBalanceCC + tqDebtorBillingAABMR.tdPostingLineDebitCC - tqDebtorBillingAABMR.tdPostingLineCreditCC.
if last-of(tqDebtorBillingAABMR.tiDInvoice_ID)
then do:
assign vdOriginal1CC = tqDebtorBillingAABMR.tdDInvoiceOriginalDebitCC - tqDebtorBillingAABMR.tdDInvoiceOriginalCreditCC
vdOriginal1LC = tqDebtorBillingAABMR.tdDInvoiceOriginalDebitLC - tqDebtorBillingAABMR.tdDInvoiceOriginalCreditLC
vdOriginal1TC = tqDebtorBillingAABMR.tdDInvoiceOriginalDebitTC - tqDebtorBillingAABMR.tdDInvoiceOriginalCreditTC.
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.
/* tcrDebtorBillingAAB */
create tqDebtorBillingAAB.
buffer-copy tqDebtorBillingAABMR to tqDebtorBillingAAB.
assign tqDebtorBillingAAB.tcControlGLCode = tqDebtorBillingAABMR.tcGLCode
tqDebtorBillingAAB.tcControlGLDescription = tqDebtorBillingAABMR.tcGLDescription
tqDebtorBillingAAB.tdBalanceXC = vdBalanceXC
tqDebtorBillingAAB.tdBalanceTC = vdBalanceTC
tqDebtorBillingAAB.tcDiscountType = "Y":U
tqDebtorBillingAAB.tdAgeingPeriod1BalanceXC = 0
tqDebtorBillingAAB.tdAgeingPeriod2BalanceXC = 0
tqDebtorBillingAAB.tdAgeingPeriod3BalanceXC = 0
tqDebtorBillingAAB.tdAgeingPeriod4BalanceXC = 0
tqDebtorBillingAAB.tdAgeingPeriod5BalanceXC = 0
tqDebtorBillingAAB.ttDInvoiceDueDate = tqDebtorBillingAABMR.ttBillDueDate
tqDebtorBillingAAB.tcBillCompanyCode = vcDRCompanyFilter
tqDebtorBillingAAB.tcBillGroup = "Bill":U
tqDebtorBillingAAB.tcBillSortKey = string(tqDebtorBillingAAB.tiBillYear) + string(tqDebtorBillingAAB.tiBillNumber, ">>>>>>>>9":U).
find first tAgeingPeriod where
tAgeingPeriod.ttAgeingPeriodFromDate <= tqDebtorBillingAAB.ttBillDueDate and
tAgeingPeriod.ttAgeingPeriodToDate >= tqDebtorBillingAAB.ttBillDueDate
no-error.
if available tAgeingPeriod
then case tAgeingPeriod.tiAgeingPeriodSeq:
when 1
then assign tqDebtorBillingAAB.tdAgeingPeriod1BalanceXC = vdBalanceXC.
when 2
then assign tqDebtorBillingAAB.tdAgeingPeriod2BalanceXC = vdBalanceXC.
when 3
then assign tqDebtorBillingAAB.tdAgeingPeriod3BalanceXC = vdBalanceXC.
when 4
then assign tqDebtorBillingAAB.tdAgeingPeriod4BalanceXC = vdBalanceXC.
when 5
then assign tqDebtorBillingAAB.tdAgeingPeriod5BalanceXC = vdBalanceXC.
end case.
end. /* if last-of(tqDebtorBillingAAB.tiDInvoice_ID) */
end. /* for each tqDebtorBillingAAB */