Add blank column, rename column.
[capital-apms-progress.git] / process / report / tntagebl.p
blob71a7aee60d9499ffeaf9dd42fc78a525870e41dd
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Tenant Aged Balances Report (or Export)
6 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
9 DEF VAR current-month LIKE Month.MonthCode NO-UNDO.
10 DEF VAR today-name AS CHAR NO-UNDO INITIAL "Today".
11 DEF VAR entity-type AS CHAR NO-UNDO INITIAL "".
12 DEF VAR entity-1 AS INT NO-UNDO.
13 DEF VAR entity-n AS INT NO-UNDO.
14 DEF VAR non-property AS LOGICAL NO-UNDO INITIAL No.
15 DEF VAR by-debt-class AS LOGI NO-UNDO INITIAL No.
16 DEF VAR by-manager AS LOGI NO-UNDO INITIAL No.
17 DEF VAR by-company AS LOGI NO-UNDO INITIAL No.
18 DEF VAR summary AS LOGI NO-UNDO.
19 DEF VAR preview AS LOGI NO-UNDO.
20 DEF VAR exclude-rent AS LOGI NO-UNDO.
21 DEF VAR hide-ignored AS LOGI NO-UNDO INITIAL NO.
22 DEF VAR tenant-order AS CHAR NO-UNDO INITIAL "A".
23 DEF VAR exporting AS LOGI NO-UNDO.
24 DEF VAR check-entity-range AS LOGI NO-UNDO INITIAL No.
25 DEF VAR file-name AS CHAR NO-UNDO.
26 DEF VAR list-name AS CHAR NO-UNDO.
27 DEF VAR use-closed-flags AS LOGI NO-UNDO INITIAL Yes.
28 DEF VAR min-abs-balance LIKE AccountSummary.Balance NO-UNDO INITIAL ?.
29 DEF VAR min-debit-balance LIKE AccountSummary.Balance NO-UNDO INITIAL ?.
30 DEF VAR overdue-balance LIKE AccountSummary.Balance NO-UNDO INITIAL ?.
31 DEF VAR overdue-periods AS INT NO-UNDO INITIAL ?.
32 DEF VAR option-description AS CHAR NO-UNDO INITIAL "".
33 RUN parse-parameters.
35 /* Report counters */
36 &SCOPED-DEFINE lines-per-page 85
37 DEF VAR ln AS DEC INIT 0.00 NO-UNDO.
39 DEF VAR need-property-header AS LOGI INITIAL Yes NO-UNDO.
40 DEF VAR this-break-value AS INT NO-UNDO.
41 DEF VAR this-break-name AS CHAR NO-UNDO.
43 /* Line definitions */
44 DEF VAR trn-line AS CHAR NO-UNDO.
45 DEF VAR trn-no AS INT NO-UNDO.
47 DEF VAR reset-page AS CHAR NO-UNDO.
48 DEF VAR half-line AS CHAR NO-UNDO. half-line = CHR(27) + "=".
49 DEF VAR title-font AS CHAR NO-UNDO.
50 DEF VAR time-font AS CHAR NO-UNDO.
51 DEF VAR property-font AS CHAR NO-UNDO.
52 DEF VAR break-font AS CHAR NO-UNDO.
53 DEF VAR line-printer AS CHAR NO-UNDO.
54 DEF VAR amt-fmt AS CHAR INIT "(>>,>>>,>>9.99)" NO-UNDO.
55 DEF VAR i AS INT NO-UNDO.
57 DEF VAR last-break-value LIKE Property.Manager NO-UNDO INITIAL ?.
58 DEF VAR tnt-tot AS DEC EXTENT 5 NO-UNDO.
59 DEF VAR prp-tot AS DEC EXTENT 7 NO-UNDO.
60 DEF VAR brk-tot AS DEC EXTENT 7 NO-UNDO.
61 DEF VAR gnd-tot AS DEC EXTENT 7 INITIAL 0 NO-UNDO.
63 DEF BUFFER Month0 FOR Month.
64 DEF BUFFER Month1 FOR Month.
65 DEF BUFFER Month2 FOR Month.
67 DEF VAR now AS CHAR NO-UNDO.
68 DEF VAR page-no AS INT NO-UNDO INIT 1.
70 DEF VAR user-name AS CHAR NO-UNDO.
71 {inc/ofc-this.i}
72 {inc/ofc-acct.i "DEBTORS" "sundry-debtors"}
74 /* _UIB-CODE-BLOCK-END */
75 &ANALYZE-RESUME
78 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
80 /* ******************** Preprocessor Definitions ******************** */
82 &Scoped-define PROCEDURE-TYPE Procedure
83 &Scoped-define DB-AWARE no
87 /* _UIB-PREPROCESSOR-BLOCK-END */
88 &ANALYZE-RESUME
91 /* ************************ Function Prototypes ********************** */
93 &IF DEFINED(EXCLUDE-include-tenant) = 0 &THEN
95 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-tenant Procedure
96 FUNCTION include-tenant RETURNS LOGICAL
97 ( INPUT tenant-code AS INT, INPUT bal-0 AS DEC, INPUT bal-1 AS DEC, INPUT bal-2 AS DEC, INPUT bal-3 AS DEC ) FORWARD.
99 /* _UIB-CODE-BLOCK-END */
100 &ANALYZE-RESUME
102 &ENDIF
104 &IF DEFINED(EXCLUDE-include-tenant-entity) = 0 &THEN
106 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-tenant-entity Procedure
107 FUNCTION include-tenant-entity RETURNS LOGICAL
108 ( /* parameter-definitions */ ) FORWARD.
110 /* _UIB-CODE-BLOCK-END */
111 &ANALYZE-RESUME
113 &ENDIF
115 &IF DEFINED(EXCLUDE-non-zero-property) = 0 &THEN
117 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD non-zero-property Procedure
118 FUNCTION non-zero-property RETURNS LOGICAL
119 ( /* parameter-definitions */ ) FORWARD.
121 /* _UIB-CODE-BLOCK-END */
122 &ANALYZE-RESUME
124 &ENDIF
126 &IF DEFINED(EXCLUDE-non-zero-tenant) = 0 &THEN
128 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD non-zero-tenant Procedure
129 FUNCTION non-zero-tenant RETURNS LOGICAL
130 ( /* parameter-definitions */ ) FORWARD.
132 /* _UIB-CODE-BLOCK-END */
133 &ANALYZE-RESUME
135 &ENDIF
138 /* *********************** Procedure Settings ************************ */
140 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
141 /* Settings for THIS-PROCEDURE
142 Type: Procedure
143 Allow:
144 Frames: 0
145 Add Fields to: Neither
146 Other Settings: CODE-ONLY COMPILE
148 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
150 /* ************************* Create Window ************************** */
152 &ANALYZE-SUSPEND _CREATE-WINDOW
153 /* DESIGN Window definition (used by the UIB)
154 CREATE WINDOW Procedure ASSIGN
155 HEIGHT = 38.4
156 WIDTH = 40.
157 /* END WINDOW DEFINITION */
159 &ANALYZE-RESUME
161 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
162 /* ************************* Included-Libraries *********************** */
164 {inc/method/m-txtrep.i}
165 {inc/convert.i}
167 /* _UIB-CODE-BLOCK-END */
168 &ANALYZE-RESUME
174 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
177 /* *************************** Main Block *************************** */
178 {inc/username.i "user-name"}
180 OUTPUT TO VALUE( IF exporting THEN file-name ELSE txtrep-print-file ) KEEP-MESSAGES PAGE-SIZE 0.
182 RUN tenant-aged-balance.
184 OUTPUT CLOSE.
186 IF exporting THEN
187 MESSAGE "Export Complete" VIEW-AS ALERT-BOX INFORMATION TITLE "Finished".
188 ELSE
189 RUN view-output-file ( preview ).
191 /* _UIB-CODE-BLOCK-END */
192 &ANALYZE-RESUME
195 /* ********************** Internal Procedures *********************** */
197 &IF DEFINED(EXCLUDE-allocate-to-totals) = 0 &THEN
199 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE allocate-to-totals Procedure
200 PROCEDURE allocate-to-totals :
201 /*------------------------------------------------------------------------------
202 Purpose:
203 ------------------------------------------------------------------------------*/
205 IF AcctTran.MonthCode < Month2.MonthCode THEN
206 tnt-tot[1] = tnt-tot[1] + AcctTran.Amount.
207 ELSE IF AcctTran.MonthCode = Month2.MonthCode THEN
208 tnt-tot[2] = tnt-tot[2] + AcctTran.Amount.
209 ELSE IF AcctTran.MonthCode = Month1.MonthCode THEN
210 tnt-tot[3] = tnt-tot[3] + AcctTran.Amount.
211 ELSE
212 tnt-tot[4] = tnt-tot[4] + AcctTran.Amount.
214 tnt-tot[5] = tnt-tot[5] + AcctTran.Amount.
216 END PROCEDURE.
218 /* _UIB-CODE-BLOCK-END */
219 &ANALYZE-RESUME
221 &ENDIF
223 &IF DEFINED(EXCLUDE-check-line) = 0 &THEN
225 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-line Procedure
226 PROCEDURE check-line :
227 /*------------------------------------------------------------------------------
228 Purpose:
229 Parameters: <none>
230 Notes:
231 ------------------------------------------------------------------------------*/
233 IF exporting THEN RETURN.
235 IF ln >= {&lines-per-page} THEN DO:
236 RUN page-feed.
237 RUN page-header.
238 END.
240 END PROCEDURE.
242 /* _UIB-CODE-BLOCK-END */
243 &ANALYZE-RESUME
245 &ENDIF
247 &IF DEFINED(EXCLUDE-column-header) = 0 &THEN
249 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE column-header Procedure
250 PROCEDURE column-header :
251 /*------------------------------------------------------------------------------
252 Purpose:
253 Parameters: <none>
254 Notes:
255 ------------------------------------------------------------------------------*/
257 IF exporting THEN DO:
258 PUT UNFORMATTED (IF summary THEN '"Property"' ELSE '"Tenant"')
259 + ',,"Prior to",'
260 + STRING( Month2.StartDate, "99/99/9999" ) + ','
261 + STRING( Month1.StartDate, "99/99/9999" ) + ','
262 + STRING( Month0.StartDate, "99/99/9999" ) + ','
263 + '"Total"'.
264 RUN skip-line(1).
266 PUT UNFORMATTED ',,'
267 + STRING( Month2.StartDate - 1, "99/99/9999" ) + ','
268 + STRING( Month2.EndDate, "99/99/9999" ) + ','
269 + STRING( Month1.EndDate, "99/99/9999" ) + ','
270 + STRING( today-name, "X(15)" ).
271 RUN skip-line(2).
272 END.
273 ELSE DO:
274 RUN skip-line(2).
275 PUT UNFORMATTED
276 STRING( IF summary THEN "Property" ELSE "Tenant", "X(54)" )
277 STRING( "Prior to", "X(15)" )
278 STRING( STRING( Month2.StartDate, "99/99/9999" ) + " to", "X(15)" )
279 STRING( STRING( Month1.StartDate, "99/99/9999" ) + " to", "X(15)" )
280 STRING( STRING( Month0.StartDate, "99/99/9999" ) + " to", "X(15)" )
281 STRING( " Total", "X(15)" ).
282 RUN skip-line(1).
284 PUT UNFORMATTED
285 STRING( "", "X(54)" )
286 STRING( STRING( Month2.StartDate, "99/99/9999" ), "X(15)" )
287 STRING( STRING( Month2.EndDate, "99/99/9999" ), "X(15)" )
288 STRING( STRING( Month1.EndDate, "99/99/9999" ), "X(15)" )
289 STRING( today-name, "X(15)" ).
290 RUN skip-line(2).
291 END.
293 END PROCEDURE.
295 /* _UIB-CODE-BLOCK-END */
296 &ANALYZE-RESUME
298 &ENDIF
300 &IF DEFINED(EXCLUDE-company-header) = 0 &THEN
302 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE company-header Procedure
303 PROCEDURE company-header :
304 /*------------------------------------------------------------------------------
305 Purpose:
306 ------------------------------------------------------------------------------*/
308 RUN check-line.
309 RUN reset-brk-totals.
311 PUT CONTROL break-font.
312 PUT UNFORMATTED (IF AVAILABLE Company THEN Company.LegalName ELSE "Unknown Company" ).
313 PUT CONTROL line-printer.
314 RUN skip-line( IF exporting THEN 1 ELSE 2 ).
316 END PROCEDURE.
318 /* _UIB-CODE-BLOCK-END */
319 &ANALYZE-RESUME
321 &ENDIF
323 &IF DEFINED(EXCLUDE-each-company) = 0 &THEN
325 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-company Procedure
326 PROCEDURE each-company :
327 /*------------------------------------------------------------------------------
328 Purpose:
329 ------------------------------------------------------------------------------*/
330 /* if the user selected non-property only then we don't want to
331 do this bit since it will pick up tenants with entitytype = "P" */
332 IF non-property = FALSE THEN DO:
333 FOR EACH Property OF Company NO-LOCK BY Property.PropertyCode:
334 entity-type = "P".
335 RUN each-property.
336 END.
337 END.
339 entity-type = "L".
340 need-property-header = Yes.
341 RUN reset-prp-totals.
342 IF tenant-order = "A" THEN DO:
343 FOR EACH Tenant WHERE Tenant.EntityType = 'L'
344 AND Tenant.EntityCode = Company.CompanyCode NO-LOCK
345 BY Tenant.EntityType BY Tenant.EntityCode BY Tenant.Name:
346 RUN each-tenant.
347 END.
348 END.
349 ELSE DO:
350 FOR EACH Tenant WHERE Tenant.EntityType = 'L'
351 AND Tenant.EntityCode = Company.CompanyCode NO-LOCK
352 BY Tenant.EntityType BY Tenant.EntityCode BY Tenant.TenantCode:
353 RUN each-tenant.
354 END.
355 END.
357 IF NOT( need-property-header ) OR non-zero-property() THEN
358 RUN total-line( "Non-Property" ).
360 RUN update-brk-totals.
362 END PROCEDURE.
364 /* _UIB-CODE-BLOCK-END */
365 &ANALYZE-RESUME
367 &ENDIF
369 &IF DEFINED(EXCLUDE-each-debt-class) = 0 &THEN
371 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-debt-class Procedure
372 PROCEDURE each-debt-class :
373 /*------------------------------------------------------------------------------
374 Purpose:
375 ------------------------------------------------------------------------------*/
377 need-property-header = Yes.
378 RUN reset-prp-totals.
380 IF tenant-order = "A" THEN DO:
381 FOR EACH Tenant WHERE Tenant.DebtClassification = DebtClassification.DebtClassification NO-LOCK
382 BY Tenant.DebtClassification BY Tenant.Name:
383 RUN each-tenant.
384 END.
385 END.
386 ELSE DO:
387 FOR EACH Tenant WHERE Tenant.DebtClassification = DebtClassification.DebtClassification NO-LOCK
388 BY Tenant.DebtClassification BY Tenant.TenantCode:
389 RUN each-tenant.
390 END.
391 END.
393 IF NOT( need-property-header ) OR non-zero-property() THEN
394 RUN total-line( DebtClassification.DebtClassification + " - " + DebtClassification.Description ).
396 RUN update-brk-totals.
398 END PROCEDURE.
400 /* _UIB-CODE-BLOCK-END */
401 &ANALYZE-RESUME
403 &ENDIF
405 &IF DEFINED(EXCLUDE-each-property) = 0 &THEN
407 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
408 PROCEDURE each-property :
409 /*------------------------------------------------------------------------------
410 Purpose:
411 ------------------------------------------------------------------------------*/
413 need-property-header = Yes.
414 RUN reset-prp-totals.
416 IF tenant-order = "A" THEN DO:
417 FOR EACH Tenant WHERE Tenant.EntityType = 'P'
418 AND Tenant.EntityCode = Property.PropertyCode NO-LOCK
419 BY Tenant.EntityType BY Tenant.EntityCode BY Tenant.Name:
420 RUN each-tenant.
421 END.
422 END.
423 ELSE DO:
424 FOR EACH Tenant WHERE Tenant.EntityType = 'P'
425 AND Tenant.EntityCode = Property.PropertyCode NO-LOCK
426 BY Tenant.EntityType BY Tenant.EntityCode BY Tenant.TenantCode:
427 RUN each-tenant.
428 END.
429 END.
431 IF need-property-header AND NOT( summary) AND ( prp-tot[6] <> 0 OR prp-tot[7] <> 0 ) THEN
432 RUN property-header.
434 IF NOT( need-property-header ) OR non-zero-property() THEN
435 RUN total-line( "Property" ).
437 RUN update-brk-totals.
439 END PROCEDURE.
441 /* _UIB-CODE-BLOCK-END */
442 &ANALYZE-RESUME
444 &ENDIF
446 &IF DEFINED(EXCLUDE-each-tenant) = 0 &THEN
448 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
449 PROCEDURE each-tenant :
450 /*------------------------------------------------------------------------------
451 Purpose:
452 ------------------------------------------------------------------------------*/
453 DEF VAR tnnt-total AS DEC NO-UNDO.
454 DEF VAR extra AS CHAR NO-UNDO INITIAL "".
456 IF NOT include-tenant-entity() THEN RETURN.
457 IF NOT use-closed-flags OR today-name <> "Today" THEN DO:
458 RUN each-tenant-no-flags.
459 END.
461 IF use-closed-flags THEN DO:
462 IF today-name <> "Today" THEN tnnt-total = tnt-tot[5].
463 RUN each-tenant-use-flags.
464 IF today-name <> "Today" AND tnnt-total <> tnt-tot[5] THEN DO:
465 extra = STRING( tnnt-total, amt-fmt).
466 IF exporting THEN TRIM(extra).
467 END.
468 END.
470 IF NOT( include-tenant( Tenant.TenantCode, tnt-tot[4], tnt-tot[3], tnt-tot[2], tnt-tot[1] )) THEN RETURN.
472 IF non-zero-tenant() AND NOT summary THEN DO:
473 IF need-property-header THEN RUN property-header.
474 RUN check-line.
475 IF exporting THEN DO:
476 PUT UNFORMATTED STRING( Tenant.TenantCode ) + ',"' + Tenant.Name + '"'.
478 DO i = 1 TO 5:
479 PUT UNFORMATTED ',' + STRING( tnt-tot[i] ).
480 END.
481 IF extra <> "" THEN PUT UNFORMATTED "," + extra.
482 END.
483 ELSE DO:
484 PUT UNFORMATTED STRING( Tenant.TenantCode, "99999" ) SPACE(2)
485 STRING( Tenant.Name, "X(45)" ) SPACE(2).
487 DO i = 1 TO 5:
488 PUT UNFORMATTED STRING( tnt-tot[i], amt-fmt ).
489 END.
490 IF extra <> "" THEN PUT UNFORMATTED extra.
491 END.
493 RUN skip-line(1).
494 END.
496 END PROCEDURE.
498 /* _UIB-CODE-BLOCK-END */
499 &ANALYZE-RESUME
501 &ENDIF
503 &IF DEFINED(EXCLUDE-each-tenant-no-flags) = 0 &THEN
505 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant-no-flags Procedure
506 PROCEDURE each-tenant-no-flags :
507 /*------------------------------------------------------------------------------
508 Purpose: Without using 'closed' flags
509 ------------------------------------------------------------------------------*/
511 DEF VAR i AS INT NO-UNDO.
513 RUN reset-tnt-totals.
515 FOR EACH AcctTran NO-LOCK WHERE AcctTran.EntityType = 'T'
516 AND AcctTran.EntityCode = Tenant.TenantCode
517 AND AcctTran.AccountCode = sundry-debtors
518 AND AcctTran.MonthCode <= current-month:
519 /* MESSAGE STRING(AcctTran.Reference,"X(12)") STRING(AcctTran.Description,"X(50)") STRING(AcctTran.Amount,">>,>>>,>>9.99CR")
520 STRING(AcctTran.ClosingGroup,">>>,>>9") AcctTran.ClosedState. */
521 RUN allocate-to-totals.
522 END.
524 END PROCEDURE.
526 /* _UIB-CODE-BLOCK-END */
527 &ANALYZE-RESUME
529 &ENDIF
531 &IF DEFINED(EXCLUDE-each-tenant-use-flags) = 0 &THEN
533 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant-use-flags Procedure
534 PROCEDURE each-tenant-use-flags :
535 /*------------------------------------------------------------------------------
536 Purpose: Using 'closed' flags
537 ------------------------------------------------------------------------------*/
538 DEF VAR i AS INT NO-UNDO.
539 DEF VAR d-min AS INT NO-UNDO.
540 DEF VAR d-max AS INT NO-UNDO.
541 DEF VAR group-total AS DEC NO-UNDO.
543 RUN reset-tnt-totals.
545 IF today-name = "Today" THEN DO:
546 /* short-circuit things if we can */
547 FIND AccountSummary WHERE AccountSummary.EntityType = 'T'
548 AND AccountSummary.EntityCode = Tenant.TenantCode
549 AND AccountSummary.AccountCode = sundry-debtors NO-LOCK NO-ERROR.
550 IF NOT AVAILABLE(AccountSummary) OR AccountSummary.Balance = 0 THEN RETURN .
551 END.
553 FOR EACH AcctTran NO-LOCK WHERE AcctTran.EntityType = 'T'
554 AND AcctTran.EntityCode = Tenant.TenantCode
555 AND AcctTran.AccountCode = sundry-debtors
556 AND AcctTran.MonthCode <= current-month
557 AND (AcctTran.ClosingGroup = 0 OR AcctTran.ClosingGroup = ?),
558 FIRST Document OF AcctTran NO-LOCK:
559 IF exclude-rent AND Document.DocumentType = 'RENT' THEN NEXT.
560 RUN allocate-to-totals.
561 END.
563 DEF VAR groups-done AS CHAR NO-UNDO INITIAL "".
564 DEF VAR this-group AS CHAR NO-UNDO.
565 DEF BUFFER ClosedTran FOR AcctTran.
566 part-closed-loop:
567 FOR EACH ClosedTran NO-LOCK WHERE ClosedTran.EntityType = 'T'
568 AND ClosedTran.EntityCode = Tenant.TenantCode
569 AND ClosedTran.AccountCode = sundry-debtors
570 AND ClosedTran.MonthCode <= current-month
571 AND ClosedTran.ClosingGroup > 0
572 AND ClosedTran.ClosedState = "P":
573 this-group = STRING(ClosedTran.ClosingGroup).
574 IF LOOKUP( this-group, groups-done ) > 0 THEN NEXT part-closed-loop.
575 groups-done = groups-done + this-group + ",".
576 d-min = ClosedTran.MonthCode.
577 d-max = ClosedTran.MonthCode.
578 group-total = 0.
579 FOR EACH AcctTran WHERE AcctTran.EntityType = 'T'
580 AND AcctTran.EntityCode = Tenant.TenantCode
581 AND AcctTran.AccountCode = sundry-debtors
582 AND AcctTran.MonthCode <= current-month
583 AND AcctTran.ClosingGroup = ClosedTran.ClosingGroup NO-LOCK,
584 FIRST Document OF AcctTran NO-LOCK:
585 d-min = MIN(d-min, AcctTran.MonthCode).
586 d-max = MAX(d-max, AcctTran.MonthCode).
587 IF exclude-rent AND Document.DocumentType = 'RENT' THEN NEXT.
588 group-total = group-total + AcctTran.Amount.
589 END.
590 IF group-total > 0 THEN d-min = d-max.
591 IF d-min < Month2.MonthCode THEN tnt-tot[1] = tnt-tot[1] + group-total.
592 ELSE IF d-min = Month2.MonthCode THEN tnt-tot[2] = tnt-tot[2] + group-total.
593 ELSE IF d-min = Month1.MonthCode THEN tnt-tot[3] = tnt-tot[3] + group-total.
594 ELSE
595 tnt-tot[4] = tnt-tot[4] + group-total.
597 tnt-tot[5] = tnt-tot[5] + group-total.
598 END.
600 groups-done = "".
601 closed-tran-loop:
602 FOR EACH ClosedTran NO-LOCK WHERE ClosedTran.EntityType = 'T'
603 AND ClosedTran.EntityCode = Tenant.TenantCode
604 AND ClosedTran.AccountCode = sundry-debtors
605 AND ClosedTran.MonthCode > current-month
606 AND ClosedTran.ClosingGroup > 0
607 AND ClosedTran.ClosedState <> "P":
608 this-group = STRING(ClosedTran.ClosingGroup).
609 IF LOOKUP( this-group, groups-done ) > 0 THEN NEXT closed-tran-loop.
610 /* MESSAGE STRING(ClosedTran.Reference,"X(12)") STRING(ClosedTran.Description,"X(50)") STRING(ClosedTran.Amount,">>,>>>,>>9.99CR")
611 STRING(ClosedTran.ClosingGroup,">>>,>>9") ClosedTran.ClosedState " past end of period". */
612 groups-done = groups-done + this-group + ",".
613 d-min = ClosedTran.MonthCode.
614 d-max = ClosedTran.MonthCode.
615 FOR EACH AcctTran WHERE AcctTran.EntityType = 'T'
616 AND AcctTran.EntityCode = Tenant.TenantCode
617 AND AcctTran.AccountCode = sundry-debtors
618 AND AcctTran.MonthCode <= current-month
619 AND AcctTran.ClosingGroup = ClosedTran.ClosingGroup NO-LOCK,
620 FIRST Document OF AcctTran NO-LOCK:
621 IF exclude-rent AND Document.DocumentType = 'RENT' THEN NEXT.
622 /* MESSAGE STRING(AcctTran.Reference,"X(12)") STRING(AcctTran.Description,"X(50)") STRING(AcctTran.Amount,">>,>>>,>>9.99CR")
623 d-min = MIN(d-min, AcctTran.MonthCode).
624 d-max = MAX(d-max, AcctTran.MonthCode).
625 STRING(AcctTran.ClosingGroup,">>>,>>9") AcctTran.ClosedState " ***". */
626 RUN allocate-to-totals.
627 END.
628 END.
630 END PROCEDURE.
632 /* _UIB-CODE-BLOCK-END */
633 &ANALYZE-RESUME
635 &ENDIF
637 &IF DEFINED(EXCLUDE-get-control-strings) = 0 &THEN
639 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure
640 PROCEDURE get-control-strings :
641 /*------------------------------------------------------------------------------
642 Purpose: Get all control strings for this report
643 Parameters: <none>
644 Notes:
645 ------------------------------------------------------------------------------*/
646 DEF VAR rows AS DEC NO-UNDO.
647 DEF VAR cols AS DEC NO-UNDO.
649 RUN make-control-string ( "PCL", "reset,portrait,a4,tm,0,lm,1,LinePrinter,lpi,9.54",
650 OUTPUT reset-page, OUTPUT rows, OUTPUT cols ).
652 IF exporting OR preview THEN DO:
653 half-line = "".
654 IF exporting THEN reset-page = "".
655 RETURN.
656 END.
658 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,12",
659 OUTPUT title-font, OUTPUT rows, OUTPUT cols ).
661 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,6",
662 OUTPUT time-font, OUTPUT rows, OUTPUT cols ).
664 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,12",
665 OUTPUT break-font, OUTPUT rows, OUTPUT cols ).
667 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,8",
668 OUTPUT property-font, OUTPUT rows, OUTPUT cols ).
670 RUN make-control-string ( "PCL", "LinePrinter,lpi,9.54",
671 OUTPUT line-printer, OUTPUT rows, OUTPUT cols ).
673 END PROCEDURE.
675 /* _UIB-CODE-BLOCK-END */
676 &ANALYZE-RESUME
678 &ENDIF
680 &IF DEFINED(EXCLUDE-get-months) = 0 &THEN
682 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-months Procedure
683 PROCEDURE get-months :
684 /*------------------------------------------------------------------------------
685 Purpose:
686 Parameters: <none>
687 Notes:
688 ------------------------------------------------------------------------------*/
690 IF NOT (current-month > 0) THEN DO:
691 FIND FIRST Month WHERE Month.StartDate <= TODAY
692 AND Month.EndDate >= TODAY NO-LOCK NO-ERROR.
693 IF NOT AVAILABLE month THEN RETURN "FAIL".
694 current-month = Month.MonthCode.
695 END.
697 FIND FIRST Month0 WHERE Month0.MonthCode = current-month NO-LOCK NO-ERROR.
698 IF NOT AVAILABLE Month0 THEN RETURN "FAIL".
699 IF today-name = "" THEN today-name = STRING( Month0.EndDate, "99/99/9999").
701 FIND LAST Month1 WHERE Month1.MonthCode < Month0.MonthCode NO-LOCK NO-ERROR.
702 IF NOT AVAILABLE Month1 THEN RETURN "FAIL".
704 FIND LAST Month2 WHERE Month2.MonthCode < Month1.MonthCode NO-LOCK NO-ERROR.
705 IF NOT AVAILABLE Month2 THEN RETURN "FAIL".
707 END PROCEDURE.
709 /* _UIB-CODE-BLOCK-END */
710 &ANALYZE-RESUME
712 &ENDIF
714 &IF DEFINED(EXCLUDE-page-feed) = 0 &THEN
716 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure
717 PROCEDURE page-feed :
718 /*------------------------------------------------------------------------------
719 Purpose:
720 Parameters: <none>
721 Notes:
722 ------------------------------------------------------------------------------*/
723 IF exporting THEN RETURN.
725 PUT CONTROL CHR(12).
726 page-no = page-no + 1.
728 END PROCEDURE.
730 /* _UIB-CODE-BLOCK-END */
731 &ANALYZE-RESUME
733 &ENDIF
735 &IF DEFINED(EXCLUDE-page-header) = 0 &THEN
737 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure
738 PROCEDURE page-header :
739 /*------------------------------------------------------------------------------
740 Purpose:
741 Parameters: <none>
742 Notes:
743 ------------------------------------------------------------------------------*/
745 RUN reset-page.
746 RUN print-title.
747 RUN column-header.
749 END PROCEDURE.
751 /* _UIB-CODE-BLOCK-END */
752 &ANALYZE-RESUME
754 &ENDIF
756 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
758 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
759 PROCEDURE parse-parameters :
760 /*------------------------------------------------------------------------------
761 Purpose:
762 ------------------------------------------------------------------------------*/
763 DEF VAR i AS INT NO-UNDO.
764 DEF VAR token AS CHAR NO-UNDO.
766 {inc/showopts.i "report-options"}
768 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
769 token = ENTRY( i, report-options, "~n" ).
770 CASE( ENTRY( 1, token ) ):
771 WHEN "AtMonthEnd" THEN ASSIGN
772 current-month = INT( ENTRY(2,token) )
773 today-name = "".
774 WHEN "Summary" THEN summary = Yes.
775 WHEN "NoOpenItems" THEN use-closed-flags = No.
776 WHEN "Preview" THEN preview = Yes.
777 WHEN "NonProperty" THEN non-property = Yes.
778 WHEN "ExcludeRent" THEN exclude-rent = Yes.
779 WHEN "HideIgnored" THEN hide-ignored = Yes.
780 WHEN "Sort" THEN DO:
781 by-debt-class = ENTRY(2,token) = "ByDebtClass".
782 by-manager = ENTRY(2,token) = "ByManager".
783 by-company = ENTRY(2,token) = "ByCompany".
784 END.
785 WHEN "TenantOrder" THEN tenant-order = ENTRY(2, token).
786 WHEN "MinAbsBalance" THEN min-abs-balance = DEC( ENTRY(2, token) ).
787 WHEN "MinDebitBalance" THEN min-debit-balance = DEC( ENTRY(2, token) ).
788 WHEN "OverdueBalance" THEN overdue-balance = DEC( ENTRY(2, token) ).
789 WHEN "OverduePeriods" THEN overdue-periods = INT( ENTRY(2, token) ).
791 WHEN "CompanyList" THEN ASSIGN
792 entity-type = "List"
793 list-name = SUBSTRING( token, INDEX( token, ",") + 1 ).
795 WHEN "EntityRange" THEN
796 ASSIGN
797 entity-type = ENTRY(2,token)
798 entity-1 = INT( ENTRY(3, token) )
799 entity-n = INT( ENTRY(4, token) )
800 check-entity-range = Yes.
802 WHEN "Export" THEN ASSIGN
803 exporting = Yes
804 file-name = SUBSTRING( token, INDEX( token, ",") + 1 ).
806 END CASE.
807 END.
809 option-description = "".
810 IF min-debit-balance > 0 THEN
811 option-description = ", Debits only, Minimum current: " + TRIM( STRING( min-debit-balance, "->>,>>>,>>9.99")).
812 ELSE IF min-abs-balance > 0 THEN
813 option-description = ", Minimum current: " + TRIM( STRING( min-abs-balance, "->>,>>>,>>9.99")) .
815 IF overdue-balance > 0 THEN
816 option-description = option-description
817 + ", Minimum " + TRIM( STRING( overdue-balance, "->>,>>>,>>9.99"))
818 + " overdue for more than " + TRIM( STRING( overdue-periods, "->9")) + " months".
820 option-description = substring( option-description, 3).
821 END PROCEDURE.
823 /* _UIB-CODE-BLOCK-END */
824 &ANALYZE-RESUME
826 &ENDIF
828 &IF DEFINED(EXCLUDE-portfolio-header) = 0 &THEN
830 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE portfolio-header Procedure
831 PROCEDURE portfolio-header :
832 /*------------------------------------------------------------------------------
833 Purpose:
834 Parameters: <none>
835 Notes:
836 ------------------------------------------------------------------------------*/
838 RUN check-line.
839 RUN reset-brk-totals.
841 FIND Person WHERE Person.PersonCode = Property.Manager NO-LOCK NO-ERROR.
843 PUT CONTROL break-font.
844 PUT UNFORMATTED (IF AVAILABLE Person THEN CAPS( Person.FirstName + " " + Person.LastName ) ELSE "Other" ).
845 PUT CONTROL line-printer.
846 RUN skip-line( IF exporting THEN 1 ELSE 2 ).
848 END PROCEDURE.
850 /* _UIB-CODE-BLOCK-END */
851 &ANALYZE-RESUME
853 &ENDIF
855 &IF DEFINED(EXCLUDE-print-title) = 0 &THEN
857 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure
858 PROCEDURE print-title :
859 /*------------------------------------------------------------------------------
860 Purpose:
861 ------------------------------------------------------------------------------*/
863 PUT CONTROL line-printer.
864 RUN skip-line(2).
865 PUT CONTROL time-font.
866 PUT UNFORMATTED "Printed: " + now + " for " + user-name.
867 IF NOT exporting THEN DO:
868 PUT UNFORMATTED CHR(13) SPACE( 275 ) "Page: " + STRING( page-no ).
869 END.
870 IF option-description <> "" THEN DO:
871 RUN skip-line(1).
872 PUT UNFORMATTED "Options: " + option-description.
873 END.
874 RUN skip-line(2).
876 PUT CONTROL title-font.
877 PUT UNFORMATTED SPACE(45) "Tenant Aged Balances Report" (IF exclude-rent THEN "Excluding Rent Charges" ELSE "").
878 RUN skip-line(1).
879 PUT CONTROL line-printer.
881 END PROCEDURE.
883 /* _UIB-CODE-BLOCK-END */
884 &ANALYZE-RESUME
886 &ENDIF
888 &IF DEFINED(EXCLUDE-property-header) = 0 &THEN
890 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-header Procedure
891 PROCEDURE property-header :
892 /*------------------------------------------------------------------------------
893 Purpose:
894 ------------------------------------------------------------------------------*/
895 DEF VAR break-entity-name AS CHAR NO-UNDO.
897 need-property-header = No.
899 IF by-debt-class THEN RETURN.
902 IF entity-type = "L" OR (by-company AND AVAILABLE(Company) ) THEN DO:
903 this-break-value = Company.CompanyCode.
904 this-break-name = "Company".
905 END.
906 ELSE DO:
907 this-break-value = Property.Manager.
908 this-break-name = "Portfolio".
909 END.
911 IF last-break-value <> this-break-value THEN DO:
912 IF last-break-value <> ? THEN RUN total-line( this-break-name ).
913 RUN VALUE( this-break-name + "-header").
914 last-break-value = this-break-value.
915 RUN reset-brk-totals.
916 END.
918 RUN check-line.
920 IF AVAILABLE(Property) THEN
921 break-entity-name = STRING( Property.PropertyCode, ">9999" ) + ' - ' + Property.Name.
922 ELSE IF AVAILABLE(Company) THEN
923 break-entity-name = STRING( Company.CompanyCode, ">>999" ) + ' - ' + Company.LegalName.
924 ELSE
925 break-entity-name = "Unknown".
927 IF summary THEN DO:
928 PUT CONTROL line-printer.
929 PUT UNFORMATTED STRING( break-entity-name, "X(52)" ) SPACE(2).
930 END.
931 ELSE DO:
932 PUT CONTROL property-font.
933 PUT UNFORMATTED break-entity-name.
934 PUT CONTROL line-printer.
935 RUN skip-line( IF exporting THEN 1 ELSE 1.5 ).
936 END.
938 END PROCEDURE.
940 /* _UIB-CODE-BLOCK-END */
941 &ANALYZE-RESUME
943 &ENDIF
945 &IF DEFINED(EXCLUDE-reset-brk-totals) = 0 &THEN
947 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-brk-totals Procedure
948 PROCEDURE reset-brk-totals :
949 /*------------------------------------------------------------------------------
950 Purpose:
951 Parameters: <none>
952 Notes:
953 ------------------------------------------------------------------------------*/
955 DEF VAR i AS INT NO-UNDO.
956 DO i = 1 TO 7: brk-tot[i] = 0.00. END.
958 END PROCEDURE.
960 /* _UIB-CODE-BLOCK-END */
961 &ANALYZE-RESUME
963 &ENDIF
965 &IF DEFINED(EXCLUDE-reset-page) = 0 &THEN
967 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure
968 PROCEDURE reset-page :
969 /*------------------------------------------------------------------------------
970 Purpose:
971 Parameters: <none>
972 Notes:
973 ------------------------------------------------------------------------------*/
975 PUT CONTROL reset-page.
976 trn-no = 0.
977 ln = 0.
979 END PROCEDURE.
981 /* _UIB-CODE-BLOCK-END */
982 &ANALYZE-RESUME
984 &ENDIF
986 &IF DEFINED(EXCLUDE-reset-prp-totals) = 0 &THEN
988 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-prp-totals Procedure
989 PROCEDURE reset-prp-totals :
990 /*------------------------------------------------------------------------------
991 Purpose:
992 Parameters: <none>
993 Notes:
994 ------------------------------------------------------------------------------*/
996 DEF VAR i AS INT NO-UNDO.
997 DO i = 1 TO 7: prp-tot[i] = 0.00. END.
999 END PROCEDURE.
1001 /* _UIB-CODE-BLOCK-END */
1002 &ANALYZE-RESUME
1004 &ENDIF
1006 &IF DEFINED(EXCLUDE-reset-tnt-totals) = 0 &THEN
1008 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-tnt-totals Procedure
1009 PROCEDURE reset-tnt-totals :
1010 /*------------------------------------------------------------------------------
1011 Purpose:
1012 Parameters: <none>
1013 Notes:
1014 ------------------------------------------------------------------------------*/
1016 DEF VAR i AS INT NO-UNDO.
1017 DO i = 1 TO 5: tnt-tot[i] = 0.00. END.
1019 END PROCEDURE.
1021 /* _UIB-CODE-BLOCK-END */
1022 &ANALYZE-RESUME
1024 &ENDIF
1026 &IF DEFINED(EXCLUDE-skip-line) = 0 &THEN
1028 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
1029 PROCEDURE skip-line :
1030 /*------------------------------------------------------------------------------
1031 Purpose:
1032 Parameters: <none>
1033 Notes:
1034 ------------------------------------------------------------------------------*/
1036 DEF INPUT PARAMETER n AS DEC NO-UNDO.
1038 IF ln + n >= {&lines-per-page} THEN DO:
1039 RUN page-feed.
1040 RUN page-header.
1041 END.
1043 DEF VAR int-part AS INT NO-UNDO.
1044 DEF VAR dec-part AS DEC NO-UNDO.
1046 int-part = TRUNCATE( n, 0 ).
1047 IF int-part < 0 THEN RETURN.
1048 dec-part = n - int-part.
1049 IF int-part = 0 AND dec-part = 0 THEN RETURN.
1051 IF dec-part <> 0 THEN PUT CONTROL half-line.
1053 IF int-part > 1 THEN PUT SKIP( int-part ).
1054 ELSE IF int-part > 0 THEN PUT SKIP.
1056 IF NOT exporting THEN ln = ln + n.
1058 END PROCEDURE.
1060 /* _UIB-CODE-BLOCK-END */
1061 &ANALYZE-RESUME
1063 &ENDIF
1065 &IF DEFINED(EXCLUDE-tenant-aged-balance) = 0 &THEN
1067 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE tenant-aged-balance Procedure
1068 PROCEDURE tenant-aged-balance :
1069 /*------------------------------------------------------------------------------
1070 Purpose:
1071 ------------------------------------------------------------------------------*/
1072 DEF VAR i AS INT NO-UNDO.
1074 RUN get-months.
1075 IF RETURN-VALUE = "FAIL" THEN DO:
1076 MESSAGE "Report not available for that period".
1077 RETURN.
1078 END.
1079 now = STRING( TODAY, "99/99/9999" ) + " " + STRING( TIME, "HH:MM:SS" ).
1080 RUN get-control-strings.
1081 RUN page-header.
1083 last-break-value = ? .
1085 IF by-debt-class THEN DO:
1086 FOR EACH DebtClassification:
1087 RUN each-debt-class.
1088 END.
1089 need-property-header = Yes.
1090 RUN reset-prp-totals.
1092 IF tenant-order = "A" THEN DO:
1093 FOR EACH Tenant WHERE NOT CAN-FIND( DebtClassification WHERE Tenant.DebtClassification = DebtClassification.DebtClassification) NO-LOCK
1094 BY Tenant.Name:
1095 RUN each-tenant.
1096 END.
1097 END.
1098 ELSE DO:
1099 FOR EACH Tenant WHERE NOT CAN-FIND( DebtClassification WHERE Tenant.DebtClassification = DebtClassification.DebtClassification) NO-LOCK
1100 BY Tenant.TenantCode:
1101 RUN each-tenant.
1102 END.
1103 END.
1105 IF NOT( need-property-header ) OR non-zero-property() THEN
1106 RUN total-line( "Unclassified debtors" ).
1108 RUN update-brk-totals.
1110 END.
1111 ELSE DO:
1112 CASE entity-type:
1113 WHEN "List" THEN DO:
1114 FIND ConsolidationList WHERE ConsolidationList.Name = list-name NO-LOCK.
1115 IF by-manager THEN DO:
1116 entity-type = "P".
1117 FOR EACH Property WHERE CAN-DO( ConsolidationList.CompanyList, STRING(Property.CompanyCode)) NO-LOCK
1118 BY Property.Manager BY Property.PropertyCode:
1119 RUN each-property.
1120 END.
1121 END.
1122 ELSE DO:
1123 entity-type = "L".
1124 FIND ConsolidationList WHERE ConsolidationList.Name = list-name NO-LOCK.
1125 DO i = 1 TO NUM-ENTRIES(ConsolidationList.CompanyList):
1126 FIND Company WHERE Company.CompanyCode = INT( ENTRY(i, ConsolidationList.CompanyList)) NO-LOCK.
1127 RUN each-company.
1128 END.
1129 END.
1130 END.
1131 WHEN "P" THEN DO:
1132 FOR EACH Property WHERE Property.PropertyCode >= entity-1
1133 AND Property.PropertyCode <= entity-n NO-LOCK
1134 BY Property.Manager BY Property.PropertyCode:
1135 RUN each-property.
1136 END.
1137 END.
1138 WHEN "L" THEN DO:
1139 FOR EACH Company WHERE Company.CompanyCode >= entity-1
1140 AND Company.CompanyCode <= entity-n NO-LOCK:
1141 RUN each-company.
1142 END.
1143 END.
1144 END CASE.
1145 END.
1146 IF last-break-value <> ? THEN RUN total-line( this-break-name ).
1148 RUN total-line( "Grand" ).
1149 RUN page-feed.
1151 END PROCEDURE.
1153 /* _UIB-CODE-BLOCK-END */
1154 &ANALYZE-RESUME
1156 &ENDIF
1158 &IF DEFINED(EXCLUDE-total-line) = 0 &THEN
1160 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE total-line Procedure
1161 PROCEDURE total-line :
1162 /*------------------------------------------------------------------------------
1163 Purpose:
1164 Parameters: <none>
1165 Notes:
1166 ------------------------------------------------------------------------------*/
1167 DEF INPUT PARAMETER type AS CHAR NO-UNDO.
1169 DEF VAR i AS INT NO-UNDO.
1170 DEF VAR tot-desc AS CHAR NO-UNDO.
1171 DEF VAR dbt-desc AS CHAR NO-UNDO.
1172 DEF VAR other-debits AS DEC NO-UNDO INITIAL 0.
1173 DEF VAR other-credits AS DEC NO-UNDO INITIAL 0.
1175 IF type = "Grand" AND (NOT summary) THEN RUN skip-line(2).
1176 IF summary AND type = "Non-Property" THEN DO:
1177 tot-desc = "L" + STRING( Company.CompanyCode, "99999") + " - Non-Property Debtors".
1178 END.
1179 ELSE IF summary AND type = "Property" THEN DO:
1180 tot-desc = STRING( Property.PropertyCode, "99999") + " - " + Property.Name.
1181 END.
1182 ELSE DO:
1184 CASE type:
1185 WHEN "Non-Property" THEN
1186 tot-desc = "Total: L" + STRING(Company.CompanyCode) + " - non-property debtors".
1187 WHEN "Property" THEN
1188 tot-desc = "Total: " + Property.Name + " (" + STRING(Property.PropertyCode) + ")".
1189 WHEN "Company" THEN DO:
1190 DEF BUFFER AltCo FOR Company.
1191 FIND AltCo WHERE AltCo.CompanyCode = last-break-value NO-LOCK.
1192 tot-desc = "Total: " + AltCo.LegalName + " (" + STRING(AltCo.CompanyCode) + ")".
1193 END.
1194 OTHERWISE
1195 tot-desc = type + " Totals".
1196 END CASE.
1197 END.
1199 IF exporting THEN DO:
1200 IF NOT( summary AND (type = "Non-Property" OR type = "Property")) THEN DO:
1201 PUT UNFORMATTED ',' + FILL( ',' + FILL('-',14), 7).
1202 RUN skip-line(1).
1203 END.
1204 PUT UNFORMATTED '"' + tot-desc + '",'.
1205 DO i = 1 TO 7:
1206 PUT UNFORMATTED "," + STRING( IF type = "Grand" THEN gnd-tot[i]
1207 ELSE IF type = "Portfolio" THEN brk-tot[i]
1208 ELSE IF type = "Company" THEN brk-tot[i]
1209 ELSE prp-tot[i] ).
1210 END.
1211 END.
1212 ELSE DO:
1213 IF NOT( summary AND (type = "Non-Property" OR type = "Property") ) AND NOT hide-ignored THEN DO:
1214 other-credits = IF type = "Grand" THEN gnd-tot[6] ELSE
1215 IF type = "Portfolio" THEN brk-tot[6] ELSE
1216 IF type = "Company" THEN brk-tot[6] ELSE
1217 prp-tot[6].
1218 other-debits = IF type = "Grand" THEN gnd-tot[7] ELSE
1219 IF type = "Portfolio" THEN brk-tot[7] ELSE
1220 IF type = "Company" THEN brk-tot[7] ELSE
1221 prp-tot[7].
1222 IF other-credits <> 0 OR other-debits <> 0 THEN DO:
1223 PUT UNFORMATTED SPACE(53) FILL( " " + FILL('-',14), 5).
1224 RUN skip-line(1).
1225 PUT UNFORMATTED STRING( REPLACE( tot-desc, "Total", "Debit"), "X(54)").
1226 DO i = 1 TO 5:
1227 PUT UNFORMATTED STRING( IF type = "Grand" THEN gnd-tot[i] ELSE
1228 IF type = "Portfolio" THEN brk-tot[i] ELSE
1229 IF type = "Company" THEN brk-tot[i] ELSE prp-tot[i], amt-fmt ).
1230 END.
1231 RUN skip-line(1).
1232 END.
1233 IF other-credits <> 0 THEN DO:
1234 PUT UNFORMATTED STRING( " Credit balances not shown", "X(114)")
1235 + STRING( other-credits, amt-fmt).
1236 RUN skip-line( 1 ).
1237 END.
1238 IF other-debits <> 0 THEN DO:
1239 PUT UNFORMATTED STRING( " Minor debit balances not shown", "X(114)")
1240 + STRING( other-debits, amt-fmt).
1241 RUN skip-line( 1 ).
1242 END.
1244 END.
1246 IF NOT( summary AND (type = "Non-Property" OR type = "Property")) THEN DO:
1247 PUT UNFORMATTED SPACE(53) FILL( " " + FILL('-',14), 5).
1248 RUN skip-line(1).
1249 END.
1250 PUT UNFORMATTED STRING( tot-desc, "X(54)").
1251 DO i = 1 TO 5:
1252 PUT UNFORMATTED STRING( (IF type = "Grand" THEN gnd-tot[i] ELSE
1253 IF type = "Portfolio" THEN brk-tot[i] ELSE
1254 IF type = "Company" THEN brk-tot[i] ELSE prp-tot[i])
1255 + (IF i=5 AND NOT hide-ignored THEN other-credits + other-debits ELSE 0.0), amt-fmt ).
1256 END.
1257 END.
1258 RUN skip-line( IF type = "Portfolio" OR type = "Company" THEN 3 ELSE IF summary THEN 1 ELSE 2 ).
1260 END PROCEDURE.
1262 /* _UIB-CODE-BLOCK-END */
1263 &ANALYZE-RESUME
1265 &ENDIF
1267 &IF DEFINED(EXCLUDE-update-brk-totals) = 0 &THEN
1269 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-brk-totals Procedure
1270 PROCEDURE update-brk-totals :
1271 /*------------------------------------------------------------------------------
1272 Purpose:
1273 Parameters: <none>
1274 Notes:
1275 ------------------------------------------------------------------------------*/
1277 DEF VAR i AS INT NO-UNDO.
1278 DO i = 1 TO 7:
1279 brk-tot[i] = brk-tot[i] + prp-tot[i].
1280 gnd-tot[i] = gnd-tot[i] + prp-tot[i].
1281 END.
1283 END PROCEDURE.
1285 /* _UIB-CODE-BLOCK-END */
1286 &ANALYZE-RESUME
1288 &ENDIF
1290 /* ************************ Function Implementations ***************** */
1292 &IF DEFINED(EXCLUDE-include-tenant) = 0 &THEN
1294 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-tenant Procedure
1295 FUNCTION include-tenant RETURNS LOGICAL
1296 ( INPUT tenant-code AS INT, INPUT bal-0 AS DEC, INPUT bal-1 AS DEC, INPUT bal-2 AS DEC, INPUT bal-3 AS DEC ) :
1297 /*------------------------------------------------------------------------------
1298 Purpose:
1299 Notes:
1300 ------------------------------------------------------------------------------*/
1301 DEF VAR bal-t AS DEC NO-UNDO.
1302 DEF VAR bal-overdue AS DEC NO-UNDO.
1304 bal-overdue = bal-3.
1305 IF overdue-periods < 3 THEN bal-overdue = bal-overdue + bal-2.
1306 IF overdue-periods < 2 THEN bal-overdue = bal-overdue + bal-1.
1308 bal-t = bal-0 + bal-1 + bal-2 + bal-3.
1310 IF min-abs-balance >= 0.01 OR min-debit-balance >= 0.01 THEN DO:
1311 IF (overdue-balance <> ? AND bal-overdue >= overdue-balance) THEN DO:
1312 IF bal-t < 0 THEN DO:
1313 prp-tot[6] = prp-tot[6] + bal-t.
1314 RETURN No.
1315 END.
1316 /* else fall through to show debtor on report */
1317 END.
1318 ELSE IF (min-debit-balance <> ? AND bal-t < min-debit-balance) THEN DO:
1319 IF bal-t < 0 THEN prp-tot[6] = prp-tot[6] + bal-t.
1320 ELSE ASSIGN prp-tot[7] = prp-tot[7] + bal-t
1321 prp-tot[1] = prp-tot[1] + bal-3
1322 prp-tot[2] = prp-tot[2] + bal-2
1323 prp-tot[3] = prp-tot[3] + bal-1
1324 prp-tot[4] = prp-tot[4] + bal-0 .
1325 RETURN No.
1326 END.
1327 ELSE IF (min-abs-balance <> ? AND ABS(bal-t) < ABS(min-abs-balance)) THEN DO:
1328 IF bal-t < 0 THEN prp-tot[6] = prp-tot[6] + bal-t.
1329 ELSE ASSIGN prp-tot[7] = prp-tot[7] + bal-t
1330 prp-tot[1] = prp-tot[1] + bal-3
1331 prp-tot[2] = prp-tot[2] + bal-2
1332 prp-tot[3] = prp-tot[3] + bal-1
1333 prp-tot[4] = prp-tot[4] + bal-0 .
1334 RETURN No.
1335 END.
1336 END.
1338 prp-tot[1] = prp-tot[1] + bal-3.
1339 prp-tot[2] = prp-tot[2] + bal-2.
1340 prp-tot[3] = prp-tot[3] + bal-1.
1341 prp-tot[4] = prp-tot[4] + bal-0.
1342 prp-tot[5] = prp-tot[5] + bal-t.
1344 RETURN TRUE.
1346 END FUNCTION.
1348 /* _UIB-CODE-BLOCK-END */
1349 &ANALYZE-RESUME
1351 &ENDIF
1353 &IF DEFINED(EXCLUDE-include-tenant-entity) = 0 &THEN
1355 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-tenant-entity Procedure
1356 FUNCTION include-tenant-entity RETURNS LOGICAL
1357 ( /* parameter-definitions */ ) :
1358 /*------------------------------------------------------------------------------
1359 Purpose:
1360 Notes:
1361 ------------------------------------------------------------------------------*/
1363 IF entity-type = "" THEN RETURN TRUE.
1364 IF entity-type <> Tenant.EntityType THEN RETURN FALSE.
1365 IF NOT(check-entity-range) OR (Tenant.EntityCode >= entity-1 AND Tenant.EntityCode <= entity-n) THEN RETURN TRUE.
1367 RETURN FALSE.
1369 END FUNCTION.
1371 /* _UIB-CODE-BLOCK-END */
1372 &ANALYZE-RESUME
1374 &ENDIF
1376 &IF DEFINED(EXCLUDE-non-zero-property) = 0 &THEN
1378 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION non-zero-property Procedure
1379 FUNCTION non-zero-property RETURNS LOGICAL
1380 ( /* parameter-definitions */ ) :
1381 /*------------------------------------------------------------------------------
1382 Purpose: Decide if a property was zero or not
1383 Notes:
1384 ------------------------------------------------------------------------------*/
1386 DEF VAR i AS INT NO-UNDO.
1387 DO i = 1 TO 5:
1388 IF prp-tot[i] <> 0.00 THEN RETURN Yes.
1389 END.
1391 RETURN No. /* All balances were zero */
1393 END FUNCTION.
1395 /* _UIB-CODE-BLOCK-END */
1396 &ANALYZE-RESUME
1398 &ENDIF
1400 &IF DEFINED(EXCLUDE-non-zero-tenant) = 0 &THEN
1402 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION non-zero-tenant Procedure
1403 FUNCTION non-zero-tenant RETURNS LOGICAL
1404 ( /* parameter-definitions */ ) :
1405 /*------------------------------------------------------------------------------
1406 Purpose: Decide if a tenant was zero or not
1407 Notes:
1408 ------------------------------------------------------------------------------*/
1410 DEF VAR i AS INT NO-UNDO.
1411 DO i = 1 TO 5:
1412 IF tnt-tot[i] <> 0.00 THEN RETURN Yes.
1413 END.
1415 RETURN No. /* All balances were zero */
1417 END FUNCTION.
1419 /* _UIB-CODE-BLOCK-END */
1420 &ANALYZE-RESUME
1422 &ENDIF