1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
6 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
7 DEF VAR property-1
AS INTEGER NO-UNDO.
8 DEF VAR property-n
AS INTEGER NO-UNDO.
9 DEF VAR show-warnings
AS LOGI
NO-UNDO.
10 DEF VAR show-schedule
AS LOGI
NO-UNDO.
11 DEF VAR show-outgoings
AS LOGI
NO-UNDO.
12 DEF VAR selection-style
AS CHAR NO-UNDO.
13 DEF VAR test-client-code
AS CHAR NO-UNDO INITIAL ?.
14 DEF VAR company-list
AS CHAR NO-UNDO INITIAL ?.
17 DEF VAR need-property-header
AS LOGI
NO-UNDO INITIAL Yes.
18 DEF VAR first-row-for-property
AS INT NO-UNDO INITIAL 3.
19 DEF VAR current-row
AS INT NO-UNDO INITIAL 0.
20 DEF VAR lease-list
AS CHAR NO-UNDO INITIAL "".
22 DEF WORK-TABLE og-acct
NO-UNDO
23 FIELD AccountCode
LIKE ChartOfAccount.AccountCode
24 FIELD ShortName
AS CHAR FORMAT "X(9)"
25 FIELD Recovered
AS DECIMAL
26 FIELD Gross
AS DECIMAL
27 FIELD Vacant
AS DECIMAL.
29 /* _UIB-CODE-BLOCK-END
*/
33 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
35 /* ******************** Preprocessor Definitions
******************** */
37 &Scoped-define PROCEDURE-TYPE Procedure
38 &Scoped-define DB-AWARE no
42 /* _UIB-PREPROCESSOR-BLOCK-END
*/
46 /* ************************ Function Prototypes
********************** */
48 &IF DEFINED(EXCLUDE-check-client) = 0 &THEN
50 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD check-client Procedure
51 FUNCTION check-client
RETURNS LOGICAL
52 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
54 /* _UIB-CODE-BLOCK-END
*/
59 &IF DEFINED(EXCLUDE-get-parent-entity) = 0 &THEN
61 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-parent-entity Procedure
62 FUNCTION get-parent-entity
RETURNS CHARACTER
63 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
65 /* _UIB-CODE-BLOCK-END
*/
70 &IF DEFINED(EXCLUDE-get-prop-og) = 0 &THEN
72 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-prop-og Procedure
73 FUNCTION get-prop-og
RETURNS DECIMAL
74 ( INPUT doit
AS LOGICAL, INPUT pc
AS INTEGER, INPUT ac
AS DECIMAL ) FORWARD.
76 /* _UIB-CODE-BLOCK-END
*/
82 /* *********************** Procedure Settings
************************ */
84 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
85 /* Settings for
THIS-PROCEDURE
89 Add Fields to
: Neither
90 Other Settings
: CODE-ONLY
COMPILE
92 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
94 /* ************************* Create Window
************************** */
96 &ANALYZE-SUSPEND _CREATE-WINDOW
97 /* DESIGN Window definition
(used by the UIB
)
98 CREATE WINDOW Procedure
ASSIGN
101 /* END WINDOW DEFINITION
*/
105 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
106 /* ************************* Included-Libraries
*********************** */
108 {inc
/method
/m-excel.i
}
110 /* _UIB-CODE-BLOCK-END
*/
117 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
120 /* *************************** Main Block
*************************** */
122 RUN begin-spreadsheet.
123 IF RETURN-VALUE = "FAIL" THEN RETURN.
125 IF selection-style
= "OneClient" THEN RUN for-one-client.
126 ELSE IF selection-style
= "CompanyList" THEN RUN for-company-list.
128 RUN for-each-property.
132 /* _UIB-CODE-BLOCK-END
*/
136 /* ********************** Internal Procedures
*********************** */
138 &IF DEFINED(EXCLUDE-begin-spreadsheet) = 0 &THEN
140 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE begin-spreadsheet Procedure
141 PROCEDURE begin-spreadsheet
:
142 /*------------------------------------------------------------------------------
144 ------------------------------------------------------------------------------*/
148 IF NOT VALID-HANDLE( chExcelApplication
) THEN RETURN "FAIL".
156 chWorkSheet
:Columns
("A"):ColumnWidth
= 4.
157 chWorkSheet
:Columns
("B"):ColumnWidth
= 30.
159 IF NOT( show-outgoings
) THEN DO:
160 chWorkSheet
:Columns
("C"):ColumnWidth
= 4.5.
161 chWorkSheet
:Columns
("D"):ColumnWidth
= 4.5.
162 chWorkSheet
:Columns
("E"):ColumnWidth
= 28.
163 chWorkSheet
:Columns
("F"):ColumnWidth
= 8.5.
164 chWorkSheet
:Columns
("G"):ColumnWidth
= 5.5.
165 chWorkSheet
:Columns
("H"):ColumnWidth
= 8.5.
166 chWorkSheet
:Columns
("I"):ColumnWidth
= 12.
/* rental
*/
167 chWorkSheet
:Columns
("J"):ColumnWidth
= 12.
/* rental
*/
168 chWorkSheet
:Columns
("K"):ColumnWidth
= 9.5.
169 chWorkSheet
:Columns
("L"):ColumnWidth
= 12.
/* market rental
*/
170 chWorkSheet
:Columns
("M"):ColumnWidth
= 11.
171 chWorkSheet
:Columns
("N"):ColumnWidth
= 11.
172 chWorkSheet
:Columns
("O"):ColumnWidth
= 9.5.
173 chWorkSheet
:Columns
("P"):ColumnWidth
= 12.
/* review type
*/
174 chWorkSheet
:Columns
("Q"):ColumnWidth
= 12.
/* estimate basis
*/
175 chWorkSheet
:Columns
("R"):ColumnWidth
= 11.
176 chWorkSheet
:Columns
("S"):ColumnWidth
= 11.
177 chWorkSheet
:Columns
("T"):ColumnWidth
= 11.
180 chWorkSheet
:Range
("C:D"):HorizontalAlignment
= {&xlAlignCenter}.
181 chWorkSheet
:Range
("F:L"):HorizontalAlignment
= {&xlAlignRight}.
182 chWorkSheet
:Range
("M:N"):HorizontalAlignment
= {&xlAlignCenter}.
183 chWorkSheet
:Range
("R:T"):HorizontalAlignment
= {&xlAlignCenter}.
187 chWorkSheet
:Range
("C:D"):NumberFormat
= "#0" .
188 chWorkSheet
:Range
("E:E"):NumberFormat
= "#,##0.00" .
189 chWorkSheet
:Range
("G:G"):NumberFormat
= "#0" .
190 chWorkSheet
:Range
("H:L"):NumberFormat
= "#,##0.00" .
191 chWorkSheet
:Range
("M:N"):NumberFormat
= (IF SESSION:DATE-FORMAT = "dmy" THEN "d/m/yyyy" ELSE "m/d/yyyy") .
192 chWorkSheet
:Range
("R:T"):NumberFormat
= (IF SESSION:DATE-FORMAT = "dmy" THEN "d/m/yyyy" ELSE "m/d/yyyy") .
194 set-excel-visible
(Yes
).
199 /* _UIB-CODE-BLOCK-END
*/
204 &IF DEFINED(EXCLUDE-each-property) = 0 &THEN
206 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
207 PROCEDURE each-property
:
208 /*------------------------------------------------------------------------------
210 ------------------------------------------------------------------------------*/
212 IF show-schedule
THEN DO:
213 need-property-header
= Yes.
215 FOR EACH RentalSpace
OF Property
NO-LOCK
216 BY RentalSpace.PropertyCode
BY RentalSpace.Level
BY RentalSpace.LevelSequence
:
217 RUN each-rental-space.
219 IF NOT need-property-header
THEN RUN property-footer.
222 IF show-outgoings
THEN DO:
223 need-property-header
= Yes.
224 RUN outgoings-page
(No
).
229 /* _UIB-CODE-BLOCK-END
*/
234 &IF DEFINED(EXCLUDE-each-rental-space) = 0 &THEN
236 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-rental-space Procedure
237 PROCEDURE each-rental-space
:
238 /*------------------------------------------------------------------------------
240 ------------------------------------------------------------------------------*/
241 DEF VAR tenant-name
AS CHAR NO-UNDO INITIAL "* * * Vacant * * *".
242 DEF VAR contract-rent
AS DEC NO-UNDO INITIAL ?.
243 DEF VAR charged-rent
AS DEC NO-UNDO INITIAL ?.
244 DEF VAR market-rent
AS DEC NO-UNDO INITIAL ?.
245 DEF VAR annual-og
AS DEC NO-UNDO INITIAL ?.
246 DEF VAR lease-expiry
AS INT NO-UNDO INITIAL ?.
247 DEF VAR lease-start
AS INT NO-UNDO INITIAL ?.
248 DEF VAR review-type
AS CHAR NO-UNDO INITIAL ?.
249 DEF VAR review-basis
AS CHAR NO-UNDO INITIAL ?.
250 DEF VAR rent-review
AS INT EXTENT 3 NO-UNDO INITIAL ?.
251 DEF VAR renewals
AS CHAR NO-UNDO INITIAL ?.
252 DEF VAR lease-code
AS CHAR NO-UNDO.
253 DEF VAR done-this-lease
AS LOGI
NO-UNDO.
255 FIND AreaType
OF RentalSpace
NO-LOCK NO-ERROR.
256 IF NOT AVAILABLE(AreaType
) THEN DO:
257 IF show-warnings
THEN
258 MESSAGE "Cannot find area type of '" + RentalSpace.AreaType
+ "' for Property" Property.PropertyCode
"level" RentalSpace.Level
"sequence" RentalSpace.LevelSequence
SKIP
259 "Description: " RentalSpace.Description
260 VIEW-AS ALERT-BOX ERROR
261 TITLE "Unknown Area Type".
265 market-rent
= RentalSpace.MarketRental .
266 IF RentalSpace.AreaStatus
= "L" THEN DO:
267 FIND TenancyLease
OF RentalSpace
WHERE TenancyLease.LeaseStatus
<> "PAST" NO-LOCK NO-ERROR.
268 IF AVAILABLE(TenancyLease
) THEN
269 lease-code
= STRING(TenancyLease.TenancyLeaseCode
).
271 lease-code
= "unknown".
272 IF show-warnings
THEN DO:
273 MESSAGE "Property:" Property.Name
SKIP
274 "Area:" RentalSpace.Description
"(" + STRING(RentalSpace.Level
) + "/" + STRING(RentalSpace.LevelSequence
) + ")" SKIP
275 "Area is marked as leased (status of 'L') but no current lease found."
276 VIEW-AS ALERT-BOX WARNING.
279 done-this-lease
= (LOOKUP( lease-code
, lease-list
) > 0).
280 IF NOT( done-this-lease
) THEN
281 lease-list
= lease-list
+ (IF lease-list
= "" THEN "" ELSE ",") + lease-code.
283 IF AVAILABLE(TenancyLease
) THEN DO:
284 FIND Tenant
OF TenancyLease
NO-LOCK NO-ERROR.
285 IF AVAILABLE(Tenant
) THEN DO:
286 contract-rent
= RentalSpace.ContractedRental .
287 charged-rent
= RentalSpace.ChargedRental.
288 IF NOT( done-this-lease
) THEN annual-og
= TenancyLease.OutgoingsBudget .
289 tenant-name
= Tenant.Name.
290 lease-expiry
= excel-date
( TenancyLease.LeaseEndDate
, 0.0 ).
291 lease-start
= excel-date
( TenancyLease.LeaseStartDate
, 0.0 ).
292 renewals
= TenancyLease.RightsOfRenewal .
294 /* find three rent reviews
, if we can
*/
295 FIND FIRST RentReview
OF TenancyLease
WHERE RentReview.DateDue
> DATE( 1, 1, 1990)
296 AND RentReview.ReviewStatus
<> "DONE" NO-LOCK NO-ERROR.
297 IF AVAILABLE(RentReview
) THEN DO:
298 review-type
= RentReview.ReviewType.
299 review-basis
= RentReview.EstimateBasis.
300 rent-review
[1] = excel-date
( RentReview.DateDue
, 0.0 ).
301 FIND NEXT RentReview
OF TenancyLease
WHERE RentReview.DateDue
> DATE( 1, 1, 1990)
302 AND RentReview.ReviewStatus
<> "DONE" NO-LOCK NO-ERROR.
303 IF AVAILABLE(RentReview
) THEN DO:
304 rent-review
[2] = excel-date
( RentReview.DateDue
, 0.0 ).
305 FIND NEXT RentReview
OF TenancyLease
WHERE RentReview.DateDue
> DATE( 1, 1, 1990)
306 AND RentReview.ReviewStatus
<> "DONE" NO-LOCK NO-ERROR.
307 IF AVAILABLE(RentReview
) THEN DO:
308 rent-review
[3] = excel-date
( RentReview.DateDue
, 0.0 ).
316 IF need-property-header
THEN DO:
318 first-row-for-property
= current-row
+ 1.
321 current-row
= current-row
+ 1.
323 chWorkSheet
:Cells
(current-row
,2):Value
= tenant-name.
324 chWorkSheet
:Cells
(current-row
,3):Value
= RentalSpace.Level.
325 chWorkSheet
:Cells
(current-row
,4):Value
= RentalSpace.LevelSequence.
326 chWorkSheet
:Cells
(current-row
,5):Value
= RentalSpace.Description.
327 IF AreaType.IsFloorArea
THEN
328 chWorkSheet
:Cells
(current-row
,6):Value
= RentalSpace.AreaSize.
329 ELSE IF AreaType.IsCarPark
THEN
330 chWorkSheet
:Cells
(current-row
,7):Value
= RentalSpace.AreaSize.
332 chWorkSheet
:Cells
(current-row
,8):Value
= RentalSpace.AreaSize.
334 IF contract-rent
<> ?
THEN chWorkSheet
:Cells
(current-row
,9):Value
= contract-rent.
335 IF charged-rent
<> ?
THEN chWorkSheet
:Cells
(current-row
,10):Value
= charged-rent.
336 IF annual-og
<> ?
THEN chWorkSheet
:Cells
(current-row
,11):Value
= annual-og.
337 IF market-rent
<> ?
THEN chWorkSheet
:Cells
(current-row
,12):Value
= market-rent.
338 IF lease-start
<> ?
THEN chWorkSheet
:Cells
(current-row
,13):Value
= lease-start.
339 IF lease-expiry
<> ?
THEN chWorkSheet
:Cells
(current-row
,14):Value
= lease-expiry.
340 IF renewals
<> ?
THEN chWorkSheet
:Cells
(current-row
,15):Value
= renewals.
341 IF review-type
<> ?
THEN chWorkSheet
:Cells
(current-row
,16):Value
= review-type .
342 IF review-basis
<> ?
THEN chWorkSheet
:Cells
(current-row
,17):Value
= review-basis .
343 IF rent-review
[1] <> ?
THEN chWorkSheet
:Cells
(current-row
,18):Value
= rent-review
[1] .
344 IF rent-review
[2] <> ?
THEN chWorkSheet
:Cells
(current-row
,19):Value
= rent-review
[2] .
345 IF rent-review
[3] <> ?
THEN chWorkSheet
:Cells
(current-row
,20):Value
= rent-review
[3] .
349 /* _UIB-CODE-BLOCK-END
*/
354 &IF DEFINED(EXCLUDE-end-spreadsheet) = 0 &THEN
356 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE end-spreadsheet Procedure
357 PROCEDURE end-spreadsheet
:
358 /*------------------------------------------------------------------------------
360 ------------------------------------------------------------------------------*/
366 /* _UIB-CODE-BLOCK-END
*/
371 &IF DEFINED(EXCLUDE-for-company-list) = 0 &THEN
373 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-company-list Procedure
374 PROCEDURE for-company-list
:
375 /*------------------------------------------------------------------------------
377 ------------------------------------------------------------------------------*/
378 DEF VAR i
AS INT NO-UNDO.
379 DEF VAR n
AS INT NO-UNDO.
380 DEF VAR company-code
AS INT NO-UNDO.
382 FIND ConsolidationList
WHERE ConsolidationList.Name
= company-list
NO-LOCK.
383 n
= NUM-ENTRIES( ConsolidationList.CompanyList
).
385 company-code
= INT( ENTRY( i
, ConsolidationList.CompanyList
) ).
386 FOR EACH Property
WHERE Property.CompanyCode
= company-code
NO-LOCK:
393 /* _UIB-CODE-BLOCK-END
*/
398 &IF DEFINED(EXCLUDE-for-each-property) = 0 &THEN
400 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-property Procedure
401 PROCEDURE for-each-property
:
402 /*------------------------------------------------------------------------------
404 ------------------------------------------------------------------------------*/
405 FOR EACH Property
WHERE Property.Active
AND Property.PropertyCode
>= property-1
406 AND Property.PropertyCode
<= property-n
NO-LOCK:
412 /* _UIB-CODE-BLOCK-END
*/
417 &IF DEFINED(EXCLUDE-for-one-client) = 0 &THEN
419 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-one-client Procedure
420 PROCEDURE for-one-client
:
421 /*------------------------------------------------------------------------------
423 ------------------------------------------------------------------------------*/
424 FOR EACH Company
WHERE Company.ClientCode
= test-client-code
NO-LOCK:
425 FOR EACH Property
OF Company
NO-LOCK:
432 /* _UIB-CODE-BLOCK-END
*/
437 &IF DEFINED(EXCLUDE-outgoings-header) = 0 &THEN
439 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE outgoings-header Procedure
440 PROCEDURE outgoings-header
:
441 /*------------------------------------------------------------------------------
442 Purpose
: Assign the column headings of the spreadsheet
443 ------------------------------------------------------------------------------*/
444 DEF VAR i
AS INT NO-UNDO.
446 need-property-header
= No.
448 current-row
= current-row
+ 1.
450 chWorkSheet
:Cells
(current-row
,1):Value
= Property.PropertyCode
451 chWorkSheet
:Cells
(current-row
,1):HorizontalAlignment
= {&xlAlignRight}
452 chWorkSheet
:Cells
(current-row
,2):Value
= Property.Name
453 chWorkSheet
:Cells
(current-row
,2):HorizontalAlignment
= {&xlAlignLeft}
454 chWorkSheet
:Cells
(current-row
,4):Value
= "Outgoings"
455 chWorkSheet
:Cells
(current-row
,4):HorizontalAlignment
= {&xlAlignLeft}
458 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Name
= "Arial".
459 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Size
= 11.
460 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Bold
= Yes.
462 current-row
= current-row
+ 1.
463 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Bold
= Yes.
465 FOR EACH og-acct
NO-LOCK:
466 chWorkSheet
:Cells
(current-row
, i
):Value
= og-acct.AccountCode .
467 chWorkSheet
:Cells
(current-row
, i
):NumberFormat
= "0000.00".
468 chWorkSheet
:Cells
(current-row
, i
):HorizontalAlignment
= {&xlAlignLeft}.
472 current-row
= current-row
+ 1.
473 chWorkSheet
:Cells
(current-row
,2):Value
= "Tenant".
474 chWorkSheet
:Cells
(current-row
,3):Value
= "Area".
475 chWorkSheet
:Cells
(current-row
,3):HorizontalAlignment
= {&xlAlignLeft}.
476 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Bold
= Yes.
478 FOR EACH og-acct
NO-LOCK:
479 chWorkSheet
:Cells
(current-row
, i
):Value
= og-acct.ShortName .
480 chWorkSheet
:Cells
(current-row
, i
):NumberFormat
= "General".
481 chWorkSheet
:Cells
(current-row
, i
):HorizontalAlignment
= {&xlAlignCenter}.
486 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Name
= "Arial".
487 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Bold
= Yes.
489 /* chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Style
:Name
= "Heading-2".
*/
493 /* _UIB-CODE-BLOCK-END
*/
498 &IF DEFINED(EXCLUDE-outgoings-page) = 0 &THEN
500 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE outgoings-page Procedure
501 PROCEDURE outgoings-page
:
502 /*------------------------------------------------------------------------------
503 Purpose
: Print outgoings information for the leases
/spaces of the property
504 ------------------------------------------------------------------------------*/
505 DEF INPUT PARAMETER times-amt
AS LOGICAL NO-UNDO.
507 DEF VAR out-line
AS CHAR NO-UNDO.
508 DEF VAR no-accounts
AS INTEGER NO-UNDO.
509 DEF VAR i
AS INTEGER NO-UNDO.
510 DEF VAR percentage
AS DECIMAL NO-UNDO.
511 DEF VAR acct-amnt
AS DECIMAL NO-UNDO.
512 DEF VAR non-zero
AS LOGICAL NO-UNDO.
513 DEF VAR top-line
AS INT NO-UNDO.
514 DEF VAR c1
AS CHAR NO-UNDO.
515 DEF VAR c2
AS CHAR NO-UNDO.
516 DEF VAR r1
AS CHAR NO-UNDO.
517 DEF VAR r2
AS CHAR NO-UNDO.
518 DEF VAR r-rec
AS CHAR NO-UNDO.
519 DEF VAR r-grs
AS CHAR NO-UNDO.
520 DEF VAR r-vac
AS CHAR NO-UNDO.
522 DEF BUFFER PrimarySpace
FOR RentalSpace.
525 FOR EACH PropertyOutgoing
NO-LOCK OF Property
:
526 no-accounts
= no-accounts
+ 1.
527 FIND ChartOfAccount
WHERE ChartOfAccount.AccountCode
= PropertyOutgoing.AccountCode
NO-LOCK NO-ERROR.
530 og-acct.AccountCode
= PropertyOutgoing.AccountCode
531 og-acct.ShortName
= (IF AVAILABLE(ChartOfAccount
) THEN STRING( (IF TRIM(ChartOfAccount.ShortName
) <> "" THEN ChartOfAccount.ShortName
ELSE ChartOfAccount.Name
), "X(7)") ELSE "???????")
532 og-acct.Recovered
= 0
535 og-acct.ShortName
= TRIM(og-acct.ShortName
).
536 og-acct.ShortName
= FILL( " ", 7 - LENGTH(og-acct.ShortName
)) + og-acct.ShortName .
538 FOR EACH TenancyLease
NO-LOCK OF Property
WHERE TenancyLease.LeaseStatus
<> "PAST",
539 EACH TenancyOutgoing
NO-LOCK OF TenancyLease
WHERE TenancyOutgoing.Percentage
> 0:
540 FIND FIRST og-acct
WHERE og-acct.AccountCode
= TenancyOutgoing.AccountCode
NO-ERROR.
541 IF AVAILABLE(og-acct
) THEN
542 og-acct.Recovered
= og-acct.Recovered
+ TenancyOutgoing.Percentage.
544 no-accounts
= no-accounts
+ 1.
545 FIND ChartOfAccount
WHERE ChartOfAccount.AccountCode
= TenancyOutgoing.AccountCode
NO-LOCK NO-ERROR.
548 og-acct.AccountCode
= TenancyOutgoing.AccountCode
549 og-acct.ShortName
= (IF AVAILABLE(ChartOfAccount
) THEN STRING( (IF TRIM(ChartOfAccount.ShortName
) <> "" THEN ChartOfAccount.ShortName
ELSE ChartOfAccount.Name
), "X(7)") ELSE "???????")
550 og-acct.Recovered
= TenancyOutgoing.Percentage
553 og-acct.ShortName
= TRIM(og-acct.ShortName
).
557 /* fill in those where a default percentage applies from the lease record
*/
558 FOR EACH TenancyLease
NO-LOCK OF Property
WHERE TenancyLease.LeaseStatus
<> "PAST",
559 EACH og-acct
WHERE NOT CAN-FIND( FIRST TenancyOutgoing
OF TenancyLease
WHERE TenancyOutgoing.AccountCode
= og-acct.AccountCode
):
560 og-acct.Recovered
= og-acct.Recovered
+ TenancyLease.OutgoingsRate .
563 IF need-property-header
THEN RUN outgoings-header.
566 top-line
= current-row
+ 1.
567 FOR EACH TenancyLease
NO-LOCK OF Property
WHERE TenancyLease.LeaseStatus
<> "PAST"
568 AND NOT TenancyLease.GrossLease
,
569 FIRST PrimarySpace
OF TenancyLease
/* WHERE PrimarySpace.RentalSpaceCode
= TenancyLease.PrimarySpace
*/
570 BY PrimarySpace.Level
BY PrimarySpace.LevelSequence
:
571 FIND Tenant
WHERE Tenant.TenantCode
= TenancyLease.TenantCode
NO-LOCK NO-ERROR.
573 current-row
= current-row
+ 1.
575 chWorkSheet
:Cells
(current-row
,2):Value
= Tenant.Name .
576 chWorkSheet
:Cells
(current-row
,3):Value
= TenancyLease.AreaDescription .
577 FOR EACH og-acct
BY og-acct.AccountCode
:
578 FIND TenancyOutgoing
NO-LOCK OF TenancyLease
WHERE TenancyOutgoing.AccountCode
= og-acct.AccountCode
NO-ERROR.
579 percentage
= (IF AVAILABLE(TenancyOutgoing
) THEN TenancyOutgoing.Percentage
ELSE TenancyLease.OutgoingsRate
).
580 IF percentage
= ?
THEN percentage
= 0.
581 IF percentage
<> 0 THEN DO:
583 chWorkSheet
:Cells
(current-row
,i
):Value
= percentage
/ 100.
584 chWorkSheet
:Cells
(current-row
,i
):NumberFormat
= "#,##0.00%".
590 r1
= STRING(top-line
).
591 IF top-line
> current-row
THEN current-row
= top-line.
592 r2
= STRING(current-row
).
593 current-row
= current-row
+ 1.
594 chWorkSheet
:Cells
(current-row
,2):Value
= "Total Recoverable".
596 c1
= int-to-column
(i
).
597 FOR EACH og-acct
BY og-acct.AccountCode
:
598 c2
= int-to-column
(i
).
599 chWorkSheet
:Cells
(current-row
,i
):Value
= "=SUM(" + c2
+ r1
+ ":" + c2
+ r2
+ ")".
602 r2
= STRING(current-row
).
604 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):NumberFormat
= "#,##0.00%".
605 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):Borders
({&xlEdgeTop}):LineStyle = {&xlContinuous} .
609 current-row
= current-row
+ 2.
610 top-line
= current-row
+ 1.
611 FOR EACH TenancyLease
NO-LOCK OF Property
WHERE TenancyLease.LeaseStatus
<> "PAST"
612 AND TenancyLease.GrossLease
,
613 FIRST PrimarySpace
OF TenancyLease
/* WHERE PrimarySpace.RentalSpaceCode
= TenancyLease.PrimarySpace
*/
614 BY PrimarySpace.Level
BY PrimarySpace.LevelSequence
:
615 FIND Tenant
WHERE Tenant.TenantCode
= TenancyLease.TenantCode
NO-LOCK NO-ERROR.
618 FOR EACH RentalSpace
OF TenancyLease
:
619 percentage
= percentage
+ RentalSpace.OutgoingsPercentage.
621 IF percentage
= 0 THEN NEXT.
623 current-row
= current-row
+ 1.
625 chWorkSheet
:Cells
(current-row
,2):Value
= Tenant.Name .
626 chWorkSheet
:Cells
(current-row
,3):Value
= TenancyLease.AreaDescription .
627 FOR EACH og-acct
BY og-acct.AccountCode
:
628 IF percentage
<> 0 THEN DO:
630 chWorkSheet
:Cells
(current-row
,i
):Value
= percentage
/ 100.
631 chWorkSheet
:Cells
(current-row
,i
):NumberFormat
= "#,##0.00%".
632 og-acct.Gross
= og-acct.Gross
+ percentage.
638 r1
= STRING(top-line
).
639 IF top-line
> current-row
THEN current-row
= top-line.
640 r2
= STRING(current-row
).
641 current-row
= current-row
+ 1.
642 chWorkSheet
:Cells
(current-row
,2):Value
= "Total Gross Leases".
644 c1
= int-to-column
(i
).
645 FOR EACH og-acct
BY og-acct.AccountCode
:
646 c2
= int-to-column
(i
).
647 chWorkSheet
:Cells
(current-row
,i
):Value
= "=SUM(" + c2
+ r1
+ ":" + c2
+ r2
+ ")".
650 r2
= STRING(current-row
).
652 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):NumberFormat
= "#,##0.00%".
653 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):Borders
({&xlEdgeTop}):LineStyle = {&xlContinuous} .
656 current-row
= current-row
+ 2.
657 top-line
= current-row
+ 1.
658 FOR EACH RentalSpace
NO-LOCK OF Property
WHERE RentalSpace.AreaStatus
= "V"
659 AND RentalSpace.OutgoingsPercentage
<> 0
660 BY Level
BY LevelSequence
:
661 current-row
= current-row
+ 1.
663 chWorkSheet
:Cells
(current-row
,2):Value
= "Level " + TRIM( STRING( RentalSpace.Level
, "->>>9/")) + TRIM( STRING( RentalSpace.LevelSequence
, ">>>9 ")) .
664 chWorkSheet
:Cells
(current-row
,3):Value
= RentalSpace.Description .
666 FOR EACH og-acct
BY og-acct.AccountCode
:
667 percentage
= RentalSpace.OutgoingsPercentage
* get-prop-og
( times-amt
, Property.PropertyCode
, og-acct.AccountCode
).
668 IF percentage
<> 0 THEN DO:
670 chWorkSheet
:Cells
(current-row
,i
):Value
= percentage
/ 100.
671 chWorkSheet
:Cells
(current-row
,i
):NumberFormat
= "#,##0.00%".
672 og-acct.Vacant
= og-acct.Vacant
+ RentalSpace.OutgoingsPercentage.
678 r1
= STRING(top-line
).
679 IF top-line
> current-row
THEN current-row
= top-line.
680 r2
= STRING(current-row
).
681 current-row
= current-row
+ 1.
682 chWorkSheet
:Cells
(current-row
,2):Value
= "Total Vacant".
684 c1
= int-to-column
(i
).
685 FOR EACH og-acct
BY og-acct.AccountCode
:
686 c2
= int-to-column
(i
).
687 chWorkSheet
:Cells
(current-row
,i
):Value
= "=SUM(" + c2
+ r1
+ ":" + c2
+ r2
+ ")".
690 r2
= STRING(current-row
).
692 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):NumberFormat
= "#,##0.00%".
693 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):Borders
({&xlEdgeTop}):LineStyle = {&xlContinuous} .
695 current-row
= current-row
+ 2.
696 chWorkSheet
:Cells
(current-row
,2):Value
= "Grand Total".
698 c1
= int-to-column
(i
).
699 FOR EACH og-acct
BY og-acct.AccountCode
:
700 c2
= int-to-column
(i
).
701 chWorkSheet
:Cells
(current-row
,i
):Value
= "=" + c2
+ r-rec
+ "+" + c2
+ r-grs
+ "+" + c2
+ r-vac.
704 r2
= STRING(current-row
).
706 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):NumberFormat
= "#,##0.00%".
707 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):Borders
({&xlEdgeTop}):LineStyle = {&xlContinuous} .
709 current-row
= current-row
+ 1.
710 ASSIGN chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):PageBreak
= {&xlPageBreakManual} NO-ERROR.
714 /* _UIB-CODE-BLOCK-END
*/
719 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
721 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
722 PROCEDURE parse-parameters
:
723 /*------------------------------------------------------------------------------
725 ------------------------------------------------------------------------------*/
726 DEF VAR i
AS INT NO-UNDO.
727 DEF VAR token
AS CHAR NO-UNDO.
729 {inc
/showopts.i
"report-options"}
731 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
732 token
= ENTRY( i
, report-options
, "~n" ).
734 CASE( ENTRY( 1, token
) ):
735 WHEN "Properties" THEN ASSIGN
736 property-1
= INT( ENTRY(2,token
) )
737 property-n
= INT( ENTRY(3,token
) ).
739 WHEN "Client" THEN test-client-code
= ENTRY(2,token
).
740 WHEN "CompanyList" THEN company-list
= ENTRY(2,token
).
741 WHEN "Selection" THEN selection-style
= ENTRY(2,token
).
742 WHEN "Warnings" THEN show-warnings
= ENTRY(2,token
) BEGINS "Y".
743 WHEN "Main Schedule" THEN show-schedule
= ENTRY(2,token
) BEGINS "Y".
744 WHEN "Outgoings" THEN show-outgoings
= ENTRY(2,token
) BEGINS "Y".
748 IF property-n
< property-1
THEN property-n
= property-1.
749 IF selection-style
= "AP" THEN ASSIGN
752 ELSE IF selection-style
= "1P" THEN ASSIGN
753 property-n
= property-1.
757 /* _UIB-CODE-BLOCK-END
*/
762 &IF DEFINED(EXCLUDE-property-footer) = 0 &THEN
764 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-footer Procedure
765 PROCEDURE property-footer
:
766 /*------------------------------------------------------------------------------
767 Purpose
: If we need something after each property
768 ------------------------------------------------------------------------------*/
769 DEF VAR r1
AS CHAR NO-UNDO.
770 DEF VAR r2
AS CHAR NO-UNDO.
772 r1
= STRING(first-row-for-property
).
773 r2
= STRING(current-row
).
774 current-row
= current-row
+ 1.
775 chWorkSheet
:Cells
(current-row
,6):Value
= "=SUM(F" + r1
+ ":F" + r2
+ ")".
776 chWorkSheet
:Cells
(current-row
,7):Value
= "=SUM(G" + r1
+ ":G" + r2
+ ")".
777 chWorkSheet
:Cells
(current-row
,8):Value
= "=SUM(H" + r1
+ ":H" + r2
+ ")".
778 chWorkSheet
:Cells
(current-row
,9):Value
= "=SUM(I" + r1
+ ":I" + r2
+ ")".
779 chWorkSheet
:Cells
(current-row
,10):Value
= "=SUM(J" + r1
+ ":J" + r2
+ ")".
780 chWorkSheet
:Cells
(current-row
,11):Value
= "=SUM(K" + r1
+ ":K" + r2
+ ")".
782 r1
= STRING(current-row
).
783 chWorkSheet
:Range
( "F" + r1
+ ":K" + r1
):Font
:Bold
= Yes.
784 chWorkSheet
:Range
( "F" + r1
+ ":K" + r1
):Borders
({&xlEdgeTop}):LineStyle = {&xlContinuous} .
786 current-row
= current-row
+ 1.
787 ASSIGN chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):PageBreak
= {&xlPageBreakManual} NO-ERROR.
791 /* _UIB-CODE-BLOCK-END
*/
796 &IF DEFINED(EXCLUDE-property-header) = 0 &THEN
798 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-header Procedure
799 PROCEDURE property-header
:
800 /*------------------------------------------------------------------------------
801 Purpose
: Assign the column headings of the spreadsheet
802 ------------------------------------------------------------------------------*/
803 need-property-header
= No.
805 current-row
= current-row
+ 1.
807 chWorkSheet
:Cells
(current-row
,1):Value
= Property.PropertyCode
808 chWorkSheet
:Cells
(current-row
,1):HorizontalAlignment
= 4 /* Right
*/
809 chWorkSheet
:Cells
(current-row
,2):Value
= Property.Name
810 chWorkSheet
:Cells
(current-row
,2):HorizontalAlignment
= 2 /* Left
*/
813 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Name
= "Arial".
814 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Size
= 11.
815 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Bold
= Yes.
817 current-row
= current-row
+ 1.
819 chWorkSheet
:Cells
(current-row
,2):Value
= "Tenant"
820 chWorkSheet
:Cells
(current-row
,3):Value
= "Level"
821 chWorkSheet
:Cells
(current-row
,4):Value
= "Suite"
822 chWorkSheet
:Cells
(current-row
,5):Value
= "Area rented"
823 chWorkSheet
:Cells
(current-row
,6):Value
= "Floor"
824 chWorkSheet
:Cells
(current-row
,7):Value
= "Parks"
825 chWorkSheet
:Cells
(current-row
,8):Value
= "Other"
826 chWorkSheet
:Cells
(current-row
,9):Value
= "Contracted"
827 chWorkSheet
:Cells
(current-row
,9):Value
= "Charged"
828 chWorkSheet
:Cells
(current-row
,11):Value
= "Outgoings"
829 chWorkSheet
:Cells
(current-row
,12):Value
= "EAR"
830 chWorkSheet
:Cells
(current-row
,13):Value
= "Commence"
831 chWorkSheet
:Cells
(current-row
,14):Value
= "Expiry"
832 chWorkSheet
:Cells
(current-row
,15):Value
= "Renewals"
833 chWorkSheet
:Cells
(current-row
,16):Value
= "Review Type"
834 chWorkSheet
:Cells
(current-row
,18):Value
= "Basis"
835 chWorkSheet
:Cells
(current-row
,18):Value
= "Reviews"
838 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Name
= "Arial".
839 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Bold
= Yes.
841 /* chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Style
:Name
= "Heading-2".
*/
845 /* _UIB-CODE-BLOCK-END
*/
850 &IF DEFINED(EXCLUDE-setup-workbook) = 0 &THEN
852 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE setup-workbook Procedure
853 PROCEDURE setup-workbook
:
854 /*------------------------------------------------------------------------------
856 ------------------------------------------------------------------------------*/
857 chWorkSheet
:PageSetup
:Orientation
= {&xlLandscape}.
858 chWorkSheet
:PageSetup
:LeftMargin
= 24.
859 chWorkSheet
:PageSetup
:RightMargin
= 24.
860 chWorkSheet
:PageSetup
:TopMargin
= 60.
861 chWorkSheet
:PageSetup
:BottomMargin
= 24.
863 chWorkBook
:Styles
("Normal"):Font
:Size
= 8.
864 chWorkBook
:Styles
("Normal"):Font
:Name
= "Times New Roman".
866 chWorkBook
:Styles
:Add
("Heading-1").
867 chWorkBook
:Styles
("Heading-1"):Font
:Size
= 11.
868 chWorkBook
:Styles
("Heading-1"):Font
:Name
= "Arial".
869 chWorkBook
:Styles
("Heading-1"):Font
:Bold
= True.
871 chWorkBook
:Styles
:Add
("Heading-2").
872 chWorkBook
:Styles
("Heading-2"):Font
:Name
= "Arial".
873 chWorkBook
:Styles
("Heading-2"):Font
:Bold
= True.
875 chWorkBook
:Styles
:Add
("Prop-Total").
876 chWorkBook
:Styles
("Prop-Total"):Font
:Name
= "Arial".
877 chWorkBook
:Styles
("Prop-Total"):Font
:Bold
= True.
881 /* _UIB-CODE-BLOCK-END
*/
886 /* ************************ Function Implementations
***************** */
888 &IF DEFINED(EXCLUDE-check-client) = 0 &THEN
890 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION check-client Procedure
891 FUNCTION check-client
RETURNS LOGICAL
892 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
893 /*------------------------------------------------------------------------------
894 Purpose
: Decide whether this is for the client who receives
895 expenses for this entity type
/ entity code.
896 ------------------------------------------------------------------------------*/
897 DEF VAR entity-code
AS CHAR NO-UNDO.
898 DEF VAR result
AS LOGI
NO-UNDO.
900 IF test-client-code
= ?
THEN RETURN Yes.
903 entity-code
= get-parent-entity
( et
, ec
).
904 et
= SUBSTRING( entity-code
, 1, 1).
905 ec
= INT( SUBSTRING( entity-code
, 2) ).
908 FIND Company
WHERE Company.CompanyCode
= ec
NO-LOCK NO-ERROR.
909 result
= (Company.ClientCode
= test-client-code
).
915 /* _UIB-CODE-BLOCK-END
*/
920 &IF DEFINED(EXCLUDE-get-parent-entity) = 0 &THEN
922 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-parent-entity Procedure
923 FUNCTION get-parent-entity
RETURNS CHARACTER
924 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
925 /*------------------------------------------------------------------------------
928 ------------------------------------------------------------------------------*/
929 DEF VAR parent-entity
AS CHAR NO-UNDO.
933 FIND Project
WHERE Project.ProjectCode
= ec
NO-LOCK NO-ERROR.
934 parent-entity
= Project.EntityType
+ STRING( Project.EntityCode
, "99999").
937 FIND Property
WHERE Property.PropertyCode
= ec
NO-LOCK NO-ERROR.
938 parent-entity
= "L" + STRING( Property.CompanyCode
, "99999").
941 FIND Tenant
WHERE Tenant.TenantCode
= ec
NO-LOCK NO-ERROR.
942 parent-entity
= Tenant.EntityType
+ STRING( Tenant.EntityCode
, "99999").
945 FIND Creditor
WHERE Creditor.CreditorCode
= ec
NO-LOCK NO-ERROR.
946 parent-entity
= "L" + STRING( Creditor.CompanyCode
, "99999").
950 RETURN parent-entity.
954 /* _UIB-CODE-BLOCK-END
*/
959 &IF DEFINED(EXCLUDE-get-prop-og) = 0 &THEN
961 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-prop-og Procedure
962 FUNCTION get-prop-og
RETURNS DECIMAL
963 ( INPUT doit
AS LOGICAL, INPUT pc
AS INTEGER, INPUT ac
AS DECIMAL ) :
964 /*------------------------------------------------------------------------------
967 ------------------------------------------------------------------------------*/
968 IF doit
<> Yes
THEN RETURN 1.0 .
969 FIND PropertyOutgoing
WHERE PropertyOutgoing.PropertyCode
= pc
970 AND PropertyOutgoing.AccountCode
= ac
NO-LOCK NO-ERROR.
971 IF AVAILABLE(PropertyOutgoing
) THEN
972 RETURN PropertyOutgoing.BudgetAmount
/ 100 .
978 /* _UIB-CODE-BLOCK-END
*/