Add blank column, rename column.
[capital-apms-progress.git] / process / report / sydney-wall.p
blobc8d1219c510dc0ba1c73d7a04dfd94fc1803bc43
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Report:
6 Author:
7 Date:
8 ------------------------------------------------------------------------*/
10 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
12 DEF VAR preview AS LOGI NO-UNDO INIT No.
13 DEF VAR show-vacancies AS LOGI NO-UNDO INIT No.
14 DEF VAR max-remaining-life AS DEC NO-UNDO INITIAL 999.9 .
15 DEF VAR property-1 AS INT NO-UNDO INIT 0.
16 DEF VAR property-n AS INT NO-UNDO INIT 99999.
17 DEF VAR selection-style AS CHAR NO-UNDO.
18 DEF VAR test-client-code AS CHAR NO-UNDO INITIAL ?.
19 DEF VAR company-list AS CHAR NO-UNDO INITIAL ?.
20 DEF VAR property-code AS INT NO-UNDO.
21 DEF VAR property-name AS CHAR NO-UNDO.
22 RUN parse-parameters.
25 DEF VAR user-name AS CHAR NO-UNDO.
26 {inc/username.i "user-name"}
27 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
28 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
30 DEF VAR pr-line AS CHAR INIT "" NO-UNDO. /* used everywhere to hold print line */
32 DEF VAR title-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
33 DEF VAR time-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
34 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
35 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
36 DEF VAR base-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,bold".
38 {inc/ofc-this.i}
39 {inc/ofc-set.i "Statutory-Expense-Accounts" "stat-accounts"}
40 {inc/ofc-set-l.i "Use-Rent-Charges" "use-rent-charges"}
41 {inc/ofc-set.i "Schedule-AGP-Agent-Excludes" "agent-exclude-types"}
43 {inc/ofc-set.i "RentCharge-Outgoings" "og-method"}
44 IF NOT AVAILABLE(OfficeSetting) THEN og-method = "".
45 {inc/ofc-set-l.i "RentCharge-OG-By-Lease" "charge-og-lease"}
46 IF NOT AVAILABLE(OfficeSetting) THEN charge-og-lease = Yes.
47 /* IF NOT charge-og-lease THEN og-method = "". */
49 /* _UIB-CODE-BLOCK-END */
50 &ANALYZE-RESUME
53 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
55 /* ******************** Preprocessor Definitions ******************** */
57 &Scoped-define PROCEDURE-TYPE Procedure
58 &Scoped-define DB-AWARE no
62 /* _UIB-PREPROCESSOR-BLOCK-END */
63 &ANALYZE-RESUME
66 /* ************************ Function Prototypes ********************** */
68 &IF DEFINED(EXCLUDE-to-annual) = 0 &THEN
70 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD to-annual Procedure
71 FUNCTION to-annual RETURNS DECIMAL
72 ( INPUT freq-type AS CHAR, INPUT period-amount AS DEC ) FORWARD.
74 /* _UIB-CODE-BLOCK-END */
75 &ANALYZE-RESUME
77 &ENDIF
80 /* *********************** Procedure Settings ************************ */
82 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
83 /* Settings for THIS-PROCEDURE
84 Type: Procedure
85 Allow:
86 Frames: 0
87 Add Fields to: Neither
88 Other Settings: CODE-ONLY COMPILE
90 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
92 /* ************************* Create Window ************************** */
94 &ANALYZE-SUSPEND _CREATE-WINDOW
95 /* DESIGN Window definition (used by the UIB)
96 CREATE WINDOW Procedure ASSIGN
97 HEIGHT = 15.95
98 WIDTH = 32.57.
99 /* END WINDOW DEFINITION */
101 &ANALYZE-RESUME
103 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
104 /* ************************* Included-Libraries *********************** */
106 {inc/method/m-txtrep.i}
107 {inc/method/m-lease-rentals.i}
109 /* _UIB-CODE-BLOCK-END */
110 &ANALYZE-RESUME
116 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
119 /* *************************** Main Block *************************** */
121 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
123 RUN pclrep-start( preview, "reset,landscape,tm,4,a4,lm,15,courier,cpi,18,lpi,9").
125 IF selection-style = "OneClient" THEN RUN for-one-client.
126 ELSE IF selection-style = "CompanyList" THEN RUN for-company-list.
127 ELSE
128 RUN for-each-property.
130 OUTPUT CLOSE.
132 RUN pclrep-finish.
134 /* _UIB-CODE-BLOCK-END */
135 &ANALYZE-RESUME
138 /* ********************** Internal Procedures *********************** */
140 &IF DEFINED(EXCLUDE-each-property) = 0 &THEN
142 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
143 PROCEDURE each-property :
144 /*------------------------------------------------------------------------------
145 Purpose:
146 Parameters: <none>
147 Notes:
148 ------------------------------------------------------------------------------*/
149 DEF VAR SumArea AS DECIMAL NO-UNDO INITIAL 0.
150 DEF VAR SumRent AS DECIMAL NO-UNDO INITIAL 0.
151 DEF VAR SumRemainArea AS DECIMAL NO-UNDO INITIAL 0.
152 DEF VAR SumRemainRent AS DECIMAL NO-UNDO INITIAL 0.
154 DEF VAR WALL-Rent AS DECIMAL NO-UNDO.
155 DEF VAR WALL-Area AS DECIMAL NO-UNDO.
157 property-code = Property.PropertyCode.
158 property-name = Property.Name.
159 RUN build-lease-rentals.
161 FOR EACH TenancyLease OF Property NO-LOCK WHERE TenancyLease.LeaseStatus <> "PAST",
162 FIRST RentalSpace OF TenancyLease NO-LOCK
163 WHERE RentalSpace.AreaStatus <> "V" /* vacant */
164 AND RentalSpace.AreaStatus <> "C" /* common */
165 BY RentalSpace.Level BY RentalSpace.LevelSequence:
166 RUN wall-each-lease( INPUT-OUTPUT SumArea, INPUT-OUTPUT SumRent,
167 INPUT-OUTPUT SumRemainArea, INPUT-OUTPUT SumRemainRent).
168 END.
170 RUN wall-vacant-space( INPUT-OUTPUT SumArea, INPUT-OUTPUT SumRent,
171 INPUT-OUTPUT SumRemainArea, INPUT-OUTPUT SumRemainRent).
173 ASSIGN WALL-Rent = SumRemainRent / SumRent
174 WALL-Area = SumRemainArea / SumArea
175 NO-ERROR.
177 pr-line = FILL(" ",50) + FILL( " " + FILL("=",13), 2).
178 RUN pclrep-line( base-font, pr-line ).
180 pr-line = STRING( Property.Name, "X(50)")
181 + STRING( SumArea, "->>,>>>,>>9.99")
182 + STRING( SumRent, "->>,>>>,>>9.99")
183 + FILL(" ",21)
184 + (IF WALL-Area = ? THEN FILL(" ", 14) ELSE STRING( WALL-Area, "->>>>>9.99 yrs"))
185 + (IF WALL-Rent = ? THEN "" ELSE STRING( WALL-Rent, "->>>>>9.99 yrs")).
186 RUN pclrep-line( base-font, pr-line ).
187 RUN pclrep-page-break.
189 END PROCEDURE.
191 /* _UIB-CODE-BLOCK-END */
192 &ANALYZE-RESUME
194 &ENDIF
196 &IF DEFINED(EXCLUDE-for-company-list) = 0 &THEN
198 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-company-list Procedure
199 PROCEDURE for-company-list :
200 /*------------------------------------------------------------------------------
201 Purpose:
202 ------------------------------------------------------------------------------*/
203 DEF VAR i AS INT NO-UNDO.
204 DEF VAR n AS INT NO-UNDO.
205 DEF VAR company-code AS INT NO-UNDO.
207 FIND ConsolidationList WHERE ConsolidationList.Name = company-list NO-LOCK.
208 n = NUM-ENTRIES( ConsolidationList.CompanyList ).
209 DO i = 1 TO n:
210 company-code = INT( ENTRY( i, ConsolidationList.CompanyList ) ).
211 FOR EACH Property WHERE Property.CompanyCode = company-code
212 AND Property.Active NO-LOCK:
213 RUN each-property.
214 END.
215 END.
217 END PROCEDURE.
219 /* _UIB-CODE-BLOCK-END */
220 &ANALYZE-RESUME
222 &ENDIF
224 &IF DEFINED(EXCLUDE-for-each-property) = 0 &THEN
226 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-property Procedure
227 PROCEDURE for-each-property :
228 /*------------------------------------------------------------------------------
229 Purpose:
230 ------------------------------------------------------------------------------*/
232 FOR EACH Property WHERE Property.PropertyCode >= property-1
233 AND Property.PropertyCode <= property-n
234 AND Property.Active NO-LOCK:
235 RUN each-property.
236 END.
238 END PROCEDURE.
240 /* _UIB-CODE-BLOCK-END */
241 &ANALYZE-RESUME
243 &ENDIF
245 &IF DEFINED(EXCLUDE-for-one-client) = 0 &THEN
247 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-one-client Procedure
248 PROCEDURE for-one-client :
249 /*------------------------------------------------------------------------------
250 Purpose:
251 ------------------------------------------------------------------------------*/
253 FOR EACH Company WHERE Company.ClientCode = test-client-code NO-LOCK:
254 FOR EACH Property OF Company WHERE Property.Active NO-LOCK:
255 RUN each-property.
256 END.
257 END.
260 END PROCEDURE.
262 /* _UIB-CODE-BLOCK-END */
263 &ANALYZE-RESUME
265 &ENDIF
267 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
269 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
270 PROCEDURE inst-page-footer :
271 /*------------------------------------------------------------------------------
272 Purpose: Print any page footer
273 ------------------------------------------------------------------------------*/
275 END PROCEDURE.
277 /* _UIB-CODE-BLOCK-END */
278 &ANALYZE-RESUME
280 &ENDIF
282 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
284 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
285 PROCEDURE inst-page-header :
286 /*------------------------------------------------------------------------------
287 Purpose: Print any page header
288 ------------------------------------------------------------------------------*/
290 RUN pclrep-line( "univers,Point,6,bold,Proportional", TimeStamp).
291 RUN pclrep-line( "", "" ).
292 RUN pclrep-line( "univers,Point,12,bold,Proportional",
293 "Weighted Average Lease Life - "
294 + property-name + " (P" + STRING(property-code) + ")").
296 RUN pclrep-down-by( 2 ).
297 pr-line = FILL(" ", 90) + " Unexpired ".
298 RUN pclrep-line( base-font, pr-line ).
299 pr-line = STRING("Lessee", "X(60)")
300 + "Area Rental Value Expiry Lease life by Area by Rental".
301 RUN pclrep-line( base-font + ",bold", pr-line ).
302 RUN pclrep-down-by(1).
304 END PROCEDURE.
306 /* _UIB-CODE-BLOCK-END */
307 &ANALYZE-RESUME
309 &ENDIF
311 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
313 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
314 PROCEDURE parse-parameters :
315 /*------------------------------------------------------------------------------
316 Purpose:
317 ------------------------------------------------------------------------------*/
318 DEF VAR token AS CHAR NO-UNDO.
319 DEF VAR i AS INT NO-UNDO.
321 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
322 token = ENTRY( i, report-options, "~n" ).
324 CASE ENTRY( 1, token ):
325 WHEN "Preview" THEN preview = Yes.
326 WHEN "MaxLife" THEN max-remaining-life = INT(ENTRY(2,token)).
327 WHEN "Client" THEN test-client-code = ENTRY(2,token).
328 WHEN "CompanyList" THEN company-list = ENTRY(2,token).
329 WHEN "Selection" THEN selection-style = ENTRY(2,token).
330 WHEN "ShowVacancies" THEN show-vacancies = Yes.
331 WHEN "Properties" THEN ASSIGN
332 property-1 = INT( ENTRY(2,token) )
333 property-n = INT( ENTRY(3,token) ).
334 END CASE.
336 END.
337 IF max-remaining-life < 1 THEN max-remaining-life = 999.
339 END PROCEDURE.
341 /* _UIB-CODE-BLOCK-END */
342 &ANALYZE-RESUME
344 &ENDIF
346 &IF DEFINED(EXCLUDE-test-floor-space) = 0 &THEN
348 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE test-floor-space Procedure
349 PROCEDURE test-floor-space :
350 /*------------------------------------------------------------------------------
351 Purpose: Decide if this is actual floor space
352 ------------------------------------------------------------------------------*/
353 DEF INPUT PARAMETER type AS CHAR NO-UNDO.
354 DEF INPUT PARAMETER area AS DECIMAL NO-UNDO.
356 DEF BUFFER LocAreaType FOR AreaType.
358 IF area = ? THEN RETURN "No".
359 FIND LocAreaType WHERE LocAreaType.AreaType = type NO-LOCK NO-ERROR.
360 IF AVAILABLE(LocAreaType) THEN DO:
361 IF LocAreaType.IsCarPark THEN RETURN "Park".
362 IF LocAreaType.IsFloorArea THEN RETURN "Yes".
363 RETURN "No".
364 END.
366 CASE type:
367 WHEN "C" THEN RETURN "Park".
368 WHEN "O" THEN RETURN "Yes".
369 WHEN "R" THEN RETURN "Yes".
370 WHEN "W" THEN RETURN "Yes".
371 WHEN "N" THEN RETURN "No".
372 /* OTHERWISE
373 IF area > 10 OR (area <> INTEGER(area)) THEN RETURN "Yes". */
374 END CASE.
376 RETURN "No".
378 END PROCEDURE.
380 /* _UIB-CODE-BLOCK-END */
381 &ANALYZE-RESUME
383 &ENDIF
385 &IF DEFINED(EXCLUDE-wall-each-lease) = 0 &THEN
387 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE wall-each-lease Procedure
388 PROCEDURE wall-each-lease :
389 /*------------------------------------------------------------------------------
390 Purpose:
391 ------------------------------------------------------------------------------*/
392 DEF INPUT-OUTPUT PARAMETER SumArea AS DECIMAL NO-UNDO.
393 DEF INPUT-OUTPUT PARAMETER SumRent AS DECIMAL NO-UNDO.
394 DEF INPUT-OUTPUT PARAMETER SumRemainArea AS DECIMAL NO-UNDO.
395 DEF INPUT-OUTPUT PARAMETER SumRemainRent AS DECIMAL NO-UNDO.
397 &SCOP RENT-FIGURE ChargedRental
399 DEF VAR UnexpiredLife AS DECIMAL NO-UNDO INITIAL 0.
400 DEF VAR dispLeaseExpiry AS CHAR NO-UNDO INITIAL "".
401 DEF VAR LeaseRent AS DECIMAL NO-UNDO INITIAL 0.
402 DEF VAR LeaseArea AS DECIMAL NO-UNDO INITIAL 0.
403 DEF VAR RemainRent AS DECIMAL NO-UNDO INITIAL 0.
404 DEF VAR RemainArea AS DECIMAL NO-UNDO INITIAL 0.
405 DEF VAR area-size AS DECIMAL NO-UNDO INITIAL 0.
406 DEF VAR area-rent AS DECIMAL NO-UNDO INITIAL 0.
408 DEF BUFFER RSP FOR RentalSpace.
410 UnexpiredLife = TenancyLease.LeaseEndDate - TODAY.
411 IF UnexpiredLife = ? OR UnexpiredLife < 30.4375 THEN UnexpiredLife = 30.4375.
412 IF UnexpiredLife > (max-remaining-life * 365.25) THEN UnexpiredLife = (max-remaining-life * 365.25).
413 UnexpiredLife = UnexpiredLife / 365.25.
414 FIND Tenant OF TenancyLease NO-LOCK NO-ERROR.
416 LeaseRent = TenancyLease.OutgoingsBudget.
417 IF LeaseRent = ? THEN LeaseRent = 0.
418 FOR EACH RSP OF TenancyLease NO-LOCK
419 WHERE RSP.AreaStatus <> "V" /* vacant */
420 AND RSP.AreaStatus <> "C" /* common */
421 BY RSP.Level BY RSP.LevelSequence:
423 RUN test-floor-space( RSP.AreaType, RSP.AreaSize).
424 area-rent = get-area-rental( RSP.PropertyCode, RSP.RentalSpaceCode ).
425 IF RETURN-VALUE = "Yes" THEN
426 LeaseArea = LeaseArea + RSP.AreaSize.
428 LeaseRent = LeaseRent + area-rent .
429 END.
431 ASSIGN RemainRent = LeaseRent * UnexpiredLife
432 RemainArea = LeaseArea * UnexpiredLife.
434 IF RemainRent <> 0 OR RemainArea <> 0 THEN DO:
435 dispLeaseExpiry = IF UnexpiredLife <= (31 / 365.25) THEN " Monthly "
436 ELSE STRING( TenancyLease.LeaseEndDate, "99/99/9999").
438 pr-line = STRING( Tenant.Name, "X(50)")
439 + STRING( LeaseArea, "->>,>>>,>>9.99")
440 + STRING( LeaseRent, "->>,>>>,>>9.99")
441 + " " + dispLeaseExpiry
442 + STRING( UnexpiredLife, "->,>>9.99")
443 + STRING( RemainArea, "->>,>>>,>>9.99")
444 + STRING( RemainRent, "->>,>>>,>>9.99").
445 RUN pclrep-line( base-font, pr-line ).
447 ASSIGN SumArea = SumArea + LeaseArea
448 SumRent = SumRent + LeaseRent
449 SumRemainArea = SumRemainArea + RemainArea
450 SumRemainRent = SumRemainRent + RemainRent.
451 END.
454 END PROCEDURE.
456 /* _UIB-CODE-BLOCK-END */
457 &ANALYZE-RESUME
459 &ENDIF
461 &IF DEFINED(EXCLUDE-wall-vacant-space) = 0 &THEN
463 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE wall-vacant-space Procedure
464 PROCEDURE wall-vacant-space :
465 /*------------------------------------------------------------------------------
466 Purpose:
467 ------------------------------------------------------------------------------*/
468 DEF INPUT-OUTPUT PARAMETER SumArea AS DECIMAL NO-UNDO.
469 DEF INPUT-OUTPUT PARAMETER SumRent AS DECIMAL NO-UNDO.
470 DEF INPUT-OUTPUT PARAMETER SumRemainArea AS DECIMAL NO-UNDO.
471 DEF INPUT-OUTPUT PARAMETER SumRemainRent AS DECIMAL NO-UNDO.
473 &SCOP RENT-FIGURE ChargedRental
475 DEF VAR UnexpiredLife AS DECIMAL NO-UNDO INITIAL 0.
476 DEF VAR VacantRent AS DECIMAL NO-UNDO INITIAL 0.
477 DEF VAR VacantArea AS DECIMAL NO-UNDO INITIAL 0.
478 DEF VAR RemainRent AS DECIMAL NO-UNDO INITIAL 0.
479 DEF VAR RemainArea AS DECIMAL NO-UNDO INITIAL 0.
480 DEF VAR area-size AS DECIMAL NO-UNDO INITIAL 0.
482 DEF BUFFER RSP FOR RentalSpace.
484 FOR EACH RSP OF Property NO-LOCK
485 WHERE RSP.AreaStatus = "V" /* vacant */
486 OR RSP.AreaStatus = "C" /* common */
487 BY RSP.Level BY RSP.LevelSequence:
488 RUN test-floor-space( RSP.AreaType, RSP.AreaSize).
489 IF RETURN-VALUE = "Yes" THEN
490 VacantArea = VacantArea + RSP.AreaSize.
492 END.
494 ASSIGN RemainRent = 0
495 RemainArea = 0.
497 IF VacantArea > 0 THEN DO:
498 pr-line = STRING( "Vacant and Common Areas", "X(50)")
499 + STRING( VacantArea, "->>,>>>,>>9.99")
500 + STRING( VacantRent, "->>,>>>,>>9.99")
501 + " " + " Vacant "
502 + STRING( UnexpiredLife, "->,>>9.99")
503 + STRING( RemainArea, "->>,>>>,>>9.99")
504 + STRING( RemainRent, "->>,>>>,>>9.99").
505 RUN pclrep-line( base-font, pr-line ).
506 END.
508 ASSIGN SumArea = SumArea + VacantArea
509 SumRent = SumRent + VacantRent
510 SumRemainArea = SumRemainArea + RemainArea
511 SumRemainRent = SumRemainRent + RemainRent.
514 END PROCEDURE.
516 /* _UIB-CODE-BLOCK-END */
517 &ANALYZE-RESUME
519 &ENDIF
521 /* ************************ Function Implementations ***************** */
523 &IF DEFINED(EXCLUDE-to-annual) = 0 &THEN
525 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION to-annual Procedure
526 FUNCTION to-annual RETURNS DECIMAL
527 ( INPUT freq-type AS CHAR, INPUT period-amount AS DEC ) :
528 /*------------------------------------------------------------------------------
529 Purpose: Return an annualised conversion of the amount.
530 Notes:
531 ------------------------------------------------------------------------------*/
532 DEF VAR annual-amount AS DEC NO-UNDO.
534 FIND FrequencyType WHERE FrequencyType.FrequencyCode = freq-type NO-LOCK.
536 annual-amount = ((period-amount / FrequencyType.UnitCount) * (IF FrequencyType.RepeatUnits = "D" THEN 365 ELSE 12)).
538 RETURN annual-amount.
540 END FUNCTION.
542 /* _UIB-CODE-BLOCK-END */
543 &ANALYZE-RESUME
545 &ENDIF