1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Report
: Current Income and Budgetted Expenditure
6 Author
: Andrew McMillan
8 ------------------------------------------------------------------------*/
10 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
12 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
13 DEF VAR show-rebates
AS LOGI
NO-UNDO INIT No.
14 DEF VAR property-1
AS INT NO-UNDO INIT 0.
15 DEF VAR property-n
AS INT NO-UNDO INIT 99999.
16 DEF VAR selection-style
AS CHAR NO-UNDO.
17 DEF VAR test-client-code
AS CHAR NO-UNDO INITIAL ?.
18 DEF VAR company-list
AS CHAR NO-UNDO INITIAL ?.
19 DEF VAR month-1
AS INT NO-UNDO.
20 DEF VAR month-n
AS INT NO-UNDO.
23 DEF VAR property-code
AS INT NO-UNDO.
24 DEF VAR property-name
AS CHAR NO-UNDO.
26 DEF VAR user-name
AS CHAR NO-UNDO.
27 {inc
/username.i
"user-name"}
28 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
29 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
31 DEF VAR pr-line
AS CHAR INIT "" NO-UNDO.
/* used everywhere to hold print line
*/
33 DEF VAR title-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
34 DEF VAR time-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
35 DEF VAR break1-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
36 DEF VAR break2-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
37 DEF VAR base-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,bold".
40 {inc
/ofc-set.i
"Property-Expense-Groups" "expense-groups"}
42 /* _UIB-CODE-BLOCK-END
*/
46 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
48 /* ******************** Preprocessor Definitions
******************** */
50 &Scoped-define PROCEDURE-TYPE Procedure
54 /* _UIB-PREPROCESSOR-BLOCK-END
*/
58 /* ************************ Function Prototypes
********************** */
60 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-account-budget Procedure
61 FUNCTION get-account-budget
RETURNS DECIMAL
62 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC ) FORWARD.
64 /* _UIB-CODE-BLOCK-END
*/
68 /* *********************** Procedure Settings
************************ */
70 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
71 /* Settings for
THIS-PROCEDURE
75 Add Fields to
: Neither
76 Other Settings
: CODE-ONLY
COMPILE
78 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
80 /* ************************* Create Window
************************** */
82 &ANALYZE-SUSPEND _CREATE-WINDOW
83 /* DESIGN Window definition
(used by the UIB
)
84 CREATE WINDOW Procedure
ASSIGN
87 /* END WINDOW DEFINITION
*/
93 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
94 /* ************************* Included-Libraries
*********************** */
96 {inc
/method
/m-txtrep.i
}
98 /* _UIB-CODE-BLOCK-END
*/
103 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
106 /* *************************** Main Block
*************************** */
108 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
110 RUN pclrep-start
( preview
, "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
112 IF selection-style
= "OneClient" THEN RUN for-one-client.
113 ELSE IF selection-style
= "CompanyList" THEN RUN for-company-list.
115 RUN for-each-property.
121 /* _UIB-CODE-BLOCK-END
*/
125 /* ********************** Internal Procedures
*********************** */
127 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
128 PROCEDURE each-property
:
129 /*------------------------------------------------------------------------------
130 Purpose
: Print the outgoings budgets for the property
131 ------------------------------------------------------------------------------*/
132 DEF INPUT PARAMETER property-code
AS INT NO-UNDO.
134 DEF VAR inc-amount
AS DECIMAL INITIAL 0 NO-UNDO.
135 DEF VAR bldg-area
AS DECIMAL INITIAL 0 NO-UNDO.
136 DEF VAR inc-total
AS DECIMAL INITIAL 0 NO-UNDO.
137 DEF VAR exp-total
AS DECIMAL INITIAL 0 NO-UNDO.
139 RUN print-income
( property-code
, OUTPUT inc-total
, OUTPUT bldg-area
).
140 RUN print-expenses
( property-code
, bldg-area
, OUTPUT exp-total
).
142 RUN print-report-line
( "=", "Net Receipts", (inc-total
- exp-total
), bldg-area
).
143 RUN pclrep-page-break.
147 /* _UIB-CODE-BLOCK-END
*/
151 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-company-list Procedure
152 PROCEDURE for-company-list
:
153 /*------------------------------------------------------------------------------
155 ------------------------------------------------------------------------------*/
156 DEF VAR i
AS INT NO-UNDO.
157 DEF VAR n
AS INT NO-UNDO.
158 DEF VAR company-code
AS INT NO-UNDO.
160 FIND ConsolidationList
WHERE ConsolidationList.Name
= company-list
NO-LOCK.
161 n
= NUM-ENTRIES( ConsolidationList.CompanyList
).
163 company-code
= INT( ENTRY( i
, ConsolidationList.CompanyList
) ).
164 FOR EACH Property
WHERE Property.CompanyCode
= company-code
165 AND Property.Active
NO-LOCK:
166 property-code
= Property.PropertyCode.
167 property-name
= Property.Name.
168 RUN each-property
( property-code
).
174 /* _UIB-CODE-BLOCK-END
*/
178 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-property Procedure
179 PROCEDURE for-each-property
:
180 /*------------------------------------------------------------------------------
182 ------------------------------------------------------------------------------*/
184 FOR EACH Property
WHERE Property.PropertyCode
>= property-1
185 AND Property.PropertyCode
<= property-n
186 AND Property.Active
NO-LOCK:
187 property-code
= Property.PropertyCode.
188 property-name
= Property.Name.
189 RUN each-property
( property-code
).
194 /* _UIB-CODE-BLOCK-END
*/
198 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-one-client Procedure
199 PROCEDURE for-one-client
:
200 /*------------------------------------------------------------------------------
202 ------------------------------------------------------------------------------*/
204 FOR EACH Company
WHERE Company.ClientCode
= test-client-code
NO-LOCK:
205 FOR EACH Property
OF Company
WHERE Property.Active
NO-LOCK:
206 property-code
= Property.PropertyCode.
207 property-name
= Property.Name.
208 RUN each-property
( property-code
).
215 /* _UIB-CODE-BLOCK-END
*/
219 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
220 PROCEDURE inst-page-footer
:
221 /*------------------------------------------------------------------------------
222 Purpose
: Print any page footer
223 ------------------------------------------------------------------------------*/
227 /* _UIB-CODE-BLOCK-END
*/
231 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
232 PROCEDURE inst-page-header
:
233 /*------------------------------------------------------------------------------
234 Purpose
: Print any page header
235 ------------------------------------------------------------------------------*/
237 RUN pclrep-line
( "univers,Point,6,bold,Proportional", TimeStamp
).
238 RUN pclrep-line
( "", "" ).
239 RUN pclrep-line
( "univers,Point,12,bold,Proportional",
240 "Current Income and Budgetted Expenditure for P"
241 + TRIM(STRING(property-code
))
244 RUN pclrep-line
( "", "" ).
246 /* Put any column headers here
*/
247 pr-line
= FILL(" ", 68) + "$PA Area SqM $/SqM P.C.M." .
248 RUN pclrep-line
( base-font
, pr-line
).
249 RUN pclrep-down-by
(1).
253 /* _UIB-CODE-BLOCK-END
*/
257 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE old-code Procedure
259 /*------------------------------------------------------------------------------
263 ------------------------------------------------------------------------------*/
265 FOR EACH PropertyOutgoing
NO-LOCK WHERE PropertyOutgoing.PropertyCode
= Property.PropertyCode
266 AND PropertyOutgoing.BudgetAmount
< 0,
267 FIRST ChartOfAccount
NO-LOCK WHERE ChartOfAccount.AccountCode
= PropertyOutgoing.AccountCode
:
268 pr-line
= FILL(" ", 20)
269 + STRING( PropertyOutgoing.AccountCode
, "9999.99") + " "
270 + STRING( ChartOfAccount.Name
, "X(50)") + " "
271 + STRING( - PropertyOutgoing.BudgetAmount
, "->>,>>>,>>9.99") + " "
272 + STRING( bldg-area
, "->>,>>>,>>9.99") + " "
273 + STRING( - (PropertyOutgoing.BudgetAmount
/ bldg-area
), "->,>>9.99") + " "
274 + STRING( - (PropertyOutgoing.BudgetAmount
/ 12), "->>,>>>,>>9.99").
275 RUN pclrep-line
( base-font
, pr-line
).
276 inc-total
= inc-total
- PropertyOutgoing.BudgetAmount .
280 FOR EACH TenancyLease
OF Property
NO-LOCK WHERE Tenancylease.LeaseStatus
<> "PAST"
281 AND CAN-FIND( FIRST RentalSpace
OF TenancyLease
WHERE RentalSpace.AreaStatus
<> "V" AND RentalSpace.AreaStatus
<> "X"):
282 inc-amount
= inc-amount
+ TenancyLease.OutgoingsBudget.
284 IF inc-amount
<> 0 THEN DO:
285 pr-line
= FILL(" ", 20)
286 + FILL( " ", 7) + " "
287 + STRING( "Outgoings", "X(50)") + " "
288 + STRING( inc-amount
, "->>,>>>,>>9.99") + " "
289 + STRING( bldg-area
, "->>,>>>,>>9.99") + " "
290 + STRING( (IF bldg-area
= 0 THEN 0 ELSE inc-amount
/ bldg-area
), "->,>>9.99") + " "
291 + STRING( (inc-amount
/ 12), "->>,>>>,>>9.99").
292 RUN pclrep-line
( base-font
, pr-line
).
293 inc-total
= inc-total
+ inc-amount.
298 FOR EACH PropertyOutgoing
NO-LOCK WHERE PropertyOutgoing.PropertyCode
= Property.PropertyCode
299 AND PropertyOutgoing.BudgetAmount
> 0,
300 FIRST ChartOfAccount
NO-LOCK WHERE ChartOfAccount.AccountCode
= PropertyOutgoing.AccountCode
:
301 pr-line
= FILL(" ", 20)
302 + STRING( PropertyOutgoing.AccountCode
, "9999.99") + " "
303 + STRING( ChartOfAccount.Name
, "X(50)") + " "
304 + STRING( PropertyOutgoing.BudgetAmount
, "->>,>>>,>>9.99") + " "
305 + STRING( bldg-area
, "->>,>>>,>>9.99") + " "
306 + STRING( (PropertyOutgoing.BudgetAmount
/ bldg-area
), "->,>>9.99") + " "
307 + STRING( (PropertyOutgoing.BudgetAmount
/ 12), "->>,>>>,>>9.99").
308 RUN pclrep-line
( base-font
, pr-line
).
309 exp-total
= exp-total
+ PropertyOutgoing.BudgetAmount .
315 /* _UIB-CODE-BLOCK-END
*/
319 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
320 PROCEDURE parse-parameters
:
321 /*------------------------------------------------------------------------------
323 ------------------------------------------------------------------------------*/
324 DEF VAR token
AS CHAR NO-UNDO.
325 DEF VAR i
AS INT NO-UNDO.
326 DEF VAR fin-year
AS INT NO-UNDO.
328 {inc
/showopts.i
"report-options"}
330 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
331 token
= ENTRY( i
, report-options
, "~n" ).
333 CASE ENTRY( 1, token
):
334 WHEN "Preview" THEN preview
= Yes.
335 WHEN "Client" THEN test-client-code
= ENTRY(2,token
).
336 WHEN "CompanyList" THEN company-list
= ENTRY(2,token
).
337 WHEN "Selection" THEN selection-style
= ENTRY(2,token
).
338 WHEN "ShowRebates" THEN show-rebates
= Yes.
339 WHEN "Properties" THEN ASSIGN
340 property-1
= INT( ENTRY(2,token
) )
341 property-n
= INT( ENTRY(3,token
) ).
346 /* Calculate the range of months
*/
347 FIND Month
WHERE Month.StartDate
<= TODAY AND Month.EndDate
>= TODAY NO-LOCK.
348 FIND FinancialYear
OF Month
NO-LOCK.
349 FIND FIRST Month
OF FinancialYear
NO-LOCK.
350 month-1
= Month.MonthCode.
351 FIND LAST Month
OF FinancialYear
NO-LOCK.
352 month-n
= Month.MonthCode.
356 /* _UIB-CODE-BLOCK-END
*/
360 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-expenses Procedure
361 PROCEDURE print-expenses
:
362 /*------------------------------------------------------------------------------
364 ------------------------------------------------------------------------------*/
365 DEF INPUT PARAMETER property-code
AS INT NO-UNDO.
366 DEF INPUT PARAMETER bldg-area
AS DECIMAL NO-UNDO.
367 DEF OUTPUT PARAMETER exp-total
AS DECIMAL NO-UNDO.
369 DEF VAR budget-amount
AS DEC NO-UNDO.
371 /* Print expense totals
*/
373 FOR EACH AccountGroup
NO-LOCK WHERE LOOKUP( AccountGroup.AccountGroupCode
, expense-groups
) > 0
374 BY AccountGroup.Sequence
:
375 FOR EACH ChartOfAccount
NO-LOCK OF AccountGroup
:
376 budget-amount
= get-account-budget
( "P", property-code
, ChartOfAccount.AccountCode
).
377 IF budget-amount
<> 0 THEN DO:
378 RUN print-report-line
( "", STRING( ChartOfAccount.AccountCode
, "9999.99") + " "
379 + STRING( ChartOfAccount.Name
),
380 budget-amount
, bldg-area
).
381 exp-total
= exp-total
+ budget-amount.
386 RUN print-report-line
( "-", "", exp-total
, bldg-area
).
387 RUN pclrep-down-by
(1).
391 /* _UIB-CODE-BLOCK-END
*/
395 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-income Procedure
396 PROCEDURE print-income
:
397 /*------------------------------------------------------------------------------
399 ------------------------------------------------------------------------------*/
400 DEF INPUT PARAMETER property-code
AS INT NO-UNDO.
401 DEF OUTPUT PARAMETER inc-total
AS DECIMAL NO-UNDO.
402 DEF OUTPUT PARAMETER bldg-area
AS DECIMAL NO-UNDO.
404 DEF VAR inc-amount
AS DECIMAL INITIAL 0 NO-UNDO.
405 DEF VAR area-size
AS DECIMAL INITIAL 0 NO-UNDO.
407 /* Print income totals
*/
410 FOR EACH RentChargeType
NO-LOCK,
411 FIRST ChartOfAccount
NO-LOCK WHERE ChartOfAccount.AccountCode
= RentChargeType.AccountCode
412 BY RentChargeType.AccountCode
:
415 FOR EACH TenancyLease
WHERE TenancyLease.PropertyCode
= property-code
416 AND TenancyLease.LeaseStatus
<> "PAST" NO-LOCK,
417 EACH RentCharge
NO-LOCK OF TenancyLease
WHERE RentCharge.RentChargeType
= RentChargeType.RentChargeType
:
418 inc-amount
= inc-amount
+ RentCharge.CurrentAnnualRental.
420 FIND AreaType
WHERE AreaType.AreaType
= RentChargeType.RentChargeType
NO-LOCK NO-ERROR.
421 IF AVAILABLE(AreaType
) AND AreaType.IsFloorArea
THEN DO:
422 FOR EACH RentalSpace
NO-LOCK WHERE RentalSpace.PropertyCode
= property-code
423 AND RentalSpace.AreaType
= RentChargeType.RentChargeType
:
424 area-size
= area-size
+ RentalSpace.AreaSize.
427 IF inc-amount
<> 0 OR area-size
<> 0 THEN DO:
428 RUN print-report-line
( "", STRING( ChartOfAccount.AccountCode
, "9999.99") + " "
429 + STRING( RentChargeType.Description
),
430 inc-amount
, area-size
).
431 inc-total
= inc-total
+ inc-amount.
432 bldg-area
= bldg-area
+ area-size.
436 RUN print-report-line
( "-", "", inc-total
, bldg-area
).
437 RUN pclrep-down-by
(2).
441 /* _UIB-CODE-BLOCK-END
*/
445 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-report-line Procedure
446 PROCEDURE print-report-line
:
447 /*------------------------------------------------------------------------------
449 ------------------------------------------------------------------------------*/
450 DEF INPUT PARAMETER pre-line-char
AS CHAR NO-UNDO.
451 DEF INPUT PARAMETER description
AS CHAR NO-UNDO.
452 DEF INPUT PARAMETER amount
AS DEC NO-UNDO.
453 DEF INPUT PARAMETER area
AS DEC NO-UNDO.
455 IF pre-line-char
<> "" THEN DO:
456 pr-line
= FILL(" ", 61) + FILL( pre-line-char
, 14)
457 + " " + FILL( pre-line-char
, 14)
458 + " " + FILL( pre-line-char
, 9)
459 + " " + FILL( pre-line-char
, 14).
460 RUN pclrep-line
( base-font
, pr-line
).
463 pr-line
= STRING( description
, "X(61)")
464 + STRING( amount
, "->>,>>>,>>9.99") + " "
465 + STRING( area
, "->>,>>>,>>9.99") + " "
466 + STRING( (IF area
= 0.0 THEN 0.0 ELSE (amount
/ area
)), "->,>>9.99") + " "
467 + STRING( (amount
/ 12), "->>,>>>,>>9.99").
469 RUN pclrep-line
( base-font
, pr-line
).
473 /* _UIB-CODE-BLOCK-END
*/
477 /* ************************ Function Implementations
***************** */
479 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-account-budget Procedure
480 FUNCTION get-account-budget
RETURNS DECIMAL
481 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC ) :
482 /*------------------------------------------------------------------------------
485 ------------------------------------------------------------------------------*/
486 DEF VAR budget
AS DEC NO-UNDO INITIAL 0.0 .
488 FOR EACH AccountBalance
NO-LOCK WHERE AccountBalance.EntityType
= et
489 AND AccountBalance.EntityCode
= ec
490 AND AccountBalance.AccountCode
= ac
491 AND AccountBalance.MonthCode
>= month-1
492 AND AccountBalance.MonthCode
<= month-n
:
493 budget
= budget
+ AccountBalance.Budget.
500 /* _UIB-CODE-BLOCK-END
*/