Add blank column, rename column.
[capital-apms-progress.git] / process / report / portfolio-expiry.p
blob800ed095320e302899fb0e32492d0732551b6d29
1 DEF TEMP-TABLE Expiring NO-UNDO
2 FIELD PropertyCode LIKE Property.PropertyCode
3 FIELD ExpiringOn LIKE TenancyLease.LeaseEndDate
4 FIELD ValueExpiring LIKE RentalSpace.ContractedRental
5 FIELD AreaExpiring LIKE RentalSpace.AreaSize
6 INDEX XPKExpiries IS PRIMARY PropertyCode ExpiringOn.
8 DEF VAR end-date AS DATE NO-UNDO.
9 DEF VAR month-name AS CHAR NO-UNDO FORMAT "X(7)" LABEL " Month ".
10 DEF VAR month-value AS DEC NO-UNDO FORMAT "->>,>>>,>>>,>>9" LABEL " Value".
11 DEF VAR month-area AS DEC NO-UNDO FORMAT "->>,>>>,>>9" LABEL " Area".
13 FOR EACH Property WHERE Property.Active:
14 FOR EACH TenancyLease OF Property WHERE TenancyLease.LeaseStatus <> "PAST"
15 NO-LOCK BY TenancyLease.LeaseEndDate :
16 FIND Expiring WHERE Expiring.PropertyCode = Property.PropertyCode
17 AND Expiring.ExpiringOn = TenancyLease.LeaseEndDate
18 NO-ERROR.
19 end-date = TenancyLease.LeaseEndDate.
20 IF end-date < TODAY THEN end-date = ?.
21 IF NOT AVAILABLE(Expiring) THEN DO:
22 CREATE Expiring.
23 Expiring.PropertyCode = Property.PropertyCode.
24 Expiring.ExpiringOn = TenancyLease.LeaseEndDate.
25 END.
26 FOR EACH RentalSpace OF TenancyLease NO-LOCK:
27 Expiring.ValueExpiring = Expiring.ValueExpiring + RentalSpace.ContractedRental .
28 IF INDEX( "CIORW", RentalSpace.AreaType) > 0 THEN
29 Expiring.AreaExpiring = Expiring.AreaExpiring + RentalSpace.AreaSize .
30 END.
31 END.
32 END.
34 DEFINE FRAME x WITH DOWN.
36 FOR EACH Property WHERE Property.Active:
37 FIND Expiring WHERE Expiring.PropertyCode = Property.PropertyCode NO-LOCK NO-ERROR.
38 IF AVAILABLE(Expiring) THEN DO:
39 DISPLAY Property.PropertyCode
40 "Monthly" @ month-name
41 Expiring.AreaExpiring @ month-area
42 Expiring.ValueExpiring @ month-value
43 WITH FRAME x .
44 DOWN WITH FRAME x.
45 END.
46 FOR EACH Month NO-LOCK WHERE CAN-FIND( FIRST Expiring OF Property
47 WHERE Expiring.ExpiringOn >= Month.StartDate
48 AND Expiring.ExpiringOn <= Month.EndDate) :
49 month-name = Month.MonthName + " " + SUBSTRING( STRING( YEAR(Month.StartDate), "9999"), 3).
50 month-area = 0.
51 month-value = 0.
52 FOR EACH Expiring OF Property WHERE Expiring.ExpiringOn >= Month.StartDate
53 AND Expiring.ExpiringOn <= Month.EndDate:
54 month-area = month-area + Expiring.AreaExpiring.
55 month-value = month-value + Expiring.ValueExpiring.
56 END.
57 DISPLAY Property.PropertyCode month-name month-area month-value WITH FRAME x .
58 DOWN WITH FRAME x.
59 END.
60 END.