1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
9 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
10 DEF VAR one-property
AS LOGI
NO-UNDO INIT No.
11 DEF VAR property-code
AS INT NO-UNDO INIT ?.
12 DEF VAR month-ending
AS INT NO-UNDO INITIAL ?.
13 DEF VAR account-list
AS CHAR NO-UNDO.
14 DEF VAR no-accounts
AS INT NO-UNDO.
17 DEF BUFFER ToMonth
FOR Month.
18 FIND ToMonth
WHERE ToMonth.MonthCode
= month-ending
NO-LOCK.
19 DEF VAR reconcile-from
AS DATE NO-UNDO.
20 DEF BUFFER FromMonth
FOR Month.
22 DEF VAR mfmt
AS CHAR NO-UNDO INITIAL ">>,>>>,>>9.99CR".
23 DEF VAR mudl
AS CHAR NO-UNDO INITIAL "--------------".
25 DEF VAR user-name
AS CHAR NO-UNDO.
26 {inc
/username.i
"user-name"}
27 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
28 timeStamp
= STRING( ToMonth.EndDate
, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
30 DEF VAR line
AS CHAR NO-UNDO.
32 DEF VAR time-font
AS CHAR NO-UNDO INITIAL "helvetica,proportional,point,6,normal".
33 DEF VAR base-font
AS CHAR NO-UNDO INITIAL "courier,fixed,cpi,16,lpi,9,normal".
34 DEF VAR header-font
AS CHAR NO-UNDO INITIAL "Times,Point,11,lpi,6,Proportional,Normal".
37 {inc
/ofc-set.i
"Reconciliation-Date" "reconciliation-date-text"}
39 /* _UIB-CODE-BLOCK-END
*/
43 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
45 /* ******************** Preprocessor Definitions
******************** */
47 &Scoped-define PROCEDURE-TYPE Procedure
51 /* _UIB-PREPROCESSOR-BLOCK-END
*/
55 /* ************************ Function Prototypes
********************** */
57 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD balance-from-summary Procedure
58 FUNCTION balance-from-summary
RETURNS DECIMAL
59 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC, INPUT mnth
AS INT ) FORWARD.
61 /* _UIB-CODE-BLOCK-END
*/
64 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD each-property Procedure
65 FUNCTION each-property
RETURNS DECIMAL
66 ( INPUT-OUTPUT mgr-ytd
AS DEC, INPUT-OUTPUT mgr-bud
AS DEC ) FORWARD.
68 /* _UIB-CODE-BLOCK-END
*/
71 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-balance Procedure
72 FUNCTION get-balance
RETURNS DECIMAL
73 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC ) FORWARD.
75 /* _UIB-CODE-BLOCK-END
*/
78 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-og-budget Procedure
79 FUNCTION get-og-budget
RETURNS DECIMAL
80 ( INPUT pc
AS INT, INPUT ac
AS DEC, INPUT months
AS INT ) FORWARD.
82 /* _UIB-CODE-BLOCK-END
*/
86 /* *********************** Procedure Settings
************************ */
88 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
89 /* Settings for
THIS-PROCEDURE
93 Add Fields to
: Neither
94 Other Settings
: CODE-ONLY
COMPILE
96 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
98 /* ************************* Create Window
************************** */
100 &ANALYZE-SUSPEND _CREATE-WINDOW
101 /* DESIGN Window definition
(used by the UIB
)
102 CREATE WINDOW Procedure
ASSIGN
105 /* END WINDOW DEFINITION
*/
111 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
112 /* ************************* Included-Libraries
*********************** */
114 {inc
/method
/m-txtrep.i
}
119 /* _UIB-CODE-BLOCK-END
*/
124 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
127 /* *************************** Main Block
*************************** */
129 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
131 RUN pclrep-start
( preview
, "reset,portrait,tm,2,a4,lm,6,courier,cpi,16,lpi,9").
133 RUN og-budget-watchlist.
139 /* _UIB-CODE-BLOCK-END
*/
143 /* ********************** Internal Procedures
*********************** */
145 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
146 PROCEDURE inst-page-footer
:
147 /*------------------------------------------------------------------------------
148 Purpose
: Print any page footer
149 ------------------------------------------------------------------------------*/
153 /* _UIB-CODE-BLOCK-END
*/
157 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
158 PROCEDURE inst-page-header
:
159 /*------------------------------------------------------------------------------
161 ------------------------------------------------------------------------------*/
164 line
= line
+ CHR(13) + SPC
(275) + "Page: " + STRING( pclrep-page-number
).
165 RUN pclrep-line
( time-font
, line
).
167 RUN pclrep-down-by
(2).
168 RUN pclrep-line
( header-font
, SPC
(35) + "Outgoing Watchlist Accounts - " + STRING( ToMonth.EndDate
, "99/99/9999")).
169 RUN pclrep-down-by
(1).
171 RUN pclrep-line
( base-font
, " Prop Account YTD Budget Variance").
172 RUN pclrep-down-by
(1).
176 /* _UIB-CODE-BLOCK-END
*/
180 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE og-budget-watchlist Procedure
181 PROCEDURE og-budget-watchlist
:
182 /*------------------------------------------------------------------------------
184 ------------------------------------------------------------------------------*/
185 DEF VAR mgr-ytd
AS DEC NO-UNDO INITIAL 0.0 .
186 DEF VAR mgr-bud
AS DEC NO-UNDO INITIAL 0.0 .
188 IF one-property
THEN DO:
189 FIND Property
WHERE Property.PropertyCode
= property-code
NO-LOCK.
190 each-property
( INPUT-OUTPUT mgr-ytd
, INPUT-OUTPUT mgr-bud
).
193 FOR EACH Property
NO-LOCK WHERE Property.Active
194 AND NOT Property.ExternallyManaged
195 AND NOT CAN-FIND( FIRST TenancyLease
OF Property
WHERE TenancyLease.LeaseStatus
<> "PAST"
196 AND TenancyLease.RecoveryType
= "A"),
197 FIRST Person
WHERE Person.PersonCode
= Property.Manager
198 BREAK BY Person.LastName
:
199 IF FIRST-OF( Person.LastName
) THEN DO:
200 RUN pclrep-line
( header-font
, "Managed by " + Person.FirstName
+ " " + Person.LastName
).
202 each-property
( INPUT-OUTPUT mgr-ytd
, INPUT-OUTPUT mgr-bud
).
203 IF LAST-OF( Person.LastName
) THEN DO:
204 line
= SPC
(14) + FILL( " " + mudl
, 3).
205 RUN pclrep-line
( base-font
+ ",lpi,15", line
).
207 + STRING(mgr-ytd
, mfmt
) + " "
208 + STRING(mgr-bud
, mfmt
) + " "
209 + STRING(mgr-ytd
- mgr-bud
, mfmt
) + " "
211 RUN pclrep-line
( base-font
+ ",lpi,15", line
).
212 RUN pclrep-page-break.
219 /* _UIB-CODE-BLOCK-END
*/
223 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
224 PROCEDURE parse-parameters
:
225 /*------------------------------------------------------------------------------
227 ------------------------------------------------------------------------------*/
228 DEF VAR token
AS CHAR NO-UNDO.
229 DEF VAR i
AS INT NO-UNDO.
231 {inc
/showopts.i
"report-options"}
233 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
234 token
= ENTRY( i
, report-options
, "~n" ).
236 CASE ENTRY( 1, token
):
237 WHEN "Preview" THEN preview
= Yes.
238 WHEN "Property" THEN property-code
= INT( ENTRY(2,token
) ).
239 WHEN "OneProperty" THEN one-property
= Yes.
240 WHEN "MonthEnding" THEN month-ending
= INT( ENTRY(2,token
) ).
241 WHEN "Accounts" THEN account-list
= SUBSTRING( token
, INDEX( token
, ",")).
246 no-accounts
= NUM-ENTRIES(account-list
).
250 /* _UIB-CODE-BLOCK-END
*/
254 /* ************************ Function Implementations
***************** */
256 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION balance-from-summary Procedure
257 FUNCTION balance-from-summary
RETURNS DECIMAL
258 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC, INPUT mnth
AS INT ) :
259 /*------------------------------------------------------------------------------
260 Purpose
: Calculate balance at a particular date by subtracting backwards
261 Notes
: Applies to balance sheet accounts
262 ------------------------------------------------------------------------------*/
263 DEF VAR bal
AS DEC NO-UNDO INITIAL 0.00 .
265 FIND AccountSummary
WHERE AccountSummary.EntityType
= et
266 AND AccountSummary.EntityCode
= ec
267 AND AccountSummary.AccountCode
= ac
NO-LOCK NO-ERROR.
268 IF AVAILABLE(AccountSummary
) THEN bal
= AccountSummary.Balance.
270 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= et
271 AND AccountBalance.EntityCode
= ec
272 AND AccountBalance.AccountCode
= ac
273 AND AccountBalance.MonthCode
> mnth
NO-LOCK:
274 bal
= bal
- AccountBalance.Balance.
281 /* _UIB-CODE-BLOCK-END
*/
285 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION each-property Procedure
286 FUNCTION each-property
RETURNS DECIMAL
287 ( INPUT-OUTPUT mgr-ytd
AS DEC, INPUT-OUTPUT mgr-bud
AS DEC ) :
288 /*------------------------------------------------------------------------------
291 ------------------------------------------------------------------------------*/
292 DEF VAR i
AS INT NO-UNDO INITIAL 0.
293 DEF VAR account-code
AS DEC NO-UNDO INITIAL 0.0 .
294 DEF VAR p-ytd
AS DEC NO-UNDO INITIAL 0.0 .
295 DEF VAR p-bud
AS DEC NO-UNDO INITIAL 0.0 .
296 DEF VAR a-ytd
AS DEC NO-UNDO INITIAL 0.0 .
297 DEF VAR a-bud
AS DEC NO-UNDO INITIAL 0.0 .
298 DEF VAR property-months
AS INT NO-UNDO.
299 DEF VAR did-something
AS LOGI
NO-UNDO INITIAL No.
301 reconcile-from
= Property.ReconciliationDue
+ 1.
302 IF reconciliation-date-text
<> "Done" THEN
303 reconcile-from
= add-months
( reconcile-from
, -12).
305 FIND LAST FromMonth
WHERE FromMonth.StartDate
<= reconcile-from
NO-LOCK.
306 property-months
= diff-months
( FromMonth.StartDate
, ToMonth.EndDate
+ 1).
308 DO i
= 1 TO no-accounts
:
309 account-code
= DEC( ENTRY( i
, account-list
)).
310 FIND ChartOfAccount
WHERE ChartOfAccount.AccountCode
= account-code
NO-LOCK NO-ERROR.
311 IF NOT AVAILABLE(ChartOfAccount
) THEN NEXT.
312 a-ytd
= get-balance
( "P", Property.PropertyCode
, account-code
).
313 a-bud
= get-og-budget
( Property.PropertyCode
, account-code
, property-months
).
314 IF a-ytd
= 0 AND a-bud
= 0 THEN NEXT.
316 line
= STRING(Property.PropertyCode
,"99999") + " "
317 + STRING(account-code
, "9999.99") + " "
318 + STRING(a-ytd
, mfmt
) + " "
319 + STRING(a-bud
, mfmt
) + " "
320 + STRING(a-ytd
- a-bud
, mfmt
).
321 IF (a-bud
= 0 AND a-ytd
> 0) OR (a-ytd
/ a-bud
) > 1.10 THEN DO:
322 line
= line
+ " Overbudget".
323 IF a-bud
<> 0 THEN line
= line
+ " by " + TRIM( STRING( 100.0 * ((a-ytd
/ a-bud
) - 1.0), "->>,>>9")) + "%".
325 RUN pclrep-line
( base-font
, line
).
326 p-bud
= p-bud
+ a-bud.
327 p-ytd
= p-ytd
+ a-ytd.
330 IF NOT did-something
THEN RETURN 0.0.
332 line
= SPC
(13) + FILL( " " + mudl
, 3).
333 RUN pclrep-line
( base-font
+ ",lpi,15", line
).
335 + STRING(p-ytd
, mfmt
) + " "
336 + STRING(p-bud
, mfmt
) + " "
337 + STRING(p-ytd
- p-bud
, mfmt
) + " "
338 + Property.Name
+ " (" + STRING(property-months
) + " months from " + STRING(reconcile-from
) + " to " + STRING(ToMonth.EndDate
) + ")".
339 RUN pclrep-line
( base-font
+ ",lpi,15", line
).
340 RUN pclrep-down-by
(2.3).
342 mgr-ytd
= mgr-ytd
+ p-ytd.
343 mgr-bud
= mgr-bud
+ p-bud.
349 /* _UIB-CODE-BLOCK-END
*/
353 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-balance Procedure
354 FUNCTION get-balance
RETURNS DECIMAL
355 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC ) :
356 /*------------------------------------------------------------------------------
359 ------------------------------------------------------------------------------*/
360 DEF VAR balance
AS DEC NO-UNDO INITIAL 0.0 .
362 RETURN balance-from-summary
( et
, ec
, ac
, month-ending
).
366 /* _UIB-CODE-BLOCK-END
*/
370 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-og-budget Procedure
371 FUNCTION get-og-budget
RETURNS DECIMAL
372 ( INPUT pc
AS INT, INPUT ac
AS DEC, INPUT months
AS INT ) :
373 /*------------------------------------------------------------------------------
376 ------------------------------------------------------------------------------*/
377 FIND PropertyOutgoing
WHERE PropertyOutgoing.PropertyCode
= pc
378 AND PropertyOutgoing.AccountCode
= ac
NO-LOCK NO-ERROR.
379 IF NOT AVAILABLE(PropertyOutgoing
) THEN RETURN 0.0 .
381 RETURN (PropertyOutgoing.BudgetAmount
* months
) / 12.0 .
385 /* _UIB-CODE-BLOCK-END
*/