Add blank column, rename column.
[capital-apms-progress.git] / process / report / schdagnt.p
blobe0a4848f7f1ec36792cad1862e7649a7043ba028
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
6 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
7 DEF INPUT PARAMETER preview AS LOGICAL NO-UNDO.
8 DEF INPUT PARAMETER property-1 AS INTEGER NO-UNDO.
9 DEF INPUT PARAMETER property-2 AS INTEGER NO-UNDO.
11 /* Operational Control */
14 /* for accumulating outgoing details over a property */
15 DEF WORK-TABLE bldg-sublease NO-UNDO LIKE SubLease.
16 DEF WORK-TABLE og-acct NO-UNDO
17 FIELD AccountCode LIKE ChartOfAccount.AccountCode
18 FIELD ShortName AS CHAR FORMAT "X(9)"
19 FIELD Recovered AS DECIMAL
20 FIELD Gross AS DECIMAL
21 FIELD Vacant AS DECIMAL.
22 DEFINE WORKFILE og-desc NO-UNDO
23 FIELD percent AS DEC
24 FIELD accounts AS CHAR
25 FIELD description AS CHAR
26 FIELD count AS INT.
28 /* page control */
29 DEF VAR prt-ctrl AS CHAR NO-UNDO.
30 DEF VAR cols AS INT NO-UNDO.
31 DEF VAR rows AS INT NO-UNDO.
32 DEF VAR first-building AS LOGICAL INITIAL yes NO-UNDO.
33 DEF VAR user-name AS CHAR NO-UNDO.
34 {inc/username.i "user-name"}
36 /* page header */
37 &SCOPED-DEFINE page-width 205
38 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
40 DEF VAR timeStamp AS CHAR FORMAT "X(40)" NO-UNDO.
41 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
42 DEF VAR hline2 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
43 DEF VAR hline3 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
44 DEF VAR hline4 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
45 DEF VAR col-head1-base AS CHAR FORMAT "X({&page-width})" NO-UNDO.
46 DEF VAR col-head2-base AS CHAR FORMAT "X({&page-width})" NO-UNDO.
47 DEF VAR col-head1 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
48 DEF VAR col-head2 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
49 DEF VAR u-line AS CHAR NO-UNDO.
50 u-line = FILL("-",{&page-width}).
51 DEF VAR e-line AS CHAR NO-UNDO.
52 e-line = FILL("=",{&page-width}).
53 &GLOB VERT-POS 88
54 /* SUBSTRING(u-line,{&VERT-POS}) = "+". */
55 DEFINE FRAME heading-frame WITH 1 DOWN {&with-clause} PAGE-TOP.
56 FORM HEADER
57 timeStamp "Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
58 hline2 SKIP hline3 SKIP (1) hline4 SKIP (1)
59 col-head1 SKIP col-head2 SKIP (1) u-line FORMAT "X({&page-width})"
60 WITH FRAME heading-frame.
62 col-head1-base = "Rental Space | Tenant Lease | | |Renew rights | Rent Reviews | Outgoings".
63 col-head2-base = "Description Area Rate Contracted Charged | Name | %age Outgoing | Term | Expires |Notice Term |Status Notice Date | Contributions".
65 /* Formats */
66 DEF VAR area-format AS CHAR NO-UNDO.
67 DEF VAR unit-format AS CHAR NO-UNDO.
68 DEF VAR money-format AS CHAR NO-UNDO.
69 area-format = "->>>,>>9.99".
70 unit-format = "->>>,>>9".
71 money-format = "->>,>>>,>>9.99".
73 &GLOB FIELD-COUNT 20
74 DEF VAR f AS CHAR EXTENT {&FIELD-COUNT} NO-UNDO. /* an array of the fields we will print */
75 DEF VAR f-fmt AS CHAR EXTENT {&FIELD-COUNT} NO-UNDO.
76 ASSIGN
77 f-fmt[1] = "X(24)" f-fmt[2] = "X(16)" /* description, units */
78 f-fmt[3] = "X(14)" f-fmt[4] = "X(14)" /* rate, contracted */
79 f-fmt[5] = "X(14)" f-fmt[6] = "X(1)" /* charged, filler */
80 f-fmt[7] = "X(24)" f-fmt[8] = "X(8)" /* name, og percent */
81 f-fmt[9] = "X(12)" f-fmt[10] = "X(8)" /* og-desc, term */
82 f-fmt[11] = "X(10)" f-fmt[12] = "X(4)" /* expiry, renew notice */
83 f-fmt[13] = "X(8)" f-fmt[14] = "X(4)" /* renew term, rr freq */
84 f-fmt[15] = "X(4)" f-fmt[16] = "X(10)" /* rr notice, rr due */
85 f-fmt[17] = "X(13)" f-fmt[18] = "X(8)" /* og contrib */
86 f-fmt[19] = "X(8)" f-fmt[20] = "X(8)"
89 /* Accumulators */
90 DEF VAR level-lines AS INT NO-UNDO.
91 DEF VAR level-area AS DECIMAL NO-UNDO.
92 DEF VAR level-parks AS DECIMAL NO-UNDO.
93 DEF VAR level-contract AS DECIMAL NO-UNDO.
94 DEF VAR level-charged AS DECIMAL NO-UNDO.
96 DEF VAR bldg-area AS DECIMAL NO-UNDO.
97 DEF VAR bldg-contract AS DECIMAL NO-UNDO.
98 DEF VAR bldg-charged AS DECIMAL NO-UNDO.
99 DEF VAR total-break AS INTEGER NO-UNDO.
101 DEF VAR grand-area AS DECIMAL NO-UNDO.
102 DEF VAR grand-contract AS DECIMAL NO-UNDO.
103 DEF VAR grand-charged AS DECIMAL NO-UNDO.
105 DEF VAR space-notes AS CHAR NO-UNDO.
106 DEF VAR lease-notes AS CHAR NO-UNDO.
107 DEF VAR various-notes AS CHAR NO-UNDO.
108 DEF VAR bldg-notes AS CHAR NO-UNDO.
109 DEF VAR notes-list AS CHAR NO-UNDO.
110 DEF VAR rs-notes AS CHAR NO-UNDO.
111 DEF VAR rs-codes AS CHAR NO-UNDO.
112 DEF VAR tl-notes AS CHAR NO-UNDO.
113 DEF VAR tl-codes AS CHAR NO-UNDO.
115 DEF VAR lease-list AS CHAR NO-UNDO.
116 DEF VAR first-appearance AS LOGICAL NO-UNDO.
118 DEF VAR out-line AS CHAR NO-UNDO.
120 /* _UIB-CODE-BLOCK-END */
121 &ANALYZE-RESUME
124 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
126 /* ******************** Preprocessor Definitions ******************** */
128 &Scoped-define PROCEDURE-TYPE Procedure
132 /* _UIB-PREPROCESSOR-BLOCK-END */
133 &ANALYZE-RESUME
136 /* ************************ Function Prototypes ********************** */
138 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-prop-og Procedure
139 FUNCTION get-prop-og RETURNS DECIMAL
140 ( INPUT doit AS LOGICAL, INPUT pc AS INTEGER, INPUT ac AS DECIMAL ) FORWARD.
142 /* _UIB-CODE-BLOCK-END */
143 &ANALYZE-RESUME
146 /* *********************** Procedure Settings ************************ */
148 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
149 /* Settings for THIS-PROCEDURE
150 Type: Procedure
151 Allow:
152 Frames: 0
153 Add Fields to: Neither
154 Other Settings: CODE-ONLY COMPILE
156 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
158 /* ************************* Create Window ************************** */
160 &ANALYZE-SUSPEND _CREATE-WINDOW
161 /* DESIGN Window definition (used by the UIB)
162 CREATE WINDOW Procedure ASSIGN
163 HEIGHT = .67
164 WIDTH = 30.14.
165 /* END WINDOW DEFINITION */
167 &ANALYZE-RESUME
171 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
172 /* ************************* Included-Libraries *********************** */
174 {inc/convert.i}
175 {inc/method/m-txtrep.i}
177 /* _UIB-CODE-BLOCK-END */
178 &ANALYZE-RESUME
182 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
185 /* *************************** Main Block *************************** */
187 RUN make-control-string ( "PCL", "reset,landscape,tm,4,a4,lm,5,courier,cpi,20,lpi,9.5",
188 OUTPUT prt-ctrl, OUTPUT rows, OUTPUT cols ).
189 /* MESSAGE "Apparently" cols "by" rows VIEW-AS ALERT-BOX INFORMATION. */
191 RUN output-control-file ( prt-ctrl ).
192 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE VALUE(rows).
194 ASSIGN grand-area = 0 grand-contract = 0 grand-charged = 0 .
195 FOR EACH Property WHERE Property.Active AND Property.PropertyCode >= property-1
196 AND Property.PropertyCode <= property-2
197 NO-LOCK:
198 RUN clear-property.
199 RUN property-schedule.
201 PUT SKIP (2).
202 out-line = "* * * * * * * * * * End of Property " + STRING(Property.PropertyCode) + " " + Property.Name + " * * * * * * * * * *".
203 out-line = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(out-line) ) / 2)) + out-line.
204 RUN print-line( out-line, no ).
206 END.
207 RUN grand-totals.
209 OUTPUT CLOSE.
210 RUN view-output-file ( preview ).
212 /* _UIB-CODE-BLOCK-END */
213 &ANALYZE-RESUME
216 /* ********************** Internal Procedures *********************** */
218 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE building-notes Procedure
219 PROCEDURE building-notes :
220 /*------------------------------------------------------------------------------
221 Purpose:
222 Parameters: <none>
223 Notes:
224 ------------------------------------------------------------------------------*/
226 END PROCEDURE.
228 /* _UIB-CODE-BLOCK-END */
229 &ANALYZE-RESUME
232 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-property Procedure
233 PROCEDURE clear-property :
234 /*------------------------------------------------------------------------------
235 Purpose: Clear the work-tables we are using for each property
236 ------------------------------------------------------------------------------*/
237 FOR EACH bldg-sublease: DELETE bldg-sublease. END.
238 FOR EACH og-acct: DELETE og-acct. END.
239 ASSIGN bldg-area = 0 bldg-contract = 0 bldg-charged = 0
240 total-break = 90 notes-list = "" lease-list = "|"
241 rs-notes = "" rs-codes = ""
242 tl-notes = "" tl-codes = "".
243 END PROCEDURE.
245 /* _UIB-CODE-BLOCK-END */
246 &ANALYZE-RESUME
249 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-rental-space Procedure
250 PROCEDURE each-rental-space :
251 /*------------------------------------------------------------------------------
252 Purpose:
253 ------------------------------------------------------------------------------*/
254 DEF VAR out-line AS CHAR NO-UNDO.
255 DEF VAR i AS INT NO-UNDO.
256 DEF VAR rs-desc AS CHAR NO-UNDO.
258 DO i = 1 TO {&FIELD-COUNT}: f[i] = "". END.
259 RUN save-up-notes( RentalSpace.RentalSpaceCode, RentalSpace.NoteCode, RentalSpace.Description, OUTPUT rs-desc , INPUT-OUTPUT rs-notes, INPUT-OUTPUT rs-codes ).
260 RUN word-wrap( rs-desc, 24, OUTPUT f[1]).
261 IF RentalSpace.AreaType = "C" THEN DO:
262 f[2] = STRING( RentalSpace.AreaSize, unit-format) + " parks".
263 f[3] = STRING( ((RentalSpace.ContractedRental / RentalSpace.AreaSize) / 52), "->>,>>9.99 pw ").
264 level-parks = level-parks + (IF RentalSpace.AreaSize <> ? THEN RentalSpace.AreaSize ELSE 0).
265 END.
266 ELSE IF RentalSpace.AreaType = "N" THEN DO:
267 f[2] = STRING( RentalSpace.AreaSize, unit-format) + " rights".
268 END.
269 ELSE DO:
270 ASSIGN
271 f[2] = STRING( RentalSpace.AreaSize, area-format) + " sq.M"
272 f[3] = STRING( (RentalSpace.ContractedRental / RentalSpace.AreaSize), "->>,>>9.99 psm")
273 level-area = level-area + (IF RentalSpace.AreaSize <> ? THEN RentalSpace.AreaSize ELSE 0)
275 END.
277 IF RentalSpace.AreaStatus = "V"
278 OR NOT CAN-FIND( TenancyLease OF RentalSpace WHERE TenancyLease.LeaseStatus <> "PAST" )
279 THEN ASSIGN
280 f[4] = STRING( 0, money-format)
281 f[5] = STRING( 0, money-format)
282 f[7] = "* * * VACANT * * *".
283 ELSE DO:
284 ASSIGN
285 f[4] = STRING( RentalSpace.ContractedRental, money-format)
286 f[5] = STRING( RentalSpace.ChargedRental, money-format)
287 level-contract = level-contract + (IF RentalSpace.ContractedRental <> ? THEN RentalSpace.ContractedRental ELSE 0)
288 level-charged = level-charged + (IF RentalSpace.ChargedRental <> ? THEN RentalSpace.ChargedRental ELSE 0)
290 RUN get-lease-details.
291 END.
293 DEF VAR ln-count AS INTEGER INITIAL 1 NO-UNDO.
294 DO WHILE true:
295 RUN rental-space-line( ln-count, OUTPUT out-line ).
296 IF TRIM(out-line) = "" THEN LEAVE. /* We've finished! */
297 RUN print-line( out-line, yes ).
298 ln-count = ln-count + 1.
299 END.
301 ASSIGN space-notes = "" lease-notes = "" .
302 END PROCEDURE.
304 /* _UIB-CODE-BLOCK-END */
305 &ANALYZE-RESUME
308 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-last-notes Procedure
309 PROCEDURE get-last-notes :
310 /*------------------------------------------------------------------------------
311 Purpose: Collect together various pieces of inforrmation as notes
312 ------------------------------------------------------------------------------*/
313 DEF VAR a-line AS CHAR NO-UNDO.
315 notes-list = "".
316 various-notes = "".
317 RUN get-notes( Property.NoteCode, OUTPUT bldg-notes).
318 IF bldg-notes <> "" THEN bldg-notes = CHR(10) + "Building Notes" + CHR(10) + "--------------" + CHR(10) + CHR(10) + SUBSTRING( bldg-notes, 5).
319 RUN word-wrap( bldg-notes, 100, OUTPUT bldg-notes).
321 /* sub leases for the building */
322 IF CAN-FIND( FIRST bldg-sublease ) THEN DO:
323 various-notes = various-notes + CHR(10) + "Sub Leases" + CHR(10) + "----------" + CHR(10).
324 FOR EACH bldg-sublease:
325 FIND TenancyLease OF bldg-sublease NO-LOCK.
326 FIND Tenant OF Tenancylease NO-LOCK NO-ERROR.
327 various-notes = various-notes + (IF AVAILABLE(Tenant) THEN Tenant.Name ELSE "Tenant not on file") + CHR(10).
328 various-notes = various-notes + " To: " + bldg-sublease.Name + CHR(10).
329 a-line = (IF bldg-sublease.AnnualRental > 0 THEN (" Rent:" + STRING( bldg-sublease.AnnualRental, money-format)) ELSE "")
330 + (IF bldg-sublease.LeaseStartDate > DATE(1,1,1) THEN (" Start:" + STRING( bldg-sublease.LeaseStartDate, "99/99/9999")) ELSE "")
331 + (IF bldg-sublease.LeaseEndDate > DATE(1,1,1) THEN (" End:" + STRING( bldg-sublease.LeaseEndDate, "99/99/9999")) ELSE "").
332 IF TRIM(a-line) <> "" THEN various-notes = various-notes + a-line + CHR(10).
333 IF TRIM(bldg-sublease.Detail) <> "" THEN various-notes = various-notes + bldg-sublease.Detail + CHR(10).
334 various-notes = various-notes + CHR(10).
335 END.
336 various-notes = various-notes + CHR(10).
337 END.
339 /* frontages for the building */
340 IF CAN-FIND( FIRST StreetFrontage WHERE StreetFrontage.PropertyCode = Property.PropertyCode ) THEN DO:
341 various-notes = various-notes + CHR(10) + "Frontages" + CHR(10) + "---------" + CHR(10).
342 FOR EACH StreetFrontage WHERE StreetFrontage.PropertyCode = Property.PropertyCode NO-LOCK:
343 various-notes = various-notes + STRING( StreetFrontage.Length, ">>>>>>9.99m ") + StreetFrontage.Description + CHR(10).
344 END.
345 END.
347 END PROCEDURE.
349 /* _UIB-CODE-BLOCK-END */
350 &ANALYZE-RESUME
353 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-lease-details Procedure
354 PROCEDURE get-lease-details :
355 /*------------------------------------------------------------------------------
356 Purpose:
357 ------------------------------------------------------------------------------*/
358 FIND TenancyLease OF RentalSpace WHERE TenancyLease.LeaseStatus <> "PAST" NO-LOCK NO-ERROR.
359 IF AVAILABLE(TenancyLease) THEN DO:
360 first-appearance = INDEX( lease-list, "|" + STRING(TenancyLease.TenancyLeaseCode,"99999") + "|") = 0.
361 IF first-appearance THEN lease-list = lease-list + STRING(TenancyLease.TenancyLeaseCode,"99999") + "|".
363 RUN get-notes( TenancyLease.NoteCode, OUTPUT lease-notes ).
364 RUN get-tenant-details.
365 RUN save-up-notes( TenancyLease.TenancyLeaseCode, TenancyLease.NoteCode, f[7], OUTPUT f[7], INPUT-OUTPUT tl-notes, INPUT-OUTPUT tl-codes ).
366 RUN word-wrap( f[7], 24, OUTPUT f[7]).
367 RUN get-outgoings-details.
368 /* IF NOT first-appearance AND f[8] <> "" THEN ASSIGN f[8] = " as" f[9] = " above". */
370 f[10] = (IF TenancyLease.TermYears > 0 THEN TRIM( STRING( TenancyLease.TermYears, ">>>9y")) ELSE "")
371 + (IF TenancyLease.TermMonths > 0 THEN TRIM( STRING( TenancyLease.TermMonths, ">9m")) ELSE "")
372 + (IF TenancyLease.TermDays > 0 THEN TRIM( STRING( TenancyLease.TermDays, ">9d")) ELSE "").
373 IF (TenancyLease.TermYears < 1 AND TenancyLease.TermMonths <= 1)
374 OR TenancyLease.LeaseEndDate = ?
375 OR f[10] = ""
376 THEN f[10] = "monthly".
377 f[10] = FILL(' ', INTEGER((8 - LENGTH(f[10])) / 2)) + f[10].
379 f[11] = STRING( TenancyLease.LeaseEndDate, "99/99/9999").
380 f[12] = (IF TenancyLease.RORNoticePeriod > 0 THEN STRING( TenancyLease.RORNoticePeriod, ">>9m") ElSE "").
381 f[13] = (IF TenancyLease.RightsOfRenewal <> ? THEN TenancyLease.RightsOfRenewal ElSE "").
383 RUN get-review-details.
385 FOR EACH SubLease OF TenancyLease NO-LOCK:
386 FIND FIRST bldg-sublease WHERE bldg-sublease.TenancyLeaseCode = SubLease.TenancyLeaseCode
387 AND bldg-sublease.SubLeaseCode = SubLease.SubLeaseCode NO-LOCK NO-ERROR.
388 IF NOT AVAILABLE(bldg-sublease) THEN CREATE bldg-sublease.
389 ASSIGN
390 bldg-sublease.Name = SubLease.Name
391 bldg-sublease.TenancyLeaseCode = SubLease.TenancyLeaseCode
392 bldg-sublease.SubLeaseCode = SubLease.SubLeaseCode
393 bldg-sublease.LeaseStartDate = SubLease.LeaseStartDate
394 bldg-sublease.LeaseEndDate = SubLease.LeaseEndDate
395 bldg-sublease.AnnualRental = SubLease.AnnualRental
396 bldg-sublease.Details = SubLease.Details
398 END.
399 END.
400 ELSE DO:
401 f[7] = "Lease not on file!".
402 END.
403 END PROCEDURE.
405 /* _UIB-CODE-BLOCK-END */
406 &ANALYZE-RESUME
409 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-notes Procedure
410 PROCEDURE get-notes :
411 /*------------------------------------------------------------------------------
412 Purpose:
413 ------------------------------------------------------------------------------*/
414 DEF INPUT PARAMETER note-code AS INTEGER NO-UNDO.
415 DEF OUTPUT PARAMETER note-detail AS CHAR NO-UNDO.
417 DEF VAR i AS INT NO-UNDO.
418 DEF VAR no-notes AS INT NO-UNDO.
420 /* search the list of notes already displayed for this property */
421 no-notes = NUM-ENTRIES( notes-list).
422 DO i = 1 TO no-notes:
423 IF note-code = INTEGER(ENTRY(i,notes-list)) THEN DO:
424 note-detail = "see note [" + TRIM( STRING( i, ">>9")) + "] above.".
425 note-code = 0.
426 RETURN.
427 END.
428 END.
430 IF note-code > 0 THEN DO:
431 IF notes-list <> "" THEN notes-list = notes-list + ",".
432 notes-list = notes-list + TRIM(STRING( note-code, ">>>>>>>9")).
433 FIND Note WHERE Note.NoteCode = note-code NO-LOCK NO-ERROR.
434 note-detail = (IF AVAILABLE(Note)
435 THEN "[" + TRIM( STRING(no-notes + 1, ">>9")) + "] " + Note.Detail
436 ELSE "" ).
437 END.
438 ELSE
439 note-detail = "".
441 END PROCEDURE.
443 /* _UIB-CODE-BLOCK-END */
444 &ANALYZE-RESUME
447 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-outgoings-details Procedure
448 PROCEDURE get-outgoings-details :
449 /*------------------------------------------------------------------------------
450 Purpose: Return the outgoings details for the schedule.
451 ------------------------------------------------------------------------------*/
452 DEF VAR og-chars AS CHAR NO-UNDO.
453 DEF VAR first-desc AS LOGICAL INITIAL Yes NO-UNDO.
454 DEF VAR i AS INT NO-UNDO.
456 ASSIGN f[8] = "" f[9] = "".
457 IF TenancyLease.GrossLease THEN
458 f[17] = "Gross Lease".
459 ELSE IF first-appearance AND TenancyLease.OutgoingsBudget <> 0 THEN DO:
460 f[17] = STRING( TenancyLease.OutgoingsBudget, ">>,>>>,>>9.99").
461 END.
462 ELSE IF TenancyLease.OutgoingsBudget <> 0 THEN DO:
463 f[17] = " above".
464 END.
466 FOR EACH og-desc: DELETE og-desc. END.
467 FOR EACH TenancyOutgoing OF TenancyLease NO-LOCK,
468 FIRST ChartOfAccount OF TenancyOutgoing NO-LOCK:
469 FIND FIRST og-desc WHERE og-desc.percent = TenancyOutgoing.Percentage NO-ERROR.
470 IF AVAILABLE(og-desc) THEN ASSIGN
471 og-desc.accounts = og-desc.accounts + "," + STRING(TenancyOutgoing.AccountCode)
472 og-desc.description = og-desc.description + "~n" + ChartOfAccount.ShortName
473 og-desc.count = og-desc.count + 1.
474 ELSE DO:
475 CREATE og-desc.
476 og-desc.percent = TenancyOutgoing.Percentage.
477 og-desc.accounts = STRING(TenancyOutgoing.AccountCode).
478 og-desc.description = ChartOfAccount.ShortName.
479 og-desc.count = 1.
480 END.
481 END.
483 FOR EACH og-desc NO-LOCK BY og-desc.Count DESCENDING
484 BY og-desc.percent DESCENDING:
485 og-chars = STRING( og-desc.percent, ">>9.99" ).
486 IF NOT first-appearance THEN og-chars = "(" + og-chars + ")".
488 IF NUM-ENTRIES(og-desc.description, "~n") > 4 AND first-desc THEN ASSIGN
489 og-desc.description = "All"
490 first-desc = No.
492 DO i = 1 TO NUM-ENTRIES( og-desc.description, "~n"):
493 IF f[8] <> "" THEN ASSIGN f[8] = f[8] + "~n" f[9] = f[9] + "~n".
494 ASSIGN f[8] = f[8] + og-chars
495 f[9] = f[9] + ENTRY(i, og-desc.description, "~n").
497 END.
498 END.
500 END PROCEDURE.
502 /* _UIB-CODE-BLOCK-END */
503 &ANALYZE-RESUME
506 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-review-details Procedure
507 PROCEDURE get-review-details :
508 /*------------------------------------------------------------------------------
509 Purpose: For each review, put the info on a new line
510 ------------------------------------------------------------------------------*/
511 ASSIGN f[14] = "" f[16] = "" .
512 FOR EACH RentReview OF TenancyLease WHERE RentReview.ReviewStatus <> "DONE"
513 OR RentReview.DateComplete > (TODAY - 80) NO-LOCK:
514 IF f[16] <> "" THEN ASSIGN
515 f[14] = f[14] + CHR(10)
516 f[15] = f[15] + CHR(10)
517 f[16] = f[16] + CHR(10)
519 ELSE
520 f[15] = "".
521 ASSIGN
522 f[14] = f[14] + RentReview.ReviewStatus
523 f[15] = f[15] + (IF TenancyLease.ReviewNoticePeriod > 0 THEN STRING( TenancyLease.ReviewNoticePeriod, ">>9m") ElSE " 3m").
524 f[16] = f[16] + STRING( RentReview.DateDue, "99/99/9999")
526 END.
528 END PROCEDURE.
530 /* _UIB-CODE-BLOCK-END */
531 &ANALYZE-RESUME
534 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-saved-notes Procedure
535 PROCEDURE get-saved-notes :
536 /*------------------------------------------------------------------------------
537 Purpose:
538 ------------------------------------------------------------------------------*/
539 DEF OUTPUT PARAMETER rs-text AS CHAR NO-UNDO.
540 DEF OUTPUT PARAMETER tl-text AS CHAR NO-UNDO.
542 DEF VAR i AS INT NO-UNDO.
543 DEF VAR n AS INT NO-UNDO.
544 DEF VAR code AS INT NO-UNDO.
545 DEF VAR note-text AS CHAR NO-UNDO.
547 n = NUM-ENTRIES(rs-notes).
548 IF n > 0 THEN DO:
549 rs-text = "Rental Space Notes~n------------------~n".
550 DO i = 1 TO n:
551 code = INTEGER(ENTRY(i,rs-codes)).
552 FIND RentalSpace OF Property WHERE RentalSpaceCode = code NO-LOCK NO-ERROR.
553 code = INTEGER(ENTRY(i,rs-notes)).
554 FIND Note WHERE Note.NoteCode = code NO-LOCK.
555 rs-text = rs-text + "~n"
556 + STRING( STRING(i) + ".", "X(8)")
557 + ( IF AVAILABLE(RentalSpace) THEN
558 STRING( RentalSpace.Level ) + "-"
559 + STRING( RentalSpace.LevelSequence) + " "
560 + RentalSpace.Description
561 ELSE
562 "Rental Space not available(!)"
564 + "~n~n"
565 + Note.Detail + "~n".
566 END.
567 END.
569 n = NUM-ENTRIES(tl-notes).
570 IF n > 0 THEN DO:
571 tl-text = "Tenancy Lease Notes~n-------------------~n".
572 DO i = 1 TO n:
573 code = INTEGER(ENTRY(i,tl-codes)).
574 FIND TenancyLease OF Property WHERE TenancyLease.TenancyLeaseCode = code NO-LOCK NO-ERROR.
575 IF AVAILABLE(TenancyLease) THEN FIND Tenant OF TenancyLease NO-LOCK NO-ERROR.
576 code = INTEGER(ENTRY(i,tl-notes)).
577 FIND Note WHERE Note.NoteCode = code NO-LOCK.
578 tl-text = tl-text + "~n"
579 + STRING( STRING(i) + ".", "X(8)")
580 + STRING( (IF AVAILABLE(Tenant) THEN STRING(Tenant.TenantCode, "99999") ELSE "no tenant"), "X(10)")
581 + (IF AVAILABLE(Tenant) THEN Tenant.Name ELSE "Lease >>" + STRING(code) + "<<") + "~n~n"
582 + Note.Detail + "~n".
583 END.
584 END.
585 END PROCEDURE.
587 /* _UIB-CODE-BLOCK-END */
588 &ANALYZE-RESUME
591 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-tenant-details Procedure
592 PROCEDURE get-tenant-details :
593 /*------------------------------------------------------------------------------
594 Purpose: Get the tenant of the lease.
595 ------------------------------------------------------------------------------*/
597 FIND Tenant OF TenancyLease NO-LOCK NO-ERROR.
598 IF AVAILABLE(Tenant) THEN DO:
599 f[7] = Tenant.Name + " (T" + STRING( Tenant.TenantCode, "99999") + ")".
600 IF Tenant.Name <> Tenant.LegalName AND Tenant.LegalName <> "" THEN
601 f[7] = f[7] + "~nT/A: " + Tenant.LegalName.
603 /* Inactive tenants are not charged rental */
604 IF NOT tenant.active THEN DO:
605 level-contract = level-contract - (IF RentalSpace.ContractedRental <> ? THEN RentalSpace.ContractedRental ELSE 0).
606 level-charged = level-charged - (IF RentalSpace.ChargedRental <> ? THEN RentalSpace.ChargedRental ELSE 0).
607 f[5] = STRING( 0, money-format).
608 f[4] = STRING( 0, money-format).
609 f[5] = " inactive" + SUBSTRING( f[5], 10).
610 END.
611 END.
612 ELSE
613 f[7] = "Tenant not on file!".
615 END PROCEDURE.
617 /* _UIB-CODE-BLOCK-END */
618 &ANALYZE-RESUME
621 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE grand-totals Procedure
622 PROCEDURE grand-totals :
623 /*------------------------------------------------------------------------------
624 Purpose: Display grand totals for report
625 ------------------------------------------------------------------------------*/
626 DEF VAR out-line AS CHAR NO-UNDO.
628 PUT SKIP (4).
630 RUN print-line( e-line, no).
631 out-line = STRING( "Total for Report", "X(25)")
632 + (IF grand-area > 0 THEN STRING( grand-area, area-format) + " square metres" ELSE FILL(' ',24))
633 + FILL(' ',7)
634 + STRING( grand-contract, money-format) + " "
635 + STRING( grand-charged, money-format).
636 RUN print-line( out-line, no ).
637 RUN print-line( e-line, no).
639 out-line = "* * * * * * End of Schedule * * * * * *".
640 out-line = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(out-line) ) / 2)) + out-line.
641 RUN print-line( out-line, no ).
643 END PROCEDURE.
645 /* _UIB-CODE-BLOCK-END */
646 &ANALYZE-RESUME
649 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE new-level Procedure
650 PROCEDURE new-level :
651 /*------------------------------------------------------------------------------
652 Purpose:
653 ------------------------------------------------------------------------------*/
654 DEF INPUT PARAMETER last-level AS INT NO-UNDO.
655 DEF INPUT PARAMETER next-level AS INT NO-UNDO.
657 DEF VAR out-line AS CHAR NO-UNDO.
658 DEF VAR level-name AS CHAR NO-UNDO.
659 DEF VAR level-units AS CHAR NO-UNDO.
661 IF last-level <> -99999 AND level-lines > 1 THEN DO:
662 IF last-level = 99 THEN DO:
663 level-name = "Miscellaneous".
664 level-units = (IF level-area > 0 THEN STRING( level-area, area-format) + " square metres" ELSE "").
665 END.
666 ELSE IF last-level >= 90 THEN DO:
667 level-name = "Carparking".
668 level-units = (IF level-parks > 0 THEN STRING( level-parks, unit-format) + " parks" ELSE "").
669 END.
670 ELSE DO:
671 level-name = "Level " + TRIM( STRING(last-level,"->,>>9")).
672 level-units = (IF level-area > 0 THEN STRING( level-area, area-format) + " square metres" ELSE "").
673 END.
674 out-line = FILL(' ', 25) + STRING( "----------", "X(32)") + FILL('-',14) + ' ' + FILL('-',14).
675 RUN print-line( out-line, yes ).
676 out-line = FILL(' ', 4) + STRING( "Total " + level-name, "X(21)")
677 + STRING( level-units, "X(32)")
678 + STRING( level-contract, money-format) + " "
679 + STRING( level-charged, money-format).
680 RUN print-line( out-line, yes ).
681 RUN print-line( u-line, no).
682 END.
683 ELSE IF last-level <> -99999 AND next-level < total-break THEN
684 RUN put-blank-line.
686 ASSIGN
687 bldg-area = bldg-area + level-area
688 bldg-contract = bldg-contract + level-contract
689 bldg-charged = bldg-charged + level-charged
690 level-area = 0
691 level-parks = 0
692 level-contract = 0
693 level-charged = 0
696 IF last-level <> -99999 AND next-level >= total-break THEN RUN property-totals( (next-level = 99999) ).
697 level-lines = 0.
699 END PROCEDURE.
701 /* _UIB-CODE-BLOCK-END */
702 &ANALYZE-RESUME
705 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-line Procedure
706 PROCEDURE print-line :
707 /*------------------------------------------------------------------------------
708 Purpose: Print a line of output
709 ------------------------------------------------------------------------------*/
710 DEF INPUT PARAMETER the-line AS CHAR NO-UNDO.
711 DEF INPUT PARAMETER split AS LOGICAL NO-UNDO.
713 IF split THEN DO:
714 the-line = STRING( the-line, "X(" + TRIM(STRING({&page-width},">>>>9")) + ")").
715 IF SUBSTRING( the-line, {&VERT-POS}, 1) = " " THEN SUBSTRING( the-line, {&VERT-POS}, 1) = "|".
716 END.
717 PUT UNFORMATTED the-line SKIP.
719 END PROCEDURE.
721 /* _UIB-CODE-BLOCK-END */
722 &ANALYZE-RESUME
725 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-notes Procedure
726 PROCEDURE print-notes :
727 /*------------------------------------------------------------------------------
728 Purpose: Print the notes
729 ------------------------------------------------------------------------------*/
730 DEF INPUT PARAMETER left-notes AS CHAR NO-UNDO.
731 DEF INPUT PARAMETER right-notes AS CHAR NO-UNDO.
733 DEF VAR out-line AS CHAR NO-UNDO.
734 DEF VAR one-note AS CHAR NO-UNDO.
736 DEF VAR no-lines AS INT NO-UNDO.
737 no-lines = NUM-ENTRIES( left-notes, CHR(10)).
738 IF no-lines < NUM-ENTRIES( right-notes, CHR(10)) THEN no-lines = NUM-ENTRIES( right-notes, CHR(10)).
740 DEF VAR l-no AS INTEGER INITIAL 1 NO-UNDO.
741 DO l-no = 1 TO no-lines:
742 ASSIGN one-note = ""
743 one-note = ENTRY( l-no, left-notes, CHR(10)) NO-ERROR.
744 IF one-note = ? THEN one-note = "".
745 out-line = ' ' + STRING( one-note, "X(70)") + ' '.
747 ASSIGN one-note = ""
748 one-note = ENTRY( l-no, right-notes, CHR(10)) NO-ERROR.
749 IF one-note = ? THEN one-note = "".
750 out-line = out-line + ' ' + STRING( one-note, "X(100)").
752 RUN print-line( out-line, yes ).
753 END.
755 END PROCEDURE.
757 /* _UIB-CODE-BLOCK-END */
758 &ANALYZE-RESUME
761 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-schedule Procedure
762 PROCEDURE property-schedule :
763 /*------------------------------------------------------------------------------
764 Purpose: Schedule for a single building
765 ------------------------------------------------------------------------------*/
766 DEF VAR last-level AS INT INITIAL -99999 NO-UNDO.
767 DEF VAR out-line AS CHAR NO-UNDO.
769 RUN set-headings( col-head1-base, col-head2-base).
770 FOR EACH RentalSpace OF Property NO-LOCK
771 BY RentalSpace.PropertyCode BY RentalSpace.Level BY RentalSpace.LevelSequence:
772 IF RentalSpace.Level <> last-level THEN DO:
773 RUN new-level ( last-level, RentalSpace.Level ).
774 last-level = RentalSpace.Level.
775 END.
776 RUN each-rental-space.
777 level-lines = level-lines + 1.
778 END.
779 RUN new-level( last-level, 99999 ).
781 END PROCEDURE.
783 /* _UIB-CODE-BLOCK-END */
784 &ANALYZE-RESUME
787 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-totals Procedure
788 PROCEDURE property-totals :
789 /*------------------------------------------------------------------------------
790 Purpose: Display final- or sub- totals for this property
791 ------------------------------------------------------------------------------*/
792 DEF INPUT PARAMETER final-total AS LOGICAL NO-UNDO.
794 DEF VAR out-line AS CHAR NO-UNDO.
796 RUN print-line( e-line, no).
797 IF final-total THEN
798 out-line = "Total for " + Property.Name.
799 ELSE
800 out-line = " " + "Total floor rental".
801 out-line = STRING( out-line, "X(25)")
802 + (IF bldg-area > 0 THEN STRING( bldg-area, area-format) + " square metres" ELSE FILL(' ',24))
803 + FILL(' ',7)
804 + STRING( bldg-contract, money-format) + " "
805 + STRING( bldg-charged, money-format).
806 RUN print-line( out-line, no ).
807 RUN print-line( e-line, no).
809 IF final-total THEN DO:
810 ASSIGN
811 grand-area = grand-area + bldg-area
812 grand-contract = grand-contract + bldg-contract
813 grand-charged = grand-charged + bldg-charged
814 bldg-area = 0
815 bldg-contract = 0
816 bldg-charged = 0
818 END.
819 ELSE
820 total-break = total-break * 10.
822 END PROCEDURE.
824 /* _UIB-CODE-BLOCK-END */
825 &ANALYZE-RESUME
828 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE put-blank-line Procedure
829 PROCEDURE put-blank-line :
830 /*------------------------------------------------------------------------------
831 Purpose: Put a blank line - with a vertical in it?
832 ------------------------------------------------------------------------------*/
833 DEF VAR out-line AS CHAR NO-UNDO.
834 out-line = FILL(' ',{&VERT-POS}).
835 RUN print-line( out-line, yes).
836 END PROCEDURE.
838 /* _UIB-CODE-BLOCK-END */
839 &ANALYZE-RESUME
842 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE rental-space-line Procedure
843 PROCEDURE rental-space-line :
844 /*------------------------------------------------------------------------------
845 Purpose: Create an output line.
846 ------------------------------------------------------------------------------*/
847 DEF INPUT PARAMETER l-no AS INTEGER NO-UNDO.
848 DEF OUTPUT PARAMETER line AS CHAR NO-UNDO.
850 DEF VAR fval AS CHAR NO-UNDO.
851 DEF VAR i AS INT NO-UNDO.
853 line = "".
854 DO i = 1 TO {&FIELD-COUNT}:
855 ASSIGN fval = ""
856 fval = ENTRY( l-no, f[i], CHR(10)) NO-ERROR.
857 IF fval = ? THEN fval = "".
858 line = line + STRING( fval, f-fmt[i]) + ' '.
859 END.
861 END PROCEDURE.
863 /* _UIB-CODE-BLOCK-END */
864 &ANALYZE-RESUME
867 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE save-up-notes Procedure
868 PROCEDURE save-up-notes :
869 /*------------------------------------------------------------------------------
870 Purpose:
871 ------------------------------------------------------------------------------*/
872 DEF INPUT PARAMETER record-code AS INT NO-UNDO.
873 DEF INPUT PARAMETER note-code AS INT NO-UNDO.
874 DEF INPUT PARAMETER i-desc AS CHAR NO-UNDO.
875 DEF OUTPUT PARAMETER o-desc AS CHAR NO-UNDO.
876 DEF INPUT-OUTPUT PARAMETER n-list AS CHAR NO-UNDO.
877 DEF INPUT-OUTPUT PARAMETER c-list AS CHAR NO-UNDO.
879 DEF VAR n AS INT NO-UNDO.
880 DEF VAR i AS INT NO-UNDO.
881 DEF VAR result AS INT NO-UNDO INITIAL 0.
883 o-desc = i-desc.
884 IF note-code = ? OR note-code = 0 THEN RETURN.
885 FIND Note WHERE Note.NoteCode = note-code NO-LOCK NO-ERROR.
886 IF NOT AVAILABLE(Note) THEN RETURN.
887 IF TRIM(Note.Detail) = "" THEN RETURN.
889 n = NUM-ENTRIES(n-list).
890 DO i = 1 TO n:
891 IF INTEGER(ENTRY(i,n-list)) = note-code THEN DO:
892 result = i.
893 LEAVE.
894 END.
895 END.
897 IF result = 0 THEN DO:
898 result = n + 1.
899 n-list = n-list + (IF n-list <> "" THEN "," ELSE "") + STRING(note-code).
900 c-list = c-list + (IF c-list <> "" THEN "," ELSE "") + STRING(record-code).
901 END.
903 o-desc = i-desc + " *" + TRIM(STRING(result)).
905 END PROCEDURE.
907 /* _UIB-CODE-BLOCK-END */
908 &ANALYZE-RESUME
911 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-headings Procedure
912 PROCEDURE set-headings :
913 /*------------------------------------------------------------------------------
914 Purpose: Set the headings for the building schedule report.
915 ------------------------------------------------------------------------------*/
916 DEF INPUT PARAMETER column-1 AS CHAR NO-UNDO.
917 DEF INPUT PARAMETER column-2 AS CHAR NO-UNDO.
919 DEF VAR pos AS INT NO-UNDO.
921 FIND Company WHERE Company.CompanyCode = Property.CompanyCode NO-LOCK NO-ERROR.
922 ASSIGN
923 hline2 = (IF AVAILABLE(Company) THEN Company.LegalName ELSE "No Company Assigned")
924 hline3 = Property.Name + " (P" + TRIM( STRING( Property.PropertyCode, ">>>>9")) + ")"
925 hline4 = Property.StreetAddress
926 col-head1 = column-1
927 col-head2 = column-2
930 Replace-EOL-With-Commas:
931 DO WHILE TRUE:
932 pos = INDEX( hline4, CHR(10)).
933 IF pos > 0 THEN
934 hline4 = SUBSTRING( hline4, 1, pos - 1) + ", " + SUBSTRING( hline4, pos + 1).
935 ELSE
936 LEAVE Replace-EOL-With-Commas.
937 END.
938 hline2 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
939 hline3 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline3) ) / 2)) + hline3.
940 hline4 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline4) ) / 2)) + hline4.
942 IF first-building THEN DO:
943 VIEW FRAME heading-frame.
944 first-building = no.
945 END.
946 ELSE DO:
947 PAGE.
948 END.
950 END PROCEDURE.
952 /* _UIB-CODE-BLOCK-END */
953 &ANALYZE-RESUME
956 /* ************************ Function Implementations ***************** */
958 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-prop-og Procedure
959 FUNCTION get-prop-og RETURNS DECIMAL
960 ( INPUT doit AS LOGICAL, INPUT pc AS INTEGER, INPUT ac AS DECIMAL ) :
961 /*------------------------------------------------------------------------------
962 Purpose:
963 Notes:
964 ------------------------------------------------------------------------------*/
965 IF doit <> Yes THEN RETURN 1.0 .
966 FIND PropertyOutgoing WHERE PropertyOutgoing.PropertyCode = pc
967 AND PropertyOutgoing.AccountCode = ac NO-LOCK NO-ERROR.
968 IF AVAILABLE(PropertyOutgoing) THEN
969 RETURN PropertyOutgoing.BudgetAmount / 100 .
971 RETURN 0.00 .
973 END FUNCTION.
975 /* _UIB-CODE-BLOCK-END */
976 &ANALYZE-RESUME