Add blank column, rename column.
[capital-apms-progress.git] / process / report / tenant-outgoing-budgets.p
blobe3d374db4ee29489f642375885819f1455e96163
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
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 expense-reconciliation AS LOGI NO-UNDO INIT No.
12 DEF VAR tenant-code AS INT NO-UNDO INIT ?.
13 DEF VAR property-code AS INT NO-UNDO INIT ?.
14 DEF VAR generate-transactions AS LOGI NO-UNDO INIT No.
15 DEF VAR print-letter AS LOGI NO-UNDO INIT No.
16 DEF VAR exporting AS LOGI NO-UNDO INITIAL No.
17 DEF VAR month-ending AS INT NO-UNDO INITIAL ?.
18 RUN parse-parameters.
20 DEF BUFFER ToMonth FOR Month.
21 FIND ToMonth WHERE ToMonth.MonthCode = month-ending NO-LOCK.
23 DEF VAR client-name AS CHAR NO-UNDO.
24 DEF VAR in-reconciliation-summary AS LOGI NO-UNDO INITIAL No.
25 DEF VAR batch-no AS INT NO-UNDO.
26 DEF VAR document-no AS INT NO-UNDO.
27 DEF VAR transaction-no AS INT NO-UNDO.
29 DEF VAR user-name AS CHAR NO-UNDO.
30 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
32 DEF VAR line AS CHAR NO-UNDO.
33 DEF VAR rm AS INT NO-UNDO INITIAL 114.
35 DEF VAR time-font AS CHAR NO-UNDO INITIAL "helvetica,proportional,point,6,normal".
36 DEF VAR fixed-font AS CHAR NO-UNDO INITIAL "courier,fixed,cpi,13,normal,lpi,8".
37 DEF VAR header-font AS CHAR NO-UNDO INITIAL "Times,Point,11,Proportional,Normal,lpi,6.5".
38 DEF VAR letter-font AS CHAR NO-UNDO INITIAL "Times,Point,9.8,Proportional,Normal,lpi,7".
40 DEF TEMP-TABLE TOG NO-UNDO
41 FIELD PropertyCode AS INT
42 FIELD TenantCode AS INT
43 FIELD AccountCode AS DEC
44 FIELD AccountName AS CHAR
45 FIELD Percent AS DEC
46 FIELD Fixed AS DEC
47 FIELD Budget AS DEC
48 FIELD Actual AS DEC
49 FIELD Recovered AS DEC
50 INDEX XPKTOG IS UNIQUE PRIMARY PropertyCode TenantCode AccountCode
51 INDEX XAK1TOG PropertyCode AccountCode .
54 {inc/ofc-this.i}
55 {inc/ofc-acct.i "OUTGOINGS" "outgoings-account"}
56 {inc/ofc-set.i "Accounts-Letters-From" "letters-from"}
57 IF NOT AVAILABLE(OfficeSetting) THEN letters-from = "".
58 {inc/ofc-set-l.i "Tenant-Accounts" "tenant-accounts"}
59 {inc/ofc-acct.i "DEBTORS" "sundry-debtors"}
60 DEF VAR gst-entity LIKE AcctTran.EntityCode NO-UNDO.
61 IF Office.GST <> ? THEN DO:
62 {inc/ofc-acct.i "GST-OUT" "gst-account"}
63 gst-entity = OfficeControlAccount.EntityCode.
64 END.
65 {inc/ofc-set.i "Letterhead-Tray" "letterhead-tray"}
66 IF NOT AVAILABLE(OfficeSetting) THEN letterhead-tray = "".
68 /* _UIB-CODE-BLOCK-END */
69 &ANALYZE-RESUME
72 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
74 /* ******************** Preprocessor Definitions ******************** */
76 &Scoped-define PROCEDURE-TYPE Procedure
80 /* _UIB-PREPROCESSOR-BLOCK-END */
81 &ANALYZE-RESUME
84 /* ************************ Function Prototypes ********************** */
86 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD add-tog Procedure
87 FUNCTION add-tog RETURNS LOGICAL
88 ( INPUT pc AS INT, INPUT tc AS INT, INPUT ac AS DEC, INPUT percent AS DEC, INPUT bud AS DEC, INPUT act AS DEC, INPUT fixed AS DEC ) FORWARD.
90 /* _UIB-CODE-BLOCK-END */
91 &ANALYZE-RESUME
93 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD clear-togs Procedure
94 FUNCTION clear-togs RETURNS LOGICAL
95 ( /* parameter-definitions */ ) FORWARD.
97 /* _UIB-CODE-BLOCK-END */
98 &ANALYZE-RESUME
100 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-balance Procedure
101 FUNCTION get-balance RETURNS DECIMAL
102 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC ) FORWARD.
104 /* _UIB-CODE-BLOCK-END */
105 &ANALYZE-RESUME
107 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-outgoings-billed Procedure
108 FUNCTION get-outgoings-billed RETURNS DECIMAL
109 ( INPUT tc AS INT ) FORWARD.
111 /* _UIB-CODE-BLOCK-END */
112 &ANALYZE-RESUME
114 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD make-transaction Procedure
115 FUNCTION make-transaction RETURNS LOGICAL
116 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT txt AS CHAR, INPUT amnt AS DEC ) FORWARD.
118 /* _UIB-CODE-BLOCK-END */
119 &ANALYZE-RESUME
121 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD print-tog Procedure
122 FUNCTION print-tog RETURNS CHARACTER
123 (INPUT-OUTPUT year-total AS DEC, INPUT-OUTPUT month-total AS DEC ) FORWARD.
125 /* _UIB-CODE-BLOCK-END */
126 &ANALYZE-RESUME
129 /* *********************** Procedure Settings ************************ */
131 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
132 /* Settings for THIS-PROCEDURE
133 Type: Procedure
134 Allow:
135 Frames: 0
136 Add Fields to: Neither
137 Other Settings: CODE-ONLY COMPILE
139 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
141 /* ************************* Create Window ************************** */
143 &ANALYZE-SUSPEND _CREATE-WINDOW
144 /* DESIGN Window definition (used by the UIB)
145 CREATE WINDOW Procedure ASSIGN
146 HEIGHT = .35
147 WIDTH = 51.14.
148 /* END WINDOW DEFINITION */
150 &ANALYZE-RESUME
154 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
155 /* ************************* Included-Libraries *********************** */
157 {inc/method/m-txtrep.i}
158 {inc/entity.i}
159 {inc/convert.i}
161 /* _UIB-CODE-BLOCK-END */
162 &ANALYZE-RESUME
166 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
169 /* *************************** Main Block *************************** */
170 {inc/username.i "user-name"}
171 timeStamp = STRING( ToMonth.EndDate, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
173 RUN pclrep-start( preview, "reset,portrait,tm,2,a4,lm,10,courier,cpi,12,lpi,7.5"
174 + (IF letterhead-tray <> "" THEN ",bin," + letterhead-tray ELSE "") ).
175 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
177 RUN tenant-outgoing-budgets.
179 OUTPUT CLOSE.
181 RUN pclrep-finish.
183 /* _UIB-CODE-BLOCK-END */
184 &ANALYZE-RESUME
187 /* ********************** Internal Procedures *********************** */
189 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-reconciliation-batch Procedure
190 PROCEDURE build-reconciliation-batch :
191 /*------------------------------------------------------------------------------
192 Purpose:
193 ------------------------------------------------------------------------------*/
194 DEF VAR recovered AS DEC NO-UNDO INITIAL 0.00 .
195 DEF VAR outgoings AS DEC NO-UNDO INITIAL 0.00 .
197 batch-creation:
198 DO TRANSACTION ON ERROR UNDO batch-creation, RETURN ERROR "FAIL":
200 /* Create the batch */
201 CREATE NewBatch.
202 ASSIGN NewBatch.BatchType = 'AUTO'
203 NewBatch.Description = "Expense Reconciliation - P"
204 + STRING( Property.PropertyCode, "99999") + " - "
205 + STRING( ToMonth.EndDate, "99/99/9999" ).
207 batch-no = NewBatch.BatchCode .
208 document-no = 0.
209 /* first the tenants reconciliations */
210 FOR EACH TOG WHERE TOG.PropertyCode = Property.PropertyCode
211 BREAK BY TOG.TenantCode:
212 recovered = recovered + TOG.Recovered .
213 IF LAST-OF(TOG.TenantCode) THEN DO:
214 document-no = document-no + 1.
215 outgoings = get-outgoings-billed( TOG.TenantCode ).
216 make-transaction( "T", TOG.TenantCode, outgoings-account,
217 "Clear Outgoings billed T" + STRING( TOG.TenantCode, "99999") + " to " + STRING(ToMonth.EndDate,"99/99/9999"), - outgoings ).
218 recovered = (recovered + outgoings).
219 make-transaction( "T", TOG.TenantCode, sundry-debtors,
220 "Bal. of Outgoings Due to " + STRING(ToMonth.EndDate,"99/99/9999"), recovered ).
222 /* GST */
223 recovered = ROUND( recovered * (Office.GST / 100), 2).
224 make-transaction( "T", TOG.TenantCode, sundry-debtors,
225 "GST, Bal. of Outgoings Due to " + STRING(ToMonth.EndDate,"99/99/9999"), recovered ).
226 IF tenant-accounts THEN
227 make-transaction( "P", TOG.PropertyCode, gst-account,
228 "GST, Bal. of Outgoings Due to " + STRING(ToMonth.EndDate,"99/99/9999"), - recovered ).
229 ELSE
230 make-transaction( "L", gst-entity, gst-account,
231 "GST, Bal. of Outgoings Due to " + STRING(ToMonth.EndDate,"99/99/9999"), - recovered ).
232 recovered = 0.
233 END.
234 END.
237 /* Now the property accounts changes */
238 recovered = 0.0 .
239 FOR EACH TOG WHERE TOG.PropertyCode = Property.PropertyCode
240 BREAK BY TOG.AccountCode:
241 recovered = recovered + TOG.Recovered .
242 IF LAST-OF(AccountCode) THEN DO:
243 FIND ChartOfAccount OF TOG NO-LOCK.
244 document-no = document-no + 1.
245 make-transaction( "P", Property.PropertyCode, TOG.AccountCode + 0.1,
246 "Reconciliation of recoveries to " + STRING(ToMonth.EndDate,"99/99/9999"), - recovered ).
248 actual = get-balance( "P", Property.PropertyCode, TOG.AccountCode ).
249 make-transaction( "P", Property.PropertyCode, TOG.AccountCode + 0.0,
250 "Xfr .0 to .3, Reconcile to " + STRING(ToMonth.EndDate,"99/99/9999"), - actual ).
251 make-transaction( "P", Property.PropertyCode, TOG.AccountCode + 0.3,
252 "Xfr .0 to .3, Reconcile to " + STRING(ToMonth.EndDate,"99/99/9999"), actual ).
253 recovered = 0 .
254 END.
255 END.
257 END. /* of transaction block */
259 END PROCEDURE.
261 /* _UIB-CODE-BLOCK-END */
262 &ANALYZE-RESUME
265 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-lease Procedure
266 PROCEDURE each-lease :
267 /*------------------------------------------------------------------------------
268 Purpose:
269 ------------------------------------------------------------------------------*/
271 FOR EACH TenancyOutgoing OF TenancyLease NO-LOCK:
272 add-tog( Property.PropertyCode, Tenant.TenantCode, TenancyOutgoing.AccountCode,
273 TenancyOutgoing.Percent, 0.0, 0.0, TenancyOutgoing.FixedAmount ).
274 END.
276 FOR EACH ChartOfAccount NO-LOCK WHERE ChartOfAccount.ExpenseRecoveryType = "P"
277 AND NOT CAN-FIND( TenancyOutgoing OF TenancyLease WHERE TenancyOutgoing.AccountCode = ChartOfAccount.AccountCode ):
278 add-tog( Property.PropertyCode, Tenant.TenantCode, ChartOfAccount.AccountCode,
279 TenancyLease.OutgoingsRate, 0.0, 0.0, 0.0 ).
280 END.
283 FOR EACH PropertyOutgoing OF Property WHERE
284 NOT CAN-FIND( TenancyOutgoing OF TenancyLease WHERE TenancyOutgoing.AccountCode = PropertyOutgoing.AccountCode ) NO-LOCK:
285 add-tog( Property.PropertyCode, Tenant.TenantCode, PropertyOutgoing.AccountCode,
286 TenancyLease.OutgoingsRate, 0.0, 0.0, 0.0 ).
287 END.
290 FOR EACH PropertyOutgoing OF Property NO-LOCK:
291 FIND TOG WHERE TOG.PropertyCode = Property.PropertyCode
292 AND TOG.TenantCode = Tenant.TenantCode
293 AND TOG.AccountCode = PropertyOutgoing.AccountCode
294 EXCLUSIVE-LOCK NO-ERROR.
295 IF AVAILABLE(TOG) THEN TOG.Budget = PropertyOutgoing.BudgetAmount .
296 END.
298 FOR EACH TOG WHERE TOG.PropertyCode = Property.PropertyCode
299 AND TOG.TenantCode = Tenant.TenantCode EXCLUSIVE-LOCK:
300 TOG.Actual = get-balance( "P", Property.PropertyCode, TOG.AccountCode ).
301 END.
303 END PROCEDURE.
305 /* _UIB-CODE-BLOCK-END */
306 &ANALYZE-RESUME
309 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
310 PROCEDURE each-tenant :
311 /*------------------------------------------------------------------------------
312 Purpose:
313 ------------------------------------------------------------------------------*/
314 DEF VAR share-total AS DEC NO-UNDO INITIAL 0.0 .
315 DEF VAR monthly-total AS DEC NO-UNDO INITIAL 0.0 .
316 DEF VAR outgoings-billed AS DEC NO-UNDO.
317 DEF VAR column-no AS INT NO-UNDO.
319 FOR EACH TenancyLease OF Tenant WHERE TenancyLease.LeaseStatus <> "PAST"
320 AND TenancyLease.RecoveryType = "B" NO-LOCK:
321 RUN each-lease.
322 END.
323 FOR EACH TOG WHERE TOG.PropertyCode = Property.PropertyCode
324 AND TOG.TenantCode = Tenant.TenantCode
325 AND TOG.Fixed = 0
326 AND (((NOT expense-reconciliation) AND TOG.Budget = 0)
327 OR (expense-reconciliation AND TOG.Actual = 0)):
328 DELETE TOG.
329 END.
331 IF NOT CAN-FIND( FIRST TOG WHERE TOG.PropertyCode = Property.PropertyCode
332 AND TOG.TenantCode = Tenant.TenantCode )
333 THEN RETURN.
335 RUN print-preamble.
337 RUN pclrep-down-by(1).
338 IF expense-reconciliation THEN
339 line = "Account Name" + SPC(25) + "Actual Percent Your Share".
340 ELSE
341 line = "Account Name" + SPC(20) + "Full Budget Percent Your Share Monthly".
342 RUN pclrep-line( fixed-font + ",bold", line ).
344 FOR EACH TOG WHERE TOG.PropertyCode = Property.PropertyCode
345 AND TOG.TenantCode = Tenant.TenantCode NO-LOCK:
346 line = print-tog( INPUT-OUTPUT share-total, INPUT-OUTPUT monthly-total).
347 RUN pclrep-line( fixed-font, line ).
348 END.
350 IF expense-reconciliation THEN
351 line = FILL(" ", 54) + FILL( "-", 13).
352 ELSE
353 line = FILL(" ", 54) + FILL( "=", 13) + " " + FILL( "=", 12).
354 RUN pclrep-line( fixed-font, line ).
356 line = STRING( share-total, ">,>>>,>>9.99CR") + " " .
357 IF expense-reconciliation THEN
358 line = STRING("Actual Outgoings", "X(53)") + line .
359 ELSE
360 line = FILL(" ",53) + line + STRING( monthly-total, ">>>,>>9.99CR").
361 RUN pclrep-line( fixed-font, line ).
363 IF expense-reconciliation THEN DO:
364 outgoings-billed = get-outgoings-billed(Tenant.TenantCode).
365 RUN pclrep-down-by(1).
366 line = STRING("Less Outgoings Billed", "X(53)") + STRING( outgoings-billed, ">,>>>,>>9.99CR").
367 RUN pclrep-line( fixed-font, line ).
368 line = FILL(" ", 54) + FILL( "-", 13).
369 RUN pclrep-line( fixed-font, line ).
370 share-total = share-total + outgoings-billed . /* OG billed is a credit */
371 line = STRING("Balance of Outgoings Due", "X(53)") + STRING( share-total, ">,>>>,>>9.99CR").
372 RUN pclrep-line( fixed-font, line ).
373 column-no = 53.
374 monthly-total = share-total .
375 END.
376 ELSE
377 column-no = 66.
379 IF Office.GST <> ? THEN DO:
380 RUN pclrep-down-by(1).
381 line = STRING( (IF expense-reconciliation THEN "Plus GST" ELSE "GST on monthly outgoings"), "X(" + STRING(column-no) + ")")
382 + STRING( (monthly-total * (Office.GST / 100)), ">,>>>,>>9.99CR").
383 RUN pclrep-line( fixed-font, line ).
384 monthly-total = monthly-total + ROUND(monthly-total * (Office.GST / 100), 2).
385 line = FILL(" ", column-no + 2) + FILL( "=", 12).
386 RUN pclrep-line( fixed-font, line ).
387 line = STRING( "Total" + (IF expense-reconciliation THEN " Balance Owing" ELSE ""), "X(" + STRING(column-no) + ")")
388 + STRING( monthly-total, ">,>>>,>>9.99CR").
389 RUN pclrep-line( fixed-font, line ).
390 END.
392 IF print-letter THEN RUN print-letter-closing.
394 RUN pclrep-page-break.
396 END PROCEDURE.
398 /* _UIB-CODE-BLOCK-END */
399 &ANALYZE-RESUME
402 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
403 PROCEDURE inst-page-footer :
404 /*------------------------------------------------------------------------------
405 Purpose: Print any page footer
406 ------------------------------------------------------------------------------*/
408 END PROCEDURE.
410 /* _UIB-CODE-BLOCK-END */
411 &ANALYZE-RESUME
414 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
415 PROCEDURE inst-page-header :
416 /*------------------------------------------------------------------------------
417 Purpose:
418 ------------------------------------------------------------------------------*/
419 IF NOT in-reconciliation-summary THEN RETURN.
421 line = timeStamp.
422 IF NOT exporting THEN DO:
423 line = line + CHR(13) + SPC(275) + "Page: " + STRING( pclrep-page-number ).
424 END.
425 RUN pclrep-line( time-font, line).
427 RUN pclrep-down-by(2).
428 RUN pclrep-line( header-font, SPC(15) + "Reconciliation for " + Property.Name + " (P" + STRING(Property.PropertyCode) + ")" ).
429 RUN pclrep-down-by(0.4).
430 RUN pclrep-line( header-font, "As at " + STRING( ToMonth.EndDate, "99/99/9999")).
431 RUN pclrep-down-by(2).
433 RUN pclrep-line( fixed-font, "A/C Code Account Name Actual Recovered Net").
434 RUN pclrep-down-by(1).
436 END PROCEDURE.
438 /* _UIB-CODE-BLOCK-END */
439 &ANALYZE-RESUME
442 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
443 PROCEDURE parse-parameters :
444 /*------------------------------------------------------------------------------
445 Purpose:
446 ------------------------------------------------------------------------------*/
447 DEF VAR token AS CHAR NO-UNDO.
448 DEF VAR i AS INT NO-UNDO.
450 {inc/showopts.i "report-options"}
452 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
453 token = ENTRY( i, report-options, "~n" ).
455 CASE ENTRY( 1, token ):
456 WHEN "Preview" THEN preview = Yes.
457 WHEN "Property" THEN property-code = INT( ENTRY(2,token ) ).
458 WHEN "Tenant" THEN tenant-code = INT( ENTRY(2,token) ).
459 WHEN "OneProperty" THEN one-property = Yes.
460 WHEN "ExpenseReconciliation" THEN expense-reconciliation = Yes.
461 WHEN "PrintLetter" THEN print-letter = Yes.
462 WHEN "MakeTransactions" THEN generate-transactions = Yes.
463 WHEN "MonthEnding" THEN month-ending = INT( ENTRY(2,token) ).
464 END CASE.
466 END.
468 END PROCEDURE.
470 /* _UIB-CODE-BLOCK-END */
471 &ANALYZE-RESUME
474 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE preamble-address Procedure
475 PROCEDURE preamble-address :
476 /*------------------------------------------------------------------------------
477 Purpose:
478 ------------------------------------------------------------------------------*/
479 DEF VAR i AS INT NO-UNDO.
480 DEF VAR n AS INT NO-UNDO.
481 DEF VAR addr AS CHAR NO-UNDO.
483 RUN process/getaddr.p( "T", Tenant.TenantCode, "BILL", OUTPUT addr ).
484 n = NUM-ENTRIES( addr, "~n" ).
485 RUN date-to-word( TODAY, OUTPUT line ).
487 RUN pclrep-down-by(10).
488 DO i = 1 TO 6:
489 IF i = 3 THEN PUT UNFORMATTED CHR(13) SPACE(105) line CHR(13).
490 RUN pclrep-line( header-font, (IF i > n THEN "" ELSE ENTRY( i, addr, "~n" )) ).
491 END.
493 RUN pclrep-down-by(1.7).
494 RUN pclrep-line( header-font, "Dear Sirs" ).
495 RUN pclrep-down-by(0.8).
496 RUN pclrep-line( header-font + ",bold", "re: " + Property.Name + " (P" + STRING(Property.PropertyCode,"99999") + " / T" + STRING(Tenant.TenantCode,"99999") + ")" ).
497 RUN pclrep-down-by(0.8).
499 END PROCEDURE.
501 /* _UIB-CODE-BLOCK-END */
502 &ANALYZE-RESUME
505 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE preamble-rebudget-letter Procedure
506 PROCEDURE preamble-rebudget-letter :
507 /*------------------------------------------------------------------------------
508 Purpose:
509 ------------------------------------------------------------------------------*/
510 DEF VAR txt AS CHAR NO-UNDO INITIAL "".
512 RUN date-to-word( ToMonth.EndDate + 1, OUTPUT line ).
513 txt =
514 "As the above property has reached the year end for outgoings contributions, a " +
515 "reconciliation has been actioned. This reconciliation will show the " +
516 "amount by which the actual outgoings differ from the estimate of outgoings. " +
517 "The new outgoings figure is due to start on " + line + ", so we have estimated " +
518 "the outgoings payable for the ensuing year and recalculated your regular " +
519 "monthly contribution.".
520 RUN pclrep-paragraph( letter-font, txt, rm, 0 ).
521 RUN pclrep-down-by(0.7).
523 txt =
524 "In order to expedite this change, please find enclosed an automatic " +
525 "payment authority which includes your current rental with the new " +
526 "outgoings contribution plus GST. Please complete the details on the " +
527 "authority and lodge it with your bank as soon as possible.".
528 RUN pclrep-paragraph( letter-font, txt, rm, 0 ).
529 RUN pclrep-down-by(0.7).
531 txt = "The new outgoings contributions have been estimated as follows:".
532 RUN pclrep-line( letter-font, txt ).
534 END PROCEDURE.
536 /* _UIB-CODE-BLOCK-END */
537 &ANALYZE-RESUME
540 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE preamble-reconcile-letter Procedure
541 PROCEDURE preamble-reconcile-letter :
542 /*------------------------------------------------------------------------------
543 Purpose:
544 ------------------------------------------------------------------------------*/
545 DEF VAR txt AS CHAR NO-UNDO INITIAL "".
547 RUN date-to-word( ToMonth.EndDate, OUTPUT line ).
548 txt =
549 "Please find listed below our reconciliation of outgoings contributions for the " +
550 "year ending " + line + ". Your next invoice will include the balance from " +
551 "the calculation below.".
552 RUN pclrep-paragraph( letter-font, txt, rm, 0 ).
554 END PROCEDURE.
556 /* _UIB-CODE-BLOCK-END */
557 &ANALYZE-RESUME
560 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-letter-closing Procedure
561 PROCEDURE print-letter-closing :
562 /*------------------------------------------------------------------------------
563 Purpose:
564 ------------------------------------------------------------------------------*/
565 DEF VAR client-code AS CHAR NO-UNDO.
566 DEF VAR client-name AS CHAR NO-UNDO.
567 DEF VAR txt AS CHAR NO-UNDO.
569 RUN pclrep-down-by(2).
570 txt =
571 "Should you have any queries in relation to this matter, please do not " +
572 "hesitate to contact us.".
573 RUN pclrep-paragraph( letter-font, txt, 110, 0 ).
575 RUN pclrep-down-by(2.6).
576 RUN pclrep-line( letter-font, "Yours sincerely" ).
578 client-code = get-entity-client( Tenant.EntityType, Tenant.EntityCode ).
579 FIND Client WHERE Client.ClientCode = client-code NO-LOCK NO-ERROR.
580 IF AVAILABLE(Client) THEN client-name = Client.LegalName. ELSE client-name = Office.Name .
581 RUN pclrep-down-by(1.2).
582 RUN pclrep-line( header-font + ",bold", client-name ).
583 RUN pclrep-down-by(5).
585 DEF VAR i AS INT NO-UNDO.
586 DEF VAR n AS INT NO-UNDO.
587 n = NUM-ENTRIES(letters-from).
588 DO i = 1 TO n:
589 RUN pclrep-line( letter-font + ",bold", ENTRY(i,letters-from) ).
590 END.
591 END PROCEDURE.
593 /* _UIB-CODE-BLOCK-END */
594 &ANALYZE-RESUME
597 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-preamble Procedure
598 PROCEDURE print-preamble :
599 /*------------------------------------------------------------------------------
600 Purpose:
601 ------------------------------------------------------------------------------*/
602 IF print-letter THEN DO:
603 RUN preamble-address.
604 IF expense-reconciliation THEN
605 RUN preamble-reconcile-letter.
606 ELSE
607 RUN preamble-rebudget-letter.
608 RETURN.
609 END.
611 RUN pclrep-down-by(12).
612 RUN date-to-word( ToMonth.EndDate, OUTPUT line ).
613 RUN pclrep-line( "Times,Point,11,Proportional,Normal", line ).
615 RUN pclrep-down-by(6).
616 RUN pclrep-line( header-font, Tenant.Name + " (T" + STRING(Tenant.TenantCode,"99999") + ")" ).
617 RUN pclrep-down-by(0.3).
618 RUN pclrep-line( header-font, Property.Name + " (P" + STRING(Property.PropertyCode,"99999") + ")" ).
619 IF expense-reconciliation THEN DO:
620 RUN pclrep-down-by(0.3).
621 line = "Expense Reconciliation to " + STRING( ToMonth.EndDate, "99/99/9999").
622 RUN pclrep-line( header-font, line ).
623 END.
625 END PROCEDURE.
627 /* _UIB-CODE-BLOCK-END */
628 &ANALYZE-RESUME
631 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reconciliation-summary Procedure
632 PROCEDURE reconciliation-summary :
633 /*------------------------------------------------------------------------------
634 Purpose:
635 ------------------------------------------------------------------------------*/
636 DEF VAR actual AS DEC NO-UNDO.
637 DEF VAR recovered AS DEC NO-UNDO INITIAL 0.0 .
638 DEF VAR property-actual AS DEC NO-UNDO INITIAL 0.0 .
639 DEF VAR property-recovered AS DEC NO-UNDO INITIAL 0.0 .
641 DEF VAR r AS INT NO-UNDO.
642 DEF VAR c AS INT NO-UNDO.
643 DEF VAR control-codes AS CHAR NO-UNDO.
644 RUN make-control-string( "PCL", "reset,eject,portrait,normal,bin,0", OUTPUT control-codes, OUTPUT c, OUTPUT r).
645 PUT CONTROL control-codes .
647 in-reconciliation-summary = Yes.
648 FOR EACH TOG WHERE TOG.PropertyCode = Property.PropertyCode
649 BREAK BY TOG.AccountCode:
650 recovered = recovered + TOG.Recovered .
651 IF LAST-OF(AccountCode) THEN DO:
652 FIND ChartOfAccount OF TOG NO-LOCK.
653 actual = (IF ChartOfAccount.ExpenseRecoveryType = "O" THEN recovered ELSE TOG.Actual).
654 line = STRING( TOG.AccountCode, "9999.99") + " "
655 + STRING( ChartOfAccount.Name, "X(30)" ) + " "
656 + STRING( actual, ">,>>>,>>9.99CR") + " "
657 + STRING( recovered, ">,>>>,>>9.99CR") + " "
658 + STRING( actual - recovered, ">,>>>,>>9.99CR").
659 RUN pclrep-line( fixed-font, line ).
660 property-actual = property-actual + actual.
661 property-recovered = property-recovered + recovered.
662 recovered = 0.
663 END.
664 END.
666 line = FILL(" ",39) + FILL( " "+ FILL("-",13), 3).
667 RUN pclrep-line( fixed-font, line ).
669 line = STRING("Total","X(39)" ) + STRING( property-actual, ">,>>>,>>9.99CR") + " "
670 + STRING( property-recovered, ">,>>>,>>9.99CR") + " "
671 + STRING( property-actual - property-recovered, ">,>>>,>>9.99CR").
672 RUN pclrep-line( fixed-font, line ).
674 END PROCEDURE.
676 /* _UIB-CODE-BLOCK-END */
677 &ANALYZE-RESUME
680 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE tenant-outgoing-budgets Procedure
681 PROCEDURE tenant-outgoing-budgets :
682 /*------------------------------------------------------------------------------
683 Purpose:
684 ------------------------------------------------------------------------------*/
685 IF one-property THEN DO:
686 FIND Property WHERE Property.PropertyCode = property-code NO-LOCK.
687 clear-togs().
688 FOR EACH Tenant WHERE Tenant.Active
689 AND Tenant.EntityType = "P"
690 AND Tenant.EntityCode = Property.PropertyCode NO-LOCK:
691 RUN each-tenant.
692 END.
693 IF expense-reconciliation THEN DO:
694 RUN reconciliation-summary.
695 IF generate-transactions THEN RUN build-reconciliation-batch.
696 END.
697 END.
698 ELSE DO:
699 FIND Tenant WHERE Tenant.TenantCode = tenant-code NO-LOCK.
700 IF Tenant.EntityType <> "P" THEN DO:
701 MESSAGE "Tenant for report must be a tenant of a property"
702 VIEW-AS ALERT-BOX ERROR.
703 RETURN.
704 END.
705 FIND Property WHERE Property.PropertyCode = Tenant.EntityCode NO-LOCK.
706 RUN each-tenant.
707 END.
708 END PROCEDURE.
710 /* _UIB-CODE-BLOCK-END */
711 &ANALYZE-RESUME
714 /* ************************ Function Implementations ***************** */
716 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION add-tog Procedure
717 FUNCTION add-tog RETURNS LOGICAL
718 ( INPUT pc AS INT, INPUT tc AS INT, INPUT ac AS DEC, INPUT percent AS DEC, INPUT bud AS DEC, INPUT act AS DEC, INPUT fixed AS DEC ) :
719 /*------------------------------------------------------------------------------
720 Purpose:
721 Notes:
722 ------------------------------------------------------------------------------*/
723 IF percent = 0 AND fixed = 0 THEN RETURN No.
725 FIND TOG WHERE TOG.PropertyCode = pc AND TOG.TenantCode = tc
726 AND TOG.AccountCode = ac EXCLUSIVE-LOCK NO-ERROR.
727 IF NOT AVAILABLE(TOG) THEN DO:
728 CREATE TOG.
729 ASSIGN TOG.PropertyCode = pc
730 TOG.TenantCode = tc
731 TOG.AccountCode = ac.
732 END.
734 TOG.Percent = TOG.Percent + percent.
735 TOG.Fixed = TOG.Fixed + fixed.
736 TOG.Budget = TOG.Budget + bud.
737 TOG.Actual = TOG.Actual + act.
739 RETURN True.
741 END FUNCTION.
743 /* _UIB-CODE-BLOCK-END */
744 &ANALYZE-RESUME
747 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION clear-togs Procedure
748 FUNCTION clear-togs RETURNS LOGICAL
749 ( /* parameter-definitions */ ) :
750 /*------------------------------------------------------------------------------
751 Purpose:
752 Notes:
753 ------------------------------------------------------------------------------*/
754 FOR EACH TOG: DELETE TOG. END.
756 RETURN True.
758 END FUNCTION.
760 /* _UIB-CODE-BLOCK-END */
761 &ANALYZE-RESUME
764 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-balance Procedure
765 FUNCTION get-balance RETURNS DECIMAL
766 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC ) :
767 /*------------------------------------------------------------------------------
768 Purpose:
769 Notes:
770 ------------------------------------------------------------------------------*/
771 DEF VAR balance AS DEC NO-UNDO INITIAL 0.0 .
773 FOR EACH AccountBalance WHERE AccountBalance.EntityType = et
774 AND AccountBalance.EntityCode = ec
775 AND AccountBalance.AccountCode = ac
776 AND AccountBalance.MonthCode <= month-ending
777 AND AccountBalance.Balance <> 0.0 NO-LOCK:
778 balance = balance + AccountBalance.Balance.
779 END.
780 RETURN balance.
782 END FUNCTION.
784 /* _UIB-CODE-BLOCK-END */
785 &ANALYZE-RESUME
788 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-outgoings-billed Procedure
789 FUNCTION get-outgoings-billed RETURNS DECIMAL
790 ( INPUT tc AS INT ) :
791 /*------------------------------------------------------------------------------
792 Purpose:
793 Notes:
794 ------------------------------------------------------------------------------*/
795 RETURN get-balance( "T", tc, outgoings-account ).
797 END FUNCTION.
799 /* _UIB-CODE-BLOCK-END */
800 &ANALYZE-RESUME
803 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION make-transaction Procedure
804 FUNCTION make-transaction RETURNS LOGICAL
805 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT txt AS CHAR, INPUT amnt AS DEC ) :
806 /*------------------------------------------------------------------------------
807 Purpose:
808 Notes:
809 ------------------------------------------------------------------------------*/
811 IF amnt = 0 THEN RETURN No.
813 FIND NewDocument WHERE NewDocument.BatchCode = batch-no
814 AND NewDocument.DocumentCode = document-no NO-LOCK NO-ERROR.
815 IF NOT AVAILABLE(NewDocument) THEN DO:
816 CREATE NewDocument.
817 NewDocument.BatchCode = batch-no.
818 NewDocument.DocumentCode = document-no.
819 NewDocument.DocumentType = "XREC".
820 NewDocument.Reference = STRING(batch-no) + "/" + STRING(document-no).
821 NewDocument.Description = txt.
822 transaction-no = 0.
823 END.
825 transaction-no = transaction-no + 1.
827 CREATE NewAcctTrans.
828 NewAcctTrans.BatchCode = batch-no.
829 NewAcctTrans.DocumentCode = document-no.
830 /* NewAcctTrans.TransactionCode = transaction-no. */
831 NewAcctTrans.EntityType = et.
832 NewAcctTrans.EntityCode = ec.
833 NewAcctTrans.AccountCode = ac.
834 NewAcctTrans.Amount = amnt.
835 NewAcctTrans.Date = ToMonth.EndDate.
836 NewAcctTrans.Description = txt.
837 NewAcctTrans.Reference = STRING(batch-no) + "/" + STRING(document-no) + "/" + STRING(transaction-no).
839 RETURN Yes.
841 END FUNCTION.
843 /* _UIB-CODE-BLOCK-END */
844 &ANALYZE-RESUME
847 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION print-tog Procedure
848 FUNCTION print-tog RETURNS CHARACTER
849 (INPUT-OUTPUT year-total AS DEC, INPUT-OUTPUT month-total AS DEC ) :
850 /*------------------------------------------------------------------------------
851 Purpose:
852 Notes:
853 ------------------------------------------------------------------------------*/
854 DEF VAR coa-name AS CHAR NO-UNDO INITIAL "* * * Unknown A/C * * *".
855 DEF VAR line AS CHAR NO-UNDO.
857 FIND FIRST ChartOfAccount OF TOG NO-LOCK NO-ERROR.
858 IF AVAILABLE(ChartOfAccount) THEN coa-name = ChartOfAccount.Name .
860 line = STRING( coa-name, "X(30)") + " ".
861 IF TOG.Fixed > 0 THEN DO:
862 TOG.Recovered = TOG.Fixed.
863 line = line + FILL( " ", 22).
864 END.
865 ELSE DO:
866 TOG.Recovered = (IF expense-reconciliation THEN Tog.Actual ELSE TOG.Budget).
867 line = line + STRING( TOG.Recovered, ">,>>>,>>9.99CR") + " "
868 + STRING( TOG.Percent, ">>9.99") + " ".
869 TOG.Recovered = ROUND( TOG.Recovered * (TOG.Percent / 100), 2) .
870 END.
872 year-total = year-total + TOG.Recovered.
873 month-total = month-total + ROUND( TOG.Recovered / 12, 2).
875 line = line + STRING( TOG.Recovered, ">,>>>,>>9.99CR") .
876 IF NOT expense-reconciliation THEN DO:
877 line = line + " " + STRING( TOG.Recovered / 12, ">>>,>>9.99CR") .
878 END.
880 RETURN line.
882 END FUNCTION.
884 /* _UIB-CODE-BLOCK-END */
885 &ANALYZE-RESUME