1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Method-Library
4 /*--------------------------------------------------------------------------
5 Library
: inc
/method
/m-lease-rentals.i
6 Purpose
: Used by reports which report on rentals for leases
/ areas
8 Author
(s
) : Andrew McMillan
10 Notes
: Cut from Sydney Schedule.
11 ------------------------------------------------------------------------*/
12 DEF VAR show-future-rentals
AS LOGI
NO-UNDO INITIAL No.
13 DEF VAR all-future-rentals
AS LOGI
NO-UNDO INITIAL No.
15 DEF TEMP-TABLE LeaseTotal
NO-UNDO
16 FIELD LeaseCode
AS INT
17 FIELD AnnualRent
AS DEC INITIAL 0.0
18 FIELD ContractRent
AS DEC INITIAL 0.0
19 FIELD AnnualOutgoings
AS DEC INITIAL 0.0
20 FIELD AnnualCleaning
AS DEC INITIAL 0.0
21 FIELD AreaSize
AS DEC INITIAL 0.0
22 FIELD AreaCount
AS INT INITIAL 0
23 INDEX XPKLeaseTotals
IS UNIQUE PRIMARY LeaseCode.
25 DEF TEMP-TABLE LeaseRental
NO-UNDO
26 FIELD LeaseCode
AS INT
27 FIELD AreaType
AS CHAR
28 FIELD AnnualRent
AS DEC INITIAL 0.0
29 FIELD AnnualOutgoings
AS DEC INITIAL 0.0
30 FIELD AnnualCleaning
AS DEC INITIAL 0.0
31 FIELD ContractRent
AS DEC INITIAL 0.0
32 FIELD AreaSize
AS DEC INITIAL 0.0
33 FIELD AreaCount
AS INT INITIAL 0
34 FIELD Future
AS LOGI
INITIAL No
35 INDEX XPKLeaseRentals
IS UNIQUE PRIMARY LeaseCode AreaType.
37 DEF TEMP-TABLE AreaRental
NO-UNDO
38 FIELD PropertyCode
AS INT
39 FIELD RentalSpaceCode
AS INT
40 FIELD LeaseCode
AS INT
41 FIELD AreaType
AS CHAR
42 FIELD AnnualRent
AS DEC INITIAL 0.0
43 FIELD AnnualCleaning
AS DEC INITIAL 0.0
44 FIELD AnnualOutgoings
AS DEC INITIAL 0.0
45 FIELD ContractRent
AS DEC INITIAL 0.0
46 FIELD AreaSize
AS DEC INITIAL 0.0
47 INDEX XPKLeaseRentals
IS UNIQUE PRIMARY PropertyCode RentalSpaceCode .
50 {inc
/ofc-set.i
"RentCharge-Outgoings" "outgoings-type-list"}
51 {inc
/ofc-set.i
"RentCharge-Cleaning" "cleaning-type-list"}
53 /* _UIB-CODE-BLOCK-END
*/
57 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
59 /* ******************** Preprocessor Definitions
******************** */
63 /* _UIB-PREPROCESSOR-BLOCK-END
*/
67 /* ************************ Function Prototypes
********************** */
69 &IF DEFINED(EXCLUDE-get-area-cleaning) = 0 &THEN
71 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-area-cleaning Method-Library
72 FUNCTION get-area-cleaning
RETURNS DECIMAL
73 ( INPUT property-code
AS INT, INPUT area-code
AS INT ) FORWARD.
75 /* _UIB-CODE-BLOCK-END
*/
80 &IF DEFINED(EXCLUDE-get-area-outgoings) = 0 &THEN
82 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-area-outgoings Method-Library
83 FUNCTION get-area-outgoings
RETURNS DECIMAL
84 ( INPUT property-code
AS INT, INPUT area-code
AS INT ) FORWARD.
86 /* _UIB-CODE-BLOCK-END
*/
91 &IF DEFINED(EXCLUDE-get-area-rental) = 0 &THEN
93 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-area-rental Method-Library
94 FUNCTION get-area-rental
RETURNS DECIMAL
95 ( INPUT property-code
AS INT, INPUT area-code
AS INT ) FORWARD.
97 /* _UIB-CODE-BLOCK-END
*/
103 /* *********************** Procedure Settings
************************ */
105 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
106 /* Settings for
THIS-PROCEDURE
110 Add Fields to
: Neither
111 Other Settings
: INCLUDE-ONLY
113 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
115 /* ************************* Create Window
************************** */
117 &ANALYZE-SUSPEND _CREATE-WINDOW
118 /* DESIGN Window definition
(used by the UIB
)
119 CREATE WINDOW Method-Library
ASSIGN
122 /* END WINDOW DEFINITION
*/
126 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Method-Library
127 /* ************************* Included-Libraries
*********************** */
129 /* _UIB-CODE-BLOCK-END
*/
136 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Method-Library
139 /* *************************** Main Block
*************************** */
141 /* _UIB-CODE-BLOCK-END
*/
145 /* ********************** Internal Procedures
*********************** */
147 &IF DEFINED(EXCLUDE-build-lease-rentals) = 0 &THEN
149 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-lease-rentals Method-Library
150 PROCEDURE build-lease-rentals
:
151 /*------------------------------------------------------------------------------
152 Purpose
: Build tables of rental for each type for each lease
153 and then build allocate them by the area type for each LseSpace.
154 ------------------------------------------------------------------------------*/
155 DEF BUFFER Lease
FOR TenancyLease.
156 DEF BUFFER LseCharge
FOR RentCharge.
157 DEF BUFFER LseSpace
FOR RentalSpace.
158 DEF VAR no-current-rentals
AS LOGI
NO-UNDO INITIAL NO.
159 DEF VAR this-rental
AS DEC NO-UNDO.
161 FOR EACH Lease
OF Property
WHERE Lease.LeaseStatus
<> "PAST" NO-LOCK:
163 LeaseTotal.LeaseCode
= Lease.TenancyLeaseCode.
164 no-current-rentals
= NOT CAN-FIND( FIRST LseCharge
OF Lease
WHERE CAN-FIND( FIRST RentChargeLine
OF LseCharge
WHERE RentChargeLine.RentChargeLineStatus
= "C" AND RentChargeLine.StartDate
<= TODAY)).
165 FOR EACH LseCharge
OF Lease
WHERE CAN-FIND( FIRST RentChargeLine
OF LseCharge
WHERE RentChargeLine.RentChargeLineStatus
= "C"
166 OR RentChargeLine.RentChargeLineStatus
= "I") NO-LOCK:
167 FIND LeaseRental
WHERE LeaseRental.LeaseCode
= Lease.TenancyLeaseCode
168 AND LeaseRental.AreaType
= LseCharge.RentChargeType
170 IF NOT AVAILABLE(LeaseRental
) THEN DO:
172 LeaseRental.LeaseCode
= Lease.TenancyLeaseCode.
173 LeaseRental.AreaType
= LseCharge.RentChargeType.
176 IF (show-future-rentals
AND (Lease.LeaseStartDate
> TODAY)) OR no-current-rentals
THEN DO:
177 FIND FIRST RentChargeLine
OF LseCharge
WHERE RentChargeLine.RentChargeLineStatus
= "C"
178 AND (no-current-rentals
OR RentChargeLine.StartDate
> TODAY)
180 IF NOT AVAILABLE(RentChargeLine
) OR (RentChargeLine.EndDate
= RentChargeLine.LastChargedDate
181 AND RentChargeLine.LastChargedDate
<> ?
) THEN
183 this-rental
= to-annual
( RentChargeLine.FrequencyCode
, RentChargeLine.Amount
) .
184 IF RentChargeLine.StartDate
> TODAY THEN LeaseRental.Future
= Yes.
187 this-rental
= LseCharge.CurrentAnnualRental .
189 IF CAN-DO( outgoings-type-list
, LseCharge.RentChargeType
) THEN DO:
190 LeaseTotal.AnnualOutgoings
= LeaseTotal.AnnualOutgoings
+ this-rental.
192 ELSE IF CAN-DO( cleaning-type-list
, LseCharge.RentChargeType
) THEN DO:
193 LeaseTotal.AnnualCleaning
= LeaseTotal.AnnualCleaning
+ this-rental.
196 LeaseTotal.AnnualRent
= LeaseTotal.AnnualRent
+ this-rental.
198 LeaseRental.AnnualRent
= LeaseRental.AnnualRent
+ this-rental.
201 FOR EACH LseSpace
OF Lease
WHERE LseSpace.AreaStatus
= "L" NO-LOCK:
203 AreaRental.PropertyCode
= LseSpace.PropertyCode.
204 AreaRental.RentalSpaceCode
= LseSpace.RentalSpaceCode.
205 AreaRental.LeaseCode
= Lease.TenancyLeaseCode.
206 AreaRental.AreaSize
= LseSpace.AreaSize.
207 AreaRental.AreaType
= LseSpace.AreaType.
208 AreaRental.ContractRent
= LseSpace.ContractedRental.
209 FIND LeaseRental
WHERE LeaseRental.LeaseCode
= Lease.TenancyLeaseCode
210 AND LeaseRental.AreaType
= LseSpace.AreaType
212 IF NOT AVAILABLE(LeaseRental
) THEN DO:
214 LeaseRental.LeaseCode
= Lease.TenancyLeaseCode.
215 LeaseRental.AreaType
= LseSpace.AreaType.
217 LeaseRental.AreaSize
= LeaseRental.AreaSize
+ LseSpace.AreaSize.
218 LeaseRental.AreaCount
= LeaseRental.AreaCount
+ 1.
219 LeaseRental.ContractRent
= LeaseRental.ContractRent
+ LseSpace.ContractedRental.
221 FIND AreaType
WHERE AreaType.AreaType
= LeaseRental.AreaType
NO-LOCK NO-ERROR.
222 IF AVAILABLE(AreaType
) AND AreaType.IsFloorArea
THEN DO:
223 LeaseTotal.AreaSize
= LeaseTotal.AreaSize
+ LseSpace.AreaSize.
224 LeaseTotal.AreaCount
= LeaseTotal.AreaCount
+ 1.
225 LeaseTotal.ContractRent
= LeaseTotal.ContractRent
+ LseSpace.ContractedRental.
229 DEF BUFFER NextAreaRent
FOR AreaRental.
230 DEF VAR i
AS INT NO-UNDO.
231 DEF VAR j
AS INT NO-UNDO.
232 DEF VAR rent-ratio
AS DEC NO-UNDO.
233 DEF VAR area-ratio
AS DEC NO-UNDO.
234 FOR EACH LeaseRental
WHERE LeaseRental.LeaseCode
= Lease.TenancyLeaseCode
235 AND LeaseRental.AnnualRent
<> 0:
238 FIND AreaType
WHERE AreaType.AreaType
= LeaseRental.AreaType
NO-LOCK NO-ERROR.
240 FOR EACH AreaRental
WHERE AreaRental.LeaseCode
= LeaseRental.LeaseCode
241 AND AreaRental.AreaType
= LeaseRental.AreaType
:
242 IF LeaseRental.AreaCount
< 2 THEN
243 AreaRental.AnnualRent
= LeaseRental.AnnualRent.
244 ELSE IF AreaRental.ContractRent
<> 0 AND LeaseRental.ContractRent
<> 0 THEN
245 AreaRental.AnnualRent
= LeaseRental.AnnualRent
* (AreaRental.ContractRent
/ LeaseRental.ContractRent
).
246 ELSE IF LeaseRental.AreaSize
<> 0 THEN
247 AreaRental.AnnualRent
= LeaseRental.AnnualRent
* (AreaRental.AreaSize
/ LeaseRental.AreaSize
) .
249 AreaRental.AnnualRent
= LeaseRental.AnnualRent.
251 IF AVAILABLE(AreaType
) AND AreaType.IsFloorArea
THEN DO:
252 area-ratio
= AreaRental.AreaSize
/ LeaseTotal.AreaSize.
253 IF LeaseTotal.AreaCount
< 2 THEN DO:
254 AreaRental.AnnualOutgoings
= LeaseTotal.AnnualOutgoings.
255 AreaRental.AnnualCleaning
= LeaseTotal.AnnualCleaning.
257 ELSE IF AreaRental.ContractRent
<> 0 AND LeaseTotal.ContractRent
<> 0 THEN DO:
258 rent-ratio
= (AreaRental.ContractRent
/ LeaseTotal.ContractRent
).
259 AreaRental.AnnualOutgoings
= LeaseTotal.AnnualOutgoings
* rent-ratio.
260 AreaRental.AnnualCleaning
= LeaseTotal.AnnualCleaning
* area-ratio.
262 ELSE IF LeaseTotal.AreaSize
<> 0 THEN DO:
263 AreaRental.AnnualOutgoings
= LeaseTotal.AnnualOutgoings
* area-ratio.
264 AreaRental.AnnualCleaning
= LeaseTotal.AnnualCleaning
* area-ratio.
266 ELSE IF j
= 1 THEN DO:
267 AreaRental.AnnualOutgoings
= LeaseTotal.AnnualOutgoings.
268 AreaRental.AnnualCleaning
= LeaseTotal.AnnualCleaning.
280 /* _UIB-CODE-BLOCK-END
*/
285 /* ************************ Function Implementations
***************** */
287 &IF DEFINED(EXCLUDE-get-area-cleaning) = 0 &THEN
289 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-area-cleaning Method-Library
290 FUNCTION get-area-cleaning
RETURNS DECIMAL
291 ( INPUT property-code
AS INT, INPUT area-code
AS INT ) :
292 /*------------------------------------------------------------------------------
293 Purpose
: Get the rental for this area
295 ------------------------------------------------------------------------------*/
296 FIND AreaRental
WHERE AreaRental.PropertyCode
= property-code
297 AND AreaRental.RentalSpaceCode
= area-code
NO-ERROR.
299 RETURN (IF AVAILABLE(AreaRental
) THEN AreaRental.AnnualCleaning
ELSE 0.0 ).
303 /* _UIB-CODE-BLOCK-END
*/
308 &IF DEFINED(EXCLUDE-get-area-outgoings) = 0 &THEN
310 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-area-outgoings Method-Library
311 FUNCTION get-area-outgoings
RETURNS DECIMAL
312 ( INPUT property-code
AS INT, INPUT area-code
AS INT ) :
313 /*------------------------------------------------------------------------------
314 Purpose
: Get the rental for this area
316 ------------------------------------------------------------------------------*/
317 FIND AreaRental
WHERE AreaRental.PropertyCode
= property-code
318 AND AreaRental.RentalSpaceCode
= area-code
NO-ERROR.
320 RETURN (IF AVAILABLE(AreaRental
) THEN AreaRental.AnnualOutgoings
ELSE 0.0 ).
324 /* _UIB-CODE-BLOCK-END
*/
329 &IF DEFINED(EXCLUDE-get-area-rental) = 0 &THEN
331 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-area-rental Method-Library
332 FUNCTION get-area-rental
RETURNS DECIMAL
333 ( INPUT property-code
AS INT, INPUT area-code
AS INT ) :
334 /*------------------------------------------------------------------------------
335 Purpose
: Get the rental for this area
337 ------------------------------------------------------------------------------*/
338 FIND AreaRental
WHERE AreaRental.PropertyCode
= property-code
339 AND AreaRental.RentalSpaceCode
= area-code
NO-ERROR.
341 RETURN (IF AVAILABLE(AreaRental
) THEN AreaRental.AnnualRent
ELSE 0.0 ).
345 /* _UIB-CODE-BLOCK-END
*/