Add blank column, rename column.
[capital-apms-progress.git] / process / period / vacant.p
blob52a8806f772fbe9be564959bc2d831ad56119e4e
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
9 DEF VAR report-id AS CHAR NO-UNDO INITIAL "VCNT".
11 DEF VAR debug-mode AS LOGICAL NO-UNDO INITIAL No.
12 DEF VAR min-rental AS DECIMAL NO-UNDO INITIAL 0.
13 DEF VAR gen-report AS LOGICAL NO-UNDO INITIAL No.
14 DEF VAR report-sequence AS CHAR NO-UNDO.
16 DEF VAR single-manager AS INT NO-UNDO INITIAL 0.
17 DEF VAR one-manager-name AS CHAR NO-UNDO INITIAL "".
18 DEF VAR merge-parks AS LOGICAL NO-UNDO INITIAL No.
19 DEF VAR report-exclude-entity AS LOGICAL NO-UNDO INITIAL No.
20 DEF VAR entity-list AS CHAR NO-UNDO.
21 DEF VAR print-summary-only AS LOGICAL NO-UNDO INITIAL No.
24 RUN parse-parameters.
26 DEF VAR current-process AS CHAR NO-UNDO.
28 /* _UIB-CODE-BLOCK-END */
29 &ANALYZE-RESUME
32 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
34 /* ******************** Preprocessor Definitions ******************** */
36 &Scoped-define PROCEDURE-TYPE Procedure
37 &Scoped-define DB-AWARE no
41 /* _UIB-PREPROCESSOR-BLOCK-END */
42 &ANALYZE-RESUME
46 /* *********************** Procedure Settings ************************ */
48 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
49 /* Settings for THIS-PROCEDURE
50 Type: Procedure
51 Allow:
52 Frames: 0
53 Add Fields to: Neither
54 Other Settings: CODE-ONLY COMPILE
56 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
58 /* ************************* Create Window ************************** */
60 &ANALYZE-SUSPEND _CREATE-WINDOW
61 /* DESIGN Window definition (used by the UIB)
62 CREATE WINDOW Procedure ASSIGN
63 HEIGHT = 13.2
64 WIDTH = 35.
65 /* END WINDOW DEFINITION */
67 &ANALYZE-RESUME
69 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
70 /* ************************* Included-Libraries *********************** */
72 {inc/method/m-period.i}
74 /* _UIB-CODE-BLOCK-END */
75 &ANALYZE-RESUME
81 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
84 /* *************************** Main Block *************************** */
86 IF file-name = "Printer" THEN
87 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
88 ELSE
89 OUTPUT TO VALUE( file-name ).
91 IF gen-report THEN DO:
92 RUN delete-todays-report.
93 RUN generate-vacant-spaces.
94 END.
96 RUN output-vacant-summary.
97 IF NOT(print-summary-only) THEN
98 RUN output-vacant-spaces.
99 OUTPUT CLOSE.
101 IF file-name = "Printer" THEN RUN view-output-file( report-preview ).
103 /* _UIB-CODE-BLOCK-END */
104 &ANALYZE-RESUME
107 /* ********************** Internal Procedures *********************** */
109 &IF DEFINED(EXCLUDE-generate-vacant-spaces) = 0 &THEN
111 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE generate-vacant-spaces Procedure
112 PROCEDURE generate-vacant-spaces :
113 /*------------------------------------------------------------------------------
114 Purpose: Generate the information for the report
115 ------------------------------------------------------------------------------*/
117 RUN create-detail( "HR", "", report-options ).
118 RUN create-detail( "VC", "", '"Description"' + delim + '"Area"' + delim + '"Parks"' + delim + '"EAR-Annual"' + delim + '"EAR-PSM"' + delim + '"Cost-Annual"'
119 + delim + '"Cost-PSM"' + delim + '"VacantFromDate"').
121 FOR EACH Property WHERE Property.Active NO-LOCK:
122 FOR EACH RentalSpace OF Property NO-LOCK:
123 RUN add-rsp-portfolio.
125 IF RentalSpace.AreaStatus = "V" THEN DO:
126 RUN get-area-info.
127 RUN create-rentalspace-detail.
128 DELETE AreaInfo.
129 END.
130 END.
131 END.
133 RUN create-detail( "PC", "", '"Portfolio"' + delim + '"Area"' + delim + '"EAR-Annual"' + delim + '"Base-Annual"' + delim + '"Total-Annual"' ).
134 FOR EACH Portfolio:
135 RUN create-detail( "PF", STRING(Portfolio.Portfolio),
136 STRING( Portfolio.AreaSize ) + delim
137 + STRING( Portfolio.Rental[1] ) + delim
138 + STRING( Portfolio.Rental[2] ) + delim
139 + STRING( Portfolio.Rental[3] ) ).
140 END.
141 RUN create-detail( "PF", "Total", STRING( total-area ) + delim
142 + STRING( total-rntl[1] ) + delim
143 + STRING( total-rntl[2] ) + delim
144 + STRING( total-rntl[3] ) ).
146 RUN second-pass.
148 END PROCEDURE.
150 /* _UIB-CODE-BLOCK-END */
151 &ANALYZE-RESUME
153 &ENDIF
155 &IF DEFINED(EXCLUDE-output-vacant-spaces) = 0 &THEN
157 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-vacant-spaces Procedure
158 PROCEDURE output-vacant-spaces :
159 /*------------------------------------------------------------------------------
160 Purpose:
161 ------------------------------------------------------------------------------*/
162 current-process = "VACANCIES".
163 FIND LAST PeriodicDetail WHERE PeriodicDetail.ReportID = report-id
164 AND PeriodicDetail.Date <= report-asat-date
165 AND PeriodicDetail.DetailType = "D"
166 NO-LOCK.
168 report-title = "Vacant Space by " + report-sequence
169 + "~n as at " + STRING( PeriodicDetail.Date, "99/99/9999")
170 + (IF report-sequence = "Single":U THEN " for " + one-manager-name ELSE "").
172 now = STRING( TODAY, "99/99/9999" ) + ", " + STRING( TIME, "HH:MM:SS" ).
174 xlate-list = "1,3,4,7,8,15,C".
175 RUN set-rentalspace-fields.
177 CASE report-sequence:
178 WHEN "Region" THEN ASSIGN
179 n-breaks = 2
180 break-type = 3.
181 OTHERWISE ASSIGN
182 n-breaks = 2
183 break-type = 1.
184 END CASE.
186 RUN basic-report( report-asat-date ).
188 END PROCEDURE.
190 /* _UIB-CODE-BLOCK-END */
191 &ANALYZE-RESUME
193 &ENDIF
195 &IF DEFINED(EXCLUDE-output-vacant-summary) = 0 &THEN
197 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-vacant-summary Procedure
198 PROCEDURE output-vacant-summary :
199 /*------------------------------------------------------------------------------
200 Purpose:
201 ------------------------------------------------------------------------------*/
202 current-process = "SUMMARY".
203 FIND LAST PeriodicDetail WHERE PeriodicDetail.ReportID = report-id
204 AND PeriodicDetail.Date <= report-asat-date
205 AND PeriodicDetail.DetailType = "D"
206 NO-LOCK.
208 report-title = "Summary of Vacant Space ~nas at " + STRING( PeriodicDetail.Date, "99/99/9999")
209 + (IF report-sequence = "Single":U THEN " for " + one-manager-name ELSE "").
210 now = STRING( TODAY, "99/99/9999" ) + ", " + STRING( TIME, "HH:MM:SS" ).
212 xlate-list = "1,3,16,4,7,17".
213 RUN set-rentalspace-fields.
215 /* ENTRY( 7, total-formats, delim) = ">>,>>9.99". */
217 n-breaks = 2.
218 break-type = 2.
220 RUN basic-report( report-asat-date ).
222 END PROCEDURE.
224 /* _UIB-CODE-BLOCK-END */
225 &ANALYZE-RESUME
227 &ENDIF
229 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
231 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
232 PROCEDURE parse-parameters :
233 /*------------------------------------------------------------------------------
234 Purpose: Decode the command-line parameters
235 ------------------------------------------------------------------------------*/
236 DEF VAR i AS INT NO-UNDO.
237 DEF VAR token AS CHAR NO-UNDO.
239 {inc/showopts.i "report-options"}
241 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
242 token = ENTRY( i, report-options, "~n" ).
243 CASE( ENTRY( 1, token ) ):
244 WHEN "Debug" THEN debug-mode = Yes.
245 WHEN "Regenerate" THEN gen-report = Yes.
246 WHEN "FileName" THEN file-name = TRIM( SUBSTRING(token, LENGTH(ENTRY(1,token)) + 2) ).
247 WHEN "AsAtDate" THEN report-asat-date = DATE( ENTRY(2,token) ).
249 WHEN "MinRental" THEN min-rental = DEC( ENTRY(2,token) ).
250 WHEN "Sequence" THEN report-sequence = ENTRY(2,token).
251 WHEN "OneManager" THEN single-manager = INT( ENTRY(2,token) ).
252 WHEN "MergeParks" THEN merge-parks = yes.
253 WHEN "SummaryOnly" THEN print-summary-only = yes.
254 END CASE.
255 END.
257 IF gen-report THEN report-asat-date = TODAY.
258 IF file-name = "Preview" THEN ASSIGN
259 file-name = "Printer"
260 report-preview = Yes.
262 IF report-sequence = "Single":U THEN DO:
263 FIND Person WHERE Person.PersonCode = single-manager NO-LOCK NO-ERROR.
264 IF AVAILABLE(Person) THEN
265 one-manager-name = Person.FirstName + " " + Person.LastName .
266 ELSE
267 report-sequence = "Manager":U .
268 END.
270 END PROCEDURE.
272 /* _UIB-CODE-BLOCK-END */
273 &ANALYZE-RESUME
275 &ENDIF
277 &IF DEFINED(EXCLUDE-pre-break-begin) = 0 &THEN
279 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-break-begin Procedure
280 PROCEDURE pre-break-begin :
281 /*------------------------------------------------------------------------------
282 Purpose: override the break begin procedure
283 ------------------------------------------------------------------------------*/
284 DEF INPUT PARAMETER break-level AS INT NO-UNDO.
286 IF current-process = "VACANCIES" THEN DO:
287 IF report-sequence = "Single":U AND break-level = 1 THEN RETURN "No".
288 RETURN.
289 END.
291 RUN skip-line(0). /* force headers */
292 IF current-process = "SUMMARY" THEN RETURN "NO".
294 END PROCEDURE.
296 /* _UIB-CODE-BLOCK-END */
297 &ANALYZE-RESUME
299 &ENDIF
301 &IF DEFINED(EXCLUDE-pre-break-end) = 0 &THEN
303 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-break-end Procedure
304 PROCEDURE pre-break-end :
305 /*------------------------------------------------------------------------------
306 Purpose: Override the default break-end process
307 ------------------------------------------------------------------------------*/
308 DEF INPUT PARAMETER break-level AS INT NO-UNDO.
310 IF current-process <> "SUMMARY" THEN RETURN.
311 IF break-level = 1 THEN RETURN "NO".
312 IF break-level <> 2 AND break-level <> 0 THEN RETURN.
314 DEF VAR total-line AS CHAR NO-UNDO.
315 DEF VAR break-value AS CHAR NO-UNDO.
316 DEF VAR area AS DECIMAL NO-UNDO.
317 DEF VAR i AS INT NO-UNDO.
318 DEF VAR totals AS CHAR NO-UNDO.
319 DEF VAR portfolio-area AS DECIMAL NO-UNDO.
320 DEF VAR portfolio-rent AS DECIMAL NO-UNDO.
322 totals = (IF break-level = 0 THEN grd-tot ELSE brk-tot[break-level]).
323 break-value = IF break-level = 0 THEN "Grand Total" ELSE brk-val[break-level].
324 ASSIGN area = DECIMAL( ENTRY( 2, totals, delim) ) NO-ERROR.
325 IF area = ? THEN area = 0.
327 total-line = "".
328 DO i = 1 TO 6:
329 IF i = 1 THEN
330 total-line = total-line + break-value + delim.
331 /* ELSE IF i = 7 AND area <> 0 THEN
332 total-line = total-line + STRING( (DECIMAL( ENTRY( 5, totals, delim)) / area),
333 ENTRY( i, total-formats, delim) )
334 + delim.
335 ELSE IF i = 7 OR ENTRY( i, total-list, delim ) <> "Y" THEN
336 total-line = total-line + delim. */
337 ELSE /* i = 2, 3, or 4 */
338 total-line = total-line + STRING( DECIMAL( ENTRY( i, totals, delim)),
339 ENTRY( i, total-formats, delim) )
340 + delim.
341 END.
343 IF break-level = 0 THEN DO:
344 RUN total-separator.
346 /* overwrite the total figures for % area and % rent with zero since the totals
347 don't make sense */
348 FOR EACH PropInfo NO-LOCK:
349 ASSIGN
350 portfolio-area = portfolio-area + PropInfo.TotalArea
351 portfolio-rent = portfolio-rent + PropInfo.TotalRent.
352 END.
353 ENTRY(3, total-line, delim) = " ".
354 ENTRY(6, total-line, delim) = " ".
356 IF file-name = "Printer" THEN RUN line-to-printer( No, total-line + delim + "" ).
357 ELSE RUN line-to-file( total-line + delim + "" ).
359 /* print % for total portfolio line */
360 ENTRY(1, total-line, delim) = "Whole Portfolio".
361 ENTRY(3, total-line, delim) = STRING(DECIMAL(ENTRY(2, total-line, delim)) / portfolio-area * 100,">>9.99").
362 ENTRY(6, total-line, delim) = STRING(DECIMAL(ENTRY(5, total-line, delim)) / portfolio-rent * 100,">>9.99").
363 ENTRY(2, total-line, delim) = " ".
364 ENTRY(4, total-line, delim) = " ".
365 ENTRY(5, total-line, delim) = " ".
366 END.
369 IF file-name = "Printer" THEN RUN line-to-printer( No, total-line + delim + "" ).
370 ELSE RUN line-to-file( total-line + delim + "" ).
373 RETURN "NO".
375 END PROCEDURE.
377 /* _UIB-CODE-BLOCK-END */
378 &ANALYZE-RESUME
380 &ENDIF
382 &IF DEFINED(EXCLUDE-pre-detail-line) = 0 &THEN
384 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-detail-line Procedure
385 PROCEDURE pre-detail-line :
386 /*------------------------------------------------------------------------------
387 Purpose: Override the default detail-line processing
388 ------------------------------------------------------------------------------*/
389 DEF INPUT-OUTPUT PARAMETER break-value AS CHAR NO-UNDO.
391 DEF VAR property-code AS INT NO-UNDO.
393 /* MESSAGE PeriodicDetail.ReportId PeriodicDetail.Date PeriodicDetail.DetailType PeriodicDetail.BreakValue3. */
394 IF report-sequence = "Single":U THEN DO:
395 property-code = INT( TRIM( ENTRY( 1, ENTRY( 2, PeriodicDetail.BreakValue1, "|"), " ") ) ).
396 FIND Property WHERE Property.PropertyCode = property-code NO-LOCK NO-ERROR.
397 IF Property.Manager <> single-manager THEN RETURN "No".
398 /* MESSAGE ">>" + manager-name + "<< >>" + one-manager-name + "<<". */
399 END.
401 IF ABSOLUTE( DECIMAL( ENTRY( 7, PeriodicDetail.Data, delim) ) ) < min-rental THEN
402 RETURN "NO".
404 END PROCEDURE.
406 /* _UIB-CODE-BLOCK-END */
407 &ANALYZE-RESUME
409 &ENDIF
411 &IF DEFINED(EXCLUDE-pre-output-line) = 0 &THEN
413 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-output-line Procedure
414 PROCEDURE pre-output-line :
415 /*------------------------------------------------------------------------------
416 Purpose: Selectively override the printing of the detail line
417 ------------------------------------------------------------------------------*/
418 DEF INPUT PARAMETER break-value AS CHAR NO-UNDO.
420 IF current-process = "VACANCIES" THEN RETURN.
421 IF current-process = "SUMMARY" THEN RETURN "NO".
423 END PROCEDURE.
425 /* _UIB-CODE-BLOCK-END */
426 &ANALYZE-RESUME
428 &ENDIF
430 &IF DEFINED(EXCLUDE-second-pass) = 0 &THEN
432 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE second-pass Procedure
433 PROCEDURE second-pass :
434 /*------------------------------------------------------------------------------
435 Purpose: Second pass to set up vacant space totals in breakvalue 2
436 ------------------------------------------------------------------------------*/
437 DEF VAR last-pcode AS INT NO-UNDO INITIAL -1.
438 DEF VAR this-pcode AS INT NO-UNDO INITIAL -1.
439 DEF VAR ptotal AS DEC NO-UNDO.
440 DEF VAR val AS DEC NO-UNDO.
441 DEF BUFFER PD FOR PeriodicDetail.
443 FOR EACH PeriodicDetail WHERE PeriodicDetail.ReportID = report-id
444 AND PeriodicDetail.DetailType = "D"
445 AND PeriodicDetail.Date = TODAY
446 SHARE-LOCK
447 BY PeriodicDetail.BreakValue2 DESCENDING:
448 this-pcode = INTEGER( SUBSTRING( ENTRY( 2, PeriodicDetail.BreakValue2, delim), 1, 5)).
449 IF this-pcode <> last-pcode THEN DO:
450 ptotal = 1000000000.
451 FOR EACH PD NO-LOCK WHERE PD.BreakValue2 = PeriodicDetail.BreakValue2
452 AND PD.ReportID = report-id
453 AND PD.DetailType = "D"
454 AND PD.Date = TODAY :
455 ASSIGN val = DECIMAL( ENTRY( 7, PD.Data, delim) ) NO-ERROR.
456 ptotal = ptotal - (IF val = ? THEN 0 ELSE val).
457 END.
458 last-pcode = this-pcode.
459 END.
460 ENTRY( 1, PeriodicDetail.BreakValue2, delim) = ENTRY( 1, PeriodicDetail.BreakValue2, delim) +
461 " " + STRING( ptotal, "9999999999.99").
462 END.
464 END PROCEDURE.
466 /* _UIB-CODE-BLOCK-END */
467 &ANALYZE-RESUME
469 &ENDIF