Add blank column, rename column.
[capital-apms-progress.git] / process / report / bldg-area-reconciliation.p
blobbe3fabd4272b59a6707cef1fcbf0b7ff7438f946
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 Yes.
13 DEF VAR property-1 AS INT NO-UNDO INIT 0.
14 DEF VAR property-n AS INT NO-UNDO INIT 99999.
15 DEF VAR selection-style AS CHAR NO-UNDO.
16 DEF VAR test-client-code AS CHAR NO-UNDO INITIAL ?.
17 DEF VAR company-list AS CHAR NO-UNDO INITIAL ?.
18 DEF VAR property-code AS INT NO-UNDO.
19 DEF VAR property-name AS CHAR NO-UNDO.
20 RUN parse-parameters.
23 DEF VAR user-name AS CHAR NO-UNDO.
24 {inc/username.i "user-name"}
25 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
26 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
28 DEF VAR line AS CHAR NO-UNDO INITIAL "".
30 /* _UIB-CODE-BLOCK-END */
31 &ANALYZE-RESUME
34 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
36 /* ******************** Preprocessor Definitions ******************** */
38 &Scoped-define PROCEDURE-TYPE Procedure
42 /* _UIB-PREPROCESSOR-BLOCK-END */
43 &ANALYZE-RESUME
47 /* *********************** Procedure Settings ************************ */
49 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
50 /* Settings for THIS-PROCEDURE
51 Type: Procedure
52 Allow:
53 Frames: 0
54 Add Fields to: Neither
55 Other Settings: CODE-ONLY COMPILE
57 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
59 /* ************************* Create Window ************************** */
61 &ANALYZE-SUSPEND _CREATE-WINDOW
62 /* DESIGN Window definition (used by the UIB)
63 CREATE WINDOW Procedure ASSIGN
64 HEIGHT = .08
65 WIDTH = 32.57.
66 /* END WINDOW DEFINITION */
68 &ANALYZE-RESUME
72 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
73 /* ************************* Included-Libraries *********************** */
75 {inc/method/m-txtrep.i}
77 /* _UIB-CODE-BLOCK-END */
78 &ANALYZE-RESUME
82 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
85 /* *************************** Main Block *************************** */
87 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
89 RUN pclrep-start( preview, "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
91 IF selection-style = "OneClient" THEN RUN for-one-client.
92 ELSE IF selection-style = "CompanyList" THEN RUN for-company-list.
93 ELSE
94 RUN for-each-property.
96 OUTPUT CLOSE.
98 RUN pclrep-finish.
100 /* _UIB-CODE-BLOCK-END */
101 &ANALYZE-RESUME
104 /* ********************** Internal Procedures *********************** */
106 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
107 PROCEDURE each-property :
108 /*------------------------------------------------------------------------------
109 Purpose: Print the building area reconciliation
110 ------------------------------------------------------------------------------*/
111 DEF VAR delim AS CHAR INITIAL "|" NO-UNDO.
112 DEF VAR level-totals AS CHAR NO-UNDO INITIAL ?.
113 DEF VAR last-level AS INT NO-UNDO INITIAL 9876543.
114 DEF VAR level-name AS CHAR NO-UNDO INITIAL "".
116 DEF VAR level-leased AS DECIMAL NO-UNDO INITIAL 0.
117 DEF VAR level-vacant AS DECIMAL NO-UNDO INITIAL 0.
118 DEF VAR level-common AS DECIMAL NO-UNDO INITIAL 0.
120 DEF VAR total-leased AS DECIMAL NO-UNDO INITIAL 0.
121 DEF VAR total-vacant AS DECIMAL NO-UNDO INITIAL 0.
122 DEF VAR total-common AS DECIMAL NO-UNDO INITIAL 0.
123 DEF VAR total-parks AS DECIMAL NO-UNDO INITIAL 0.
125 property-code = Property.PropertyCode.
126 property-name = Property.Name.
128 FOR EACH RentalSpace OF Property NO-LOCK
129 WHERE RentalSpace.AreaStatus <> "X"
130 BY RentalSpace.PropertyCode BY RentalSpace.Level BY RentalSpace.LevelSequence:
132 IF RentalSpace.AreaType = "C" THEN
133 total-parks = total-parks + RentalSpace.AreaSize.
135 RUN test-floor-space( RentalSpace.AreaType, RentalSpace.AreaSize).
136 IF RETURN-VALUE = "Yes" THEN DO:
137 IF RentalSpace.Level <> last-level THEN DO:
138 IF level-totals = ? THEN
139 level-totals = "".
140 ELSE IF level-leased = 0 AND level-vacant = 0 THEN
141 /* do nothing */ .
142 ELSE
143 level-totals = level-totals + (IF level-totals <> "" THEN delim ELSE "")
144 + (IF last-level = 0 THEN " GRD" ELSE STRING( last-level, "->>9"))
145 + STRING( level-leased, ">,>>>,>>9.99")
146 + STRING( level-vacant, ">,>>>,>>9.99")
147 + STRING( level-common, ">,>>>,>>9.99")
148 + STRING( level-leased + level-vacant, ">,>>>,>>9.99").
150 ASSIGN
151 last-level = RentalSpace.level
152 total-vacant = total-vacant + level-vacant
153 total-leased = total-leased + level-leased
154 total-common = total-common + level-common
155 level-vacant = 0
156 level-leased = 0
157 level-common = 0.
158 END.
159 CASE RentalSpace.AreaStatus:
160 WHEN "V" THEN level-vacant = level-vacant + RentalSpace.AreaSize.
161 WHEN "C" THEN level-common = level-common + RentalSpace.AreaSize.
162 OTHERWISE level-leased = level-leased + RentalSpace.AreaSize.
163 END CASE.
164 END.
165 END.
167 IF level-totals = ? THEN
168 level-totals = "".
169 ELSE IF level-leased = 0 AND level-vacant = 0 THEN
170 /* do nothing */ .
171 ELSE
172 level-totals = level-totals + (IF level-totals <> "" THEN delim ELSE "")
173 + (IF last-level = 0 THEN " GRD" ELSE STRING( last-level, "->>9"))
174 + STRING( level-leased, ">,>>>,>>9.99")
175 + STRING( level-vacant, ">,>>>,>>9.99")
176 + STRING( level-common, ">,>>>,>>9.99")
177 + STRING( level-leased + level-vacant, ">,>>>,>>9.99").
179 ASSIGN
180 total-vacant = total-vacant + level-vacant
181 total-leased = total-leased + level-leased
182 total-common = total-common + level-common.
184 DEF VAR i AS INT NO-UNDO.
185 DEF VAR no-of AS INT NO-UNDO.
187 no-of = NUM-ENTRIES( level-totals, delim ).
188 level-totals = level-totals + delim + delim. /* so we don't get errors unstringing */
189 DO i = 1 TO no-of:
190 line = ENTRY( i, level-totals, delim).
191 RUN print-line( line ).
192 END.
194 line = FILL( " ", 4) + FILL( " " + FILL( "-", 11), 4).
195 RUN print-line( line ).
196 line = FILL( " ", 4)
197 + STRING( total-leased, ">,>>>,>>9.99")
198 + STRING( total-vacant, ">,>>>,>>9.99")
199 + STRING( total-common, ">,>>>,>>9.99")
200 + STRING( total-leased + total-vacant, ">,>>>,>>9.99")
201 + " Total car parking: " + STRING( total-parks, "->,>>9" ).
202 RUN print-line( line ).
204 IF total-parks <> Property.TotalParks OR (total-leased + total-vacant) <> Property.TotalArea THEN DO:
205 RUN pclrep-down-by(1).
206 line = "From property file:" + FILL(" ",20)
207 + STRING( Property.TotalArea, "->,>>>,>>9.99")
208 + " car parking: " + STRING( Property.TotalParks, "->,>>9" ).
209 RUN print-line( line ).
210 line = FILL( " ", 4) + FILL( " " + FILL( "-", 11), 4).
211 RUN print-line( line ).
213 total-parks = total-parks - Property.TotalParks.
214 total-leased= total-leased + total-vacant - Property.TotalArea.
215 line = "*** Discrepancy ***" + FILL(" ",20)
216 + STRING( total-leased, "->,>>>,>>9.99")
217 + " car parking: " + STRING( total-parks, "->,>>9" ).
218 RUN print-line( line ).
219 END.
220 line = FILL( " ", 4) + FILL( " " + FILL( "=", 11), 4).
221 RUN print-line( line ).
223 END PROCEDURE.
225 /* _UIB-CODE-BLOCK-END */
226 &ANALYZE-RESUME
229 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-company-list Procedure
230 PROCEDURE for-company-list :
231 /*------------------------------------------------------------------------------
232 Purpose:
233 ------------------------------------------------------------------------------*/
234 DEF VAR i AS INT NO-UNDO.
235 DEF VAR n AS INT NO-UNDO.
236 DEF VAR company-code AS INT NO-UNDO.
238 FIND ConsolidationList WHERE ConsolidationList.Name = company-list NO-LOCK.
239 n = NUM-ENTRIES( ConsolidationList.CompanyList ).
240 DO i = 1 TO n:
241 company-code = INT( ENTRY( i, ConsolidationList.CompanyList ) ).
242 FOR EACH Property WHERE Property.CompanyCode = company-code
243 AND Property.Active NO-LOCK:
244 RUN each-property.
245 END.
246 END.
248 END PROCEDURE.
250 /* _UIB-CODE-BLOCK-END */
251 &ANALYZE-RESUME
254 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-property Procedure
255 PROCEDURE for-each-property :
256 /*------------------------------------------------------------------------------
257 Purpose:
258 ------------------------------------------------------------------------------*/
260 FOR EACH Property WHERE Property.PropertyCode >= property-1
261 AND Property.PropertyCode <= property-n NO-LOCK:
262 RUN each-property.
263 END.
265 END PROCEDURE.
267 /* _UIB-CODE-BLOCK-END */
268 &ANALYZE-RESUME
271 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-one-client Procedure
272 PROCEDURE for-one-client :
273 /*------------------------------------------------------------------------------
274 Purpose:
275 ------------------------------------------------------------------------------*/
277 FOR EACH Company WHERE Company.ClientCode = test-client-code NO-LOCK:
278 FOR EACH Property OF Company WHERE Property.Active NO-LOCK:
279 RUN each-property.
280 END.
281 END.
284 END PROCEDURE.
286 /* _UIB-CODE-BLOCK-END */
287 &ANALYZE-RESUME
290 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
291 PROCEDURE inst-page-footer :
292 /*------------------------------------------------------------------------------
293 Purpose: Print any page footer
294 ------------------------------------------------------------------------------*/
296 END PROCEDURE.
298 /* _UIB-CODE-BLOCK-END */
299 &ANALYZE-RESUME
302 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
303 PROCEDURE inst-page-header :
304 /*------------------------------------------------------------------------------
305 Purpose: Print any page header
306 ------------------------------------------------------------------------------*/
308 RUN pclrep-line( "univers,Point,7,bold,Proportional", TimeStamp).
309 RUN pclrep-line( "univers,Point,12,bold,Proportional",
310 "Building area reconciliation for P"
311 + TRIM(STRING(Property.PropertyCode))
312 + " - "
313 + Property.Name ).
315 RUN pclrep-down-by(2).
317 line = "Level Occupied Vacant Common Total Level Occupied Vacant Common Total Level Occupied Vacant Common Total" .
318 RUN print-line( line ).
319 line = "---------------------------------------------------- ---------------------------------------------------- ----------------------------------------------------" .
320 RUN print-line( line ).
322 RUN pclrep-down-by(1).
324 END PROCEDURE.
326 /* _UIB-CODE-BLOCK-END */
327 &ANALYZE-RESUME
330 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
331 PROCEDURE parse-parameters :
332 /*------------------------------------------------------------------------------
333 Purpose:
334 ------------------------------------------------------------------------------*/
335 DEF VAR token AS CHAR NO-UNDO.
336 DEF VAR i AS INT NO-UNDO.
338 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
339 token = ENTRY( i, report-options, "~n" ).
341 CASE ENTRY( 1, token ):
342 WHEN "Preview" THEN preview = Yes.
343 END CASE.
345 END.
347 END PROCEDURE.
349 /* _UIB-CODE-BLOCK-END */
350 &ANALYZE-RESUME
353 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-line Procedure
354 PROCEDURE print-line :
355 /*------------------------------------------------------------------------------
356 Purpose:
357 Parameters: <none>
358 Notes:
359 ------------------------------------------------------------------------------*/
360 DEFINE INPUT PARAMETER line AS CHARACTER NO-UNDO.
362 RUN pclrep-line("univers,Point,12,bold,Proportional",
363 line).
365 END PROCEDURE.
367 /* _UIB-CODE-BLOCK-END */
368 &ANALYZE-RESUME
371 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE test-floor-space Procedure
372 PROCEDURE test-floor-space :
373 /*------------------------------------------------------------------------------
374 Purpose: Decide if this is actual floor space
375 ------------------------------------------------------------------------------*/
376 DEF INPUT PARAMETER type AS CHAR NO-UNDO.
377 DEF INPUT PARAMETER area AS DECIMAL NO-UNDO.
379 DEF BUFFER LocAreaType FOR AreaType.
381 IF area = ? THEN RETURN "No".
382 FIND LocAreaType WHERE LocAreaType.AreaType = type NO-LOCK NO-ERROR.
383 IF AVAILABLE(LocAreaType) THEN DO:
384 IF LocAreaType.IsCarPark THEN RETURN "Park".
385 IF LocAreaType.IsFloorArea THEN RETURN "Yes".
386 RETURN "No".
387 END.
389 CASE type:
390 WHEN "C" THEN RETURN "Park".
391 WHEN "O" THEN RETURN "Yes".
392 WHEN "R" THEN RETURN "Yes".
393 WHEN "W" THEN RETURN "Yes".
394 WHEN "N" THEN RETURN "No".
395 END CASE.
397 RETURN "No".
399 END PROCEDURE.
401 /* _UIB-CODE-BLOCK-END */
402 &ANALYZE-RESUME