1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
10 ------------------------------------------------------------------------*/
11 /* *************************** Definitions
************************** */
12 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
13 DEF INPUT PARAMETER preview
AS LOGI
NO-UNDO.
17 {inc
/ofc-set-l.i
"Use-Rent-Charges" "use-rent-charges"}
18 {inc
/ofc-set.i
"RentCharge-Outgoings" "og-rentcharge-type"}
19 IF NOT AVAILABLE(OfficeSetting
) THEN og-rentcharge-type
= "".
22 DEF VAR prt-ctrl
AS CHAR NO-UNDO.
23 DEF VAR cols
AS INT NO-UNDO.
24 DEF VAR rows
AS INT NO-UNDO.
25 DEF VAR rent-report
AS LOGICAL NO-UNDO.
26 DEF VAR detail-report
AS LOGICAL NO-UNDO.
27 DEF VAR include-external
AS LOGICAL NO-UNDO.
28 rent-report
= (SUBSTRING(report-options
, 1, 1) = "R").
29 detail-report
= (SUBSTRING(report-options
, 2, 1) = "D").
30 include-external
= NOT (SUBSTRING(report-options
, 3, 1) = "X").
32 /* tenant accumulators
*/
33 DEF VAR tenant-contract
AS DECIMAL NO-UNDO.
34 DEF VAR tenant-charged
AS DECIMAL NO-UNDO.
35 DEF VAR last-tenant-code
AS INTEGER INITIAL -1 NO-UNDO.
36 DEF VAR user-name
AS CHAR NO-UNDO.
37 {inc
/username.i
"user-name"}
40 &SCOPED-DEFINE page-width 126
41 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
43 DEF VAR timeStamp
AS CHAR FORMAT "X(40)" NO-UNDO.
44 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
45 DEF VAR hline2
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
46 DEF VAR hline3
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
47 hline2
= "Trans Tasman Properties Limited".
48 hline2
= SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
49 hline3
= (IF rent-report
THEN "Rental" ELSE "Outgoings") + " Summary Report".
50 hline3
= SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline3) ) / 2)) + hline3.
52 DEF VAR column-headings
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
54 column-headings
= FILL(' '
,51) + " Contract Charged Variance".
56 column-headings
= FILL(' '
,51) + " Outgoings".
58 DEFINE FRAME heading-frame
WITH 1 DOWN {&with-clause} PAGE-TOP.
60 timeStamp
"Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
61 hline2
FORMAT "X({&page-width})"
62 hline3
FORMAT "X({&page-width})"
63 SKIP (2) column-headings
64 WITH FRAME heading-frame.
66 DEF VAR contract-amount
AS DECIMAL FORMAT "->>>,>>>,>>9.99" COLUMN-LABEL "Contract" NO-UNDO.
67 DEF VAR charged-rent
AS DECIMAL FORMAT "->>>,>>>,>>9.99" COLUMN-LABEL "Charged" NO-UNDO.
68 DEF VAR variance
AS DECIMAL FORMAT "->>,>>>,>>9.99" COLUMN-LABEL "Variance" NO-UNDO.
69 DEFINE FRAME report-line
WITH DOWN {&with-clause}.
70 FORM Property.Name contract-amount charged-rent variance
WITH FRAME report-line.
72 /* _UIB-CODE-BLOCK-END
*/
76 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
78 /* ******************** Preprocessor Definitions
******************** */
80 &Scoped-define PROCEDURE-TYPE Procedure
84 /* _UIB-PREPROCESSOR-BLOCK-END
*/
89 /* *********************** Procedure Settings
************************ */
91 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
92 /* Settings for
THIS-PROCEDURE
96 Add Fields to
: Neither
97 Other Settings
: CODE-ONLY
COMPILE
99 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
101 /* ************************* Create Window
************************** */
103 &ANALYZE-SUSPEND _CREATE-WINDOW
104 /* DESIGN Window definition
(used by the UIB
)
105 CREATE WINDOW Procedure
ASSIGN
108 /* END WINDOW DEFINITION
*/
114 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
115 /* ************************* Included-Libraries
*********************** */
117 {inc
/method
/m-txtrep.i
}
119 /* _UIB-CODE-BLOCK-END
*/
124 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
127 /* *************************** Main Block
*************************** */
129 RUN make-control-string
( "PCL", "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9",
130 OUTPUT prt-ctrl
, OUTPUT rows
, OUTPUT cols
).
132 RUN output-control-file
( prt-ctrl
).
133 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE VALUE(rows
).
135 VIEW FRAME heading-frame.
137 DEF VAR region-contract
LIKE contract-amount
NO-UNDO.
138 DEF VAR region-charged
LIKE charged-rent
NO-UNDO.
139 DEF VAR portfolio-contract
LIKE contract-amount
INITIAL 0 NO-UNDO.
140 DEF VAR portfolio-charged
LIKE charged-rent
INITIAL 0 NO-UNDO.
142 &GLOB NONE "none as yet"
143 DEF VAR last-region
AS CHAR INITIAL {&NONE} NO-UNDO.
145 FOR EACH Property
NO-LOCK WHERE Property.Active
146 AND ((NOT Property.ExternallyManaged
) OR include-external
)
147 BY Property.Region
BY Property.ShortName
:
148 IF last-region
<> Property.Region
THEN DO:
149 IF last-region
<> {&NONE} THEN DO:
150 RUN put-underlines
('
-'
).
151 RUN print-report-line
( " ", region-contract
, region-charged
).
152 IF detail-report
THEN PAGE.
ELSE PUT SKIP (1).
155 portfolio-contract
= portfolio-contract
+ region-contract.
156 portfolio-charged
= portfolio-charged
+ region-charged.
159 last-region
= Property.Region.
164 region-contract
= region-contract
+ contract-amount.
165 region-charged
= region-charged
+ charged-rent.
169 IF last-region
<> {&NONE} THEN DO:
170 RUN put-underlines
('
-'
).
171 RUN print-report-line
( " ", region-contract
, region-charged
).
173 portfolio-contract
= portfolio-contract
+ region-contract.
174 portfolio-charged
= portfolio-charged
+ region-charged.
177 RUN put-underlines
('
='
).
178 RUN print-report-line
( " ", portfolio-contract
, portfolio-charged
).
179 RUN put-underlines
('
='
).
183 RUN view-output-file
( preview
).
185 /* _UIB-CODE-BLOCK-END
*/
189 /* ********************** Internal Procedures
*********************** */
191 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
192 PROCEDURE each-property
:
193 /*------------------------------------------------------------------------------
194 Purpose
: Detail for each tenant of a property
195 ------------------------------------------------------------------------------*/
197 /* initialise totals for property
*/
200 last-tenant-code
= -1.
202 FOR EACH TenancyLease
NO-LOCK WHERE TenancyLease.PropertyCode
= Property.PropertyCode
203 AND TenancyLease.LeaseStatus
<> "PAST"
204 AND CAN-FIND( FIRST RentalSpace
OF TenancyLease
WHERE RentalSpace.AreaStatus
<> "V")
205 BY TenancyLease.PropertyCode
BY TenancyLease.TenantCode
:
206 IF TenancyLease.TenantCode
<> last-tenant-code
THEN DO:
207 RUN each-tenant
( last-tenant-code
, TenancyLease.TenantCode
).
209 IF rent-report
THEN DO:
210 FOR EACH RentalSpace
OF TenancyLease
WHERE RentalSpace.AreaStatus
<> "V" NO-LOCK:
211 tenant-contract
= tenant-contract
+ RentalSpace.ContractedRental.
212 IF NOT use-rent-charges
THEN
213 tenant-charged
= tenant-charged
+ RentalSpace.ChargedRental.
215 IF use-rent-charges
THEN DO:
216 FOR EACH RentCharge
NO-LOCK OF TenancyLease
217 WHERE RentCharge.RentChargeType
<> og-rentcharge-type
:
218 tenant-charged
= tenant-charged
+ RentCharge.CurrentAnnualRental .
223 tenant-contract
= tenant-contract
+ TenancyLease.OutgoingsBudget.
225 RUN each-tenant
( last-tenant-code
, -1 ).
227 IF detail-report
THEN RUN put-underlines
( '
-'
).
228 RUN print-report-line
( Property.Name
, contract-amount
, charged-rent
).
230 IF detail-report
THEN PUT SKIP (2).
233 /* _UIB-CODE-BLOCK-END
*/
237 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
238 PROCEDURE each-tenant
:
239 /*------------------------------------------------------------------------------
241 ------------------------------------------------------------------------------*/
242 DEF INPUT PARAMETER last-code
AS INT NO-UNDO.
243 DEF INPUT PARAMETER next-code
AS INT NO-UNDO.
245 IF last-code
> 0 THEN DO:
246 FIND Tenant
WHERE Tenant.TenantCode
= last-code
NO-LOCK NO-ERROR.
247 IF AVAILABLE( Tenant
) THEN DO:
248 IF NOT Tenant.Active
THEN tenant-charged
= 0.
249 IF detail-report
AND (tenant-contract
<> 0 OR tenant-charged
<> 0) THEN
250 RUN print-report-line
( Tenant.Name
, tenant-contract
, tenant-charged
).
252 contract-amount
= contract-amount
+ tenant-contract.
253 charged-rent
= charged-rent
+ tenant-charged.
260 last-tenant-code
= next-code
265 /* _UIB-CODE-BLOCK-END
*/
269 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-report-line Procedure
270 PROCEDURE print-report-line
:
271 /*------------------------------------------------------------------------------
273 ------------------------------------------------------------------------------*/
274 DEF INPUT PARAMETER name
AS CHAR NO-UNDO.
275 DEF INPUT PARAMETER column1
AS DECIMAL NO-UNDO.
276 DEF INPUT PARAMETER column2
AS DECIMAL NO-UNDO.
278 IF rent-report
THEN DO:
279 DEF VAR col-variance
AS DECIMAL NO-UNDO.
280 col-variance
= column2
- column1.
281 DISPLAY name @ Property.Name
282 column1 @ contract-amount
283 column2 @ charged-rent
284 col-variance @ variance
285 WITH FRAME report-line.
288 DISPLAY name @ Property.Name
289 column1 @ contract-amount
290 WITH FRAME report-line.
292 DOWN WITH FRAME report-line.
296 /* _UIB-CODE-BLOCK-END
*/
300 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE put-underlines Procedure
301 PROCEDURE put-underlines
:
302 /*------------------------------------------------------------------------------
304 ------------------------------------------------------------------------------*/
305 DEF INPUT PARAMETER ul-char
AS CHAR NO-UNDO.
308 PUT UNFORMATTED FILL(" ",51) + FILL(ul-char
,14) + " " + FILL(ul-char
,14) + " " + FILL(ul-char
,14).
310 PUT UNFORMATTED FILL(" ",51) + FILL(ul-char
,14).
314 /* _UIB-CODE-BLOCK-END
*/
318 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE region-heading Procedure
319 PROCEDURE region-heading
:
320 /*------------------------------------------------------------------------------
322 ------------------------------------------------------------------------------*/
323 DEF VAR region-name
AS CHAR NO-UNDO.
325 CASE Property.Region
:
326 WHEN "akld" THEN region-name
= "Auckland".
327 WHEN "wgtn" THEN region-name
= "Wellington".
328 WHEN "rot" THEN region-name
= "Rotorua".
329 WHEN "chch" THEN region-name
= "Christchurch".
330 WHEN "ham" THEN region-name
= "Hamilton".
331 WHEN "ZZZZ" THEN region-name
= "Sundry".
333 region-name
= CAPS( Property.Region
) + " buildings".
336 PUT UNFORMATTED SKIP region-name
SKIP FILL("-",LENGTH(region-name
)) SKIP.
339 /* _UIB-CODE-BLOCK-END
*/