Description
This method is called by the two report methods CreditorAgeingAnalysisByProj and DebtorAgeingAnalysisByProj. Since the report methods are not used, this method is also obsolete.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bprojectreport.p)
/*create 6 Ageing periods
period 0 = (AgeingDate, 01/01/9999) only used for "Within Terms = Yes"
period 1 = ((calc), AgeingDate>,
period 2, 3 (calc, calc)
period 4 (calc, calc) if "Within Terms = No"
period 4 (calc, calc) if "Within Terms = No"
period 5 (01/01/0001, calc)*/
assign viSeqMax = 5
viSeqMin = 1.
if vtDateForAgeingCalcFilter2 = ?
then assign vtDateForAgeingCalcFilter2 = today.
/*Create the first period 'manualy' if "Within Terms = Yes"*/
if vlInvoiceWithinTermsFilter
then do:
create tAgeingPeriod2.
assign tAgeingPeriod2.tiAgeingPeriodSeq = 1
tAgeingPeriod2.ttAgeingPeriodFromDate = vtDateForAgeingCalcFilter2 + 1
tAgeingPeriod2.ttAgeingPeriodToDate = vtDateMax
viSeqMin = 2.
end.
/*initial data*/
assign vtToDate = vtDateForAgeingCalcFilter2
viOffset = abs(viAgeingOffsetFilter2)
viDay = day (vtToDate)
viMonth = month (vtToDate)
viYear = year (vtToDate).
/*calculate 'ToDate' of the next period; 'FromDate' of the current period is 'ToDate' + 1*/
do viSeq = viSeqMin to viSeqMax:
create tAgeingPeriod2.
assign tAgeingPeriod2.tiAgeingPeriodSeq = viSeq.
tAgeingPeriod2.ttAgeingPeriodToDate = vtToDate.
case vcAgeingTypeFilter2:
/*Calculate 'ToDate' of the next period for Ageing of type 'DAYS'*/
when {&AGEINGTYPE-DAYS}
then assign vtToDate = tAgeingPeriod2.ttAgeingPeriodToDate - viOffset.
/*Calculate 'ToDate' of the next period for Ageing of type 'MONTHS'*/
when {&AGEINGTYPE-MONTHS}
then do:
/*calculate month and year*/
assign viIndex = 0.
do while viIndex < viOffset:
assign viIndex = viIndex + 1
viMonth = viMonth - 1.
if viMonth = 0
then assign viMonth = 12
viYear = viYear - 1.
end.
assign vtToDate = date (viMonth, viDay, viYear) no-error.
if error-status:error then assign vtToDate = ?.
/*adjust day;
in some cases ToDate might be invalid e.g. 30/02 or 31/04 etc.
therefor I decrease the valus of viDay and it results in the following situation:
if the day of 'ToDate' of the first period is 31 then
the 'ToDate' of second period will be 30 for April, June, September, November and
28 (or 29) for February;
viIndex < 5 just to be sure that it will not be an endless loop*/
assign viIndex = 0.
do while (vtToDate = ? and viIndex < 5):
assign viIndex = viIndex + 1
viDay = viDay - 1
vtToDate = date (viMonth, viDay, viYear) no-error.
if error-status:error then assign vtToDate = ?.
end.
end.
end case.
assign tAgeingPeriod2.ttAgeingPeriodFromDate = if viSeq = viSeqMax then vtDateMin else vtToDate + 1.
end.