Add blank column, rename column.
[capital-apms-progress.git] / process / report / invoice-statement.p
blob20f0cb591baad555123ca664da9105dd864ffc57
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File :
6 Purpose :
8 Syntax :
10 Description :
12 Author(s) :
13 Created :
14 Notes :
15 ------------------------------------------------------------------------*/
17 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
19 DEF VAR from-tenant LIKE Tenant.TenantCode NO-UNDO.
20 DEF VAR to-tenant LIKE Tenant.TenantCode NO-UNDO.
21 DEF VAR open-only AS LOGI NO-UNDO INITIAL No.
22 DEF VAR active-only AS LOGI NO-UNDO INITIAL No.
23 DEF VAR prop-code LIKE Property.PropertyCode NO-UNDO.
24 DEF VAR from-month LIKE Month.MonthCode NO-UNDO.
25 DEF VAR to-month LIKE Month.MonthCode NO-UNDO.
26 DEF VAR summarise-part AS LOGI NO-UNDO INITIAL No.
27 DEF VAR statement-date AS DATE NO-UNDO INITIAL TODAY.
28 DEF VAR show-differences AS LOGI NO-UNDO INITIAL No.
29 DEF VAR after-batch AS INT NO-UNDO INITIAL 0.
30 DEF VAR show-zeroes AS LOGI NO-UNDO INITIAL No.
31 DEF VAR hide-aging AS LOGI NO-UNDO INITIAL No.
32 DEF VAR actually-print AS LOGI NO-UNDO INITIAL Yes.
33 DEF VAR print-original AS LOGI NO-UNDO INITIAL Yes.
34 DEF VAR print-copy AS LOGI NO-UNDO INITIAL Yes.
35 DEF VAR show-payments-as-open AS LOGI NO-UNDO INITIAL Yes.
36 RUN parse-parameters.
38 {inc/ofc-this.i}
39 {inc/ofc-set.i "Statement-Contact" "statement-contact"}
40 IF NOT AVAILABLE(OfficeSetting) THEN statement-contact = "".
42 DEF VAR user-name AS CHAR NO-UNDO.
43 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
45 DEF VAR pr-line AS CHAR INIT "" NO-UNDO. /* used everywhere to hold print line */
47 DEF VAR title-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
48 DEF VAR time-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
49 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
50 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
51 DEF VAR base-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,normal".
54 /* global variables used for all tenants */
55 DEF VAR fixed-codes AS CHAR NO-UNDO.
56 DEF VAR variable-codes AS CHAR NO-UNDO.
57 DEF VAR aging-codes AS CHAR NO-UNDO.
58 DEF VAR copy-only AS CHAR NO-UNDO.
59 DEF VAR amount-format AS CHAR NO-UNDO INITIAL ">>>,>>>,>>9.99CR".
60 DEF VAR prompt-font AS CHAR NO-UNDO INITIAL "helvetica,point,10,proportional,normal".
61 DEF VAR data-font AS CHAR NO-UNDO INITIAL "times,point,12,proportional,bold".
62 DEF VAR fixed-font AS CHAR NO-UNDO INITIAL "courier,fixed,cpi,17,fixed,normal".
64 DEF VAR gst-rate AS DEC NO-UNDO.
65 gst-rate = (Office.GST / 100).
67 {inc/ofc-set.i "GST-Number" "gst-number"}
68 IF NOT AVAILABLE(OfficeSetting) THEN
69 gst-number = REPLACE( STRING( Office.GSTNo, ">99,999,999"),",","-") .
70 {inc/ofc-set.i "GST-Number-Name" "gst-number-name"}
71 IF NOT AVAILABLE(OfficeSetting) THEN
72 gst-number-name = "GST NO.".
74 {inc/ofc-set.i "Letterhead-Tray" "letterhead-tray"}
75 IF NOT AVAILABLE(OfficeSetting) THEN letterhead-tray = "".
77 DEF VAR statement-month-start AS DATE NO-UNDO.
78 DEF VAR statement-month-end AS DATE NO-UNDO.
79 DEF VAR current-month AS INT NO-UNDO.
80 FIND FIRST Month WHERE Month.StartDate <= statement-date AND Month.EndDate >= statement-date NO-LOCK NO-ERROR.
81 IF NOT AVAILABLE(Month) THEN DO:
82 PUT UNFORMATTED "Can't find month for date " STRING(statement-date, "99/99/9999").
83 END.
84 statement-month-start = Month.StartDate.
85 statement-month-end = Month.EndDate.
86 current-month = Month.MonthCode.
89 /* global variables used for each tenant */
90 DEF VAR logo-codes AS CHAR NO-UNDO.
91 DEF VAR client-code AS CHAR NO-UNDO.
92 DEF VAR entity-type AS CHAR NO-UNDO.
93 DEF VAR entity-code AS INT NO-UNDO.
94 DEF VAR regarding-1 AS CHAR NO-UNDO.
95 DEF VAR regarding-2 AS CHAR NO-UNDO.
96 DEF VAR regarding-3 AS CHAR NO-UNDO.
97 DEF VAR period-balances AS DEC NO-UNDO EXTENT 4.
98 DEF VAR balance-bf AS DEC NO-UNDO.
99 DEF VAR balance-before-dc AS DEC NO-UNDO.
100 DEF VAR balance-due AS DEC NO-UNDO.
101 DEF VAR account-balance AS DEC NO-UNDO.
102 DEF VAR expected-dc AS DEC NO-UNDO.
103 DEF VAR replaced-codes AS CHAR NO-UNDO.
104 DEF VAR tenant-address AS CHAR NO-UNDO.
105 DEF VAR exception-reason AS CHAR NO-UNDO.
107 /* temp table for holding statement line information */
108 DEF TEMP-TABLE StatementLine NO-UNDO
109 FIELD LnBatch AS INT
110 FIELD LnDoc AS INT
111 FIELD LnTrn AS INT
112 FIELD LnDate AS DATE
113 FIELD LnRef AS CHAR
114 FIELD LnText AS CHAR
115 FIELD LnAmount AS DEC
116 INDEX XPKStatementLines IS UNIQUE PRIMARY LnBatch LnDoc LnTrn .
118 DEF TEMP-TABLE TenantAmount NO-UNDO
119 FIELD TenantCode LIKE Tenant.TenantCode
120 FIELD LastBalance LIKE Tenant.CFBalance
121 FIELD LastBatch LIKE Tenant.BatchLastStatement
122 FIELD ThisBalance LIKE Tenant.CFBalance
123 FIELD LastRental LIKE Tenant.LastRentTotal
124 FIELD ThisRental LIKE Tenant.LastRentTotal
125 FIELD PropertyCode LIKE Tenant.EntityCode
126 INDEX XAK1Amounts IS UNIQUE PRIMARY TenantCode
127 INDEX XPKAmounts PropertyCode TenantCode.
129 /* _UIB-CODE-BLOCK-END */
130 &ANALYZE-RESUME
133 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
135 /* ******************** Preprocessor Definitions ******************** */
137 &Scoped-define PROCEDURE-TYPE Procedure
138 &Scoped-define DB-AWARE no
142 /* _UIB-PREPROCESSOR-BLOCK-END */
143 &ANALYZE-RESUME
146 /* ************************ Function Prototypes ********************** */
148 &IF DEFINED(EXCLUDE-get-aging-codes) = 0 &THEN
150 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-aging-codes Procedure
151 FUNCTION get-aging-codes RETURNS CHARACTER
152 ( /* no parameter-definitions */ ) FORWARD.
154 /* _UIB-CODE-BLOCK-END */
155 &ANALYZE-RESUME
157 &ENDIF
159 &IF DEFINED(EXCLUDE-get-copy-only) = 0 &THEN
161 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-copy-only Procedure
162 FUNCTION get-copy-only RETURNS CHARACTER
163 ( /* no parameter-definitions */ ) FORWARD.
165 /* _UIB-CODE-BLOCK-END */
166 &ANALYZE-RESUME
168 &ENDIF
170 &IF DEFINED(EXCLUDE-get-expected-dc) = 0 &THEN
172 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-expected-dc Procedure
173 FUNCTION get-expected-dc RETURNS DECIMAL
174 ( /* parameter-definitions */ ) FORWARD.
176 /* _UIB-CODE-BLOCK-END */
177 &ANALYZE-RESUME
179 &ENDIF
181 &IF DEFINED(EXCLUDE-get-fixed-codes) = 0 &THEN
183 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-fixed-codes Procedure
184 FUNCTION get-fixed-codes RETURNS CHARACTER
185 ( /* no parameter-definitions */ ) FORWARD.
187 /* _UIB-CODE-BLOCK-END */
188 &ANALYZE-RESUME
190 &ENDIF
192 &IF DEFINED(EXCLUDE-get-logo-codes) = 0 &THEN
194 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-logo-codes Procedure
195 FUNCTION get-logo-codes RETURNS CHARACTER
196 ( /* parameter-definitions */ ) FORWARD.
198 /* _UIB-CODE-BLOCK-END */
199 &ANALYZE-RESUME
201 &ENDIF
203 &IF DEFINED(EXCLUDE-get-statement-contact) = 0 &THEN
205 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-statement-contact Procedure
206 FUNCTION get-statement-contact RETURNS CHARACTER
207 ( INPUT et AS CHAR, INPUT ec AS INT ) FORWARD.
209 /* _UIB-CODE-BLOCK-END */
210 &ANALYZE-RESUME
212 &ENDIF
214 &IF DEFINED(EXCLUDE-get-variable-codes) = 0 &THEN
216 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-variable-codes Procedure
217 FUNCTION get-variable-codes RETURNS CHARACTER
218 ( /* parameter-definitions */ ) FORWARD.
220 /* _UIB-CODE-BLOCK-END */
221 &ANALYZE-RESUME
223 &ENDIF
225 &IF DEFINED(EXCLUDE-include-lease) = 0 &THEN
227 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-lease Procedure
228 FUNCTION include-lease RETURNS LOGICAL
229 ( INPUT lease-code AS INT ) FORWARD.
231 /* _UIB-CODE-BLOCK-END */
232 &ANALYZE-RESUME
234 &ENDIF
237 /* *********************** Procedure Settings ************************ */
239 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
240 /* Settings for THIS-PROCEDURE
241 Type: Procedure
242 Allow:
243 Frames: 0
244 Add Fields to: Neither
245 Other Settings: CODE-ONLY COMPILE
247 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
249 /* ************************* Create Window ************************** */
251 &ANALYZE-SUSPEND _CREATE-WINDOW
252 /* DESIGN Window definition (used by the UIB)
253 CREATE WINDOW Procedure ASSIGN
254 HEIGHT = .1
255 WIDTH = 40.
256 /* END WINDOW DEFINITION */
258 &ANALYZE-RESUME
260 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
261 /* ************************* Included-Libraries *********************** */
263 {inc/method/m-txtrep.i}
264 {inc/method/m-hpgl.i}
265 {inc/entity.i}
266 {inc/convert.i}
267 {inc/tenant-atb.i}
268 {inc/rentchrg.i}
269 {inc/contacts.i}
271 /* _UIB-CODE-BLOCK-END */
272 &ANALYZE-RESUME
278 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
281 /* *************************** Main Block *************************** */
282 {inc/username.i "user-name"}
283 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
285 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
287 RUN invoice-statements.
289 OUTPUT CLOSE.
290 RUN view-output-file ( no ).
292 IF show-differences THEN RUN exception-report.
294 /* _UIB-CODE-BLOCK-END */
295 &ANALYZE-RESUME
298 /* ********************** Internal Procedures *********************** */
300 &IF DEFINED(EXCLUDE-each-closed-payment-group) = 0 &THEN
302 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-closed-payment-group Procedure
303 PROCEDURE each-closed-payment-group :
304 /*------------------------------------------------------------------------------
305 Purpose:
306 ------------------------------------------------------------------------------*/
307 DEF INPUT PARAMETER closed-payment-recid AS RECID NO-UNDO.
309 DEF BUFFER ClosedPayment FOR AcctTran.
310 DEF BUFFER CloseDoc FOR Document.
312 FIND ClosedPayment WHERE RECID(ClosedPayment) = closed-payment-recid NO-LOCK.
313 FIND CloseDoc OF ClosedPayment.
314 IF NOT( ClosedPayment.Description BEGINS "Cash Receipt"
315 OR CloseDoc.Description BEGINS "Cash Receipt"
316 OR ClosedPayment.Description BEGINS "Refund"
317 OR CloseDoc.Description BEGINS "Refund"
318 OR ClosedPayment.Description BEGINS "Write"
319 OR CloseDoc.Description BEGINS "Write"
320 ) THEN RETURN.
323 FIND ClosingGroup OF ClosedPayment NO-LOCK.
324 IF NOT AVAILABLE(ClosingGroup) THEN RETURN.
326 FOR EACH AcctTran OF ClosingGroup NO-LOCK:
327 RUN each-transaction.
328 END.
330 END PROCEDURE.
332 /* _UIB-CODE-BLOCK-END */
333 &ANALYZE-RESUME
335 &ENDIF
337 &IF DEFINED(EXCLUDE-each-closing-group) = 0 &THEN
339 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-closing-group Procedure
340 PROCEDURE each-closing-group :
341 /*------------------------------------------------------------------------------
342 Purpose:
343 ------------------------------------------------------------------------------*/
344 DEF VAR grp-amount AS DEC NO-UNDO INITIAL 0.
345 DEF VAR dispDate AS DATE NO-UNDO.
346 DEF VAR dispReference AS CHAR NO-UNDO.
347 DEF VAR dispDescription AS CHAR NO-UNDO.
349 FIND LAST AcctTran NO-LOCK OF ClosingGroup NO-ERROR.
350 IF NOT AVAILABLE(AcctTran) THEN RETURN.
352 ASSIGN dispDate = ClosingGroup.Date
353 dispReference = "CG " + STRING( ClosingGroup.ClosingGroup)
354 dispDescription = (IF ClosingGroup.Description <> ""
355 THEN ClosingGroup.Description
356 ELSE AcctTran.Description ) .
358 IF dispDescription = "" THEN DO:
359 FIND Document NO-LOCK OF AcctTran.
360 IF dispDescription = "" THEN dispDescription = Document.Description.
361 END.
363 DEF BUFFER AltTran FOR AcctTran.
364 FOR EACH AltTran NO-LOCK OF ClosingGroup:
365 grp-amount = grp-amount + AltTran.Amount.
366 END.
368 CREATE StatementLine.
369 StatementLine.LnBatch = AcctTran.BatchCode.
370 StatementLine.LnDoc = AcctTran.DocumentCode.
371 StatementLine.LnTrn = AcctTran.TransactionCode.
372 StatementLine.LnDate = dispDate.
373 StatementLine.LnRef = dispReference.
374 StatementLine.LnText = dispDescription.
375 StatementLine.LnAmount = grp-amount.
377 END PROCEDURE.
379 /* _UIB-CODE-BLOCK-END */
380 &ANALYZE-RESUME
382 &ENDIF
384 &IF DEFINED(EXCLUDE-each-tenant) = 0 &THEN
386 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
387 PROCEDURE each-tenant :
388 /*------------------------------------------------------------------------------
389 Purpose:
390 ------------------------------------------------------------------------------*/
392 RUN get-tenant-details.
393 FIND FIRST StatementLine WHERE StatementLine.LnBatch > after-batch NO-LOCK NO-ERROR.
394 IF period-balances[1] = 0 AND period-balances[2] = 0
395 AND period-balances[3] = 0 AND period-balances[4] = 0
396 AND expected-dc = 0
397 AND NOT AVAILABLE( StatementLine ) THEN RETURN.
399 CREATE TenantAmount.
400 ASSIGN TenantAmount.TenantCode = Tenant.TenantCode
401 TenantAmount.LastBalance = Tenant.CFBalance
402 TenantAmount.ThisBalance = ?
403 TenantAmount.LastRental = Tenant.LastRentTotal
404 TenantAmount.ThisRental = ?
405 TenantAmount.LastBatch = Tenant.BatchLastStatement
406 TenantAmount.PropertyCode = Tenant.EntityCode.
408 IF print-original THEN DO:
409 IF actually-print THEN PUT CONTROL fixed-codes.
410 IF actually-print THEN PUT CONTROL logo-codes.
411 IF actually-print THEN PUT CONTROL replaced-codes.
412 RUN put-statement-lines.
413 END.
414 IF print-copy THEN DO:
415 IF actually-print THEN PUT CONTROL fixed-codes.
416 IF actually-print THEN PUT CONTROL logo-codes.
417 replaced-codes = replaced-codes + copy-only.
418 IF actually-print THEN PUT CONTROL replaced-codes.
419 RUN put-statement-lines.
420 END.
422 RUN save-tenant-snapshot.
424 END PROCEDURE.
426 /* _UIB-CODE-BLOCK-END */
427 &ANALYZE-RESUME
429 &ENDIF
431 &IF DEFINED(EXCLUDE-each-transaction) = 0 &THEN
433 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-transaction Procedure
434 PROCEDURE each-transaction :
435 /*------------------------------------------------------------------------------
436 Purpose:
437 ------------------------------------------------------------------------------*/
438 DEF VAR trn-ref AS CHAR NO-UNDO.
439 DEF VAR trn-desc AS CHAR NO-UNDO.
441 FIND StatementLine WHERE StatementLine.LnBatch = AcctTran.BatchCode
442 AND StatementLine.LnDoc = AcctTran.DocumentCode
443 AND StatementLine.LnTrn = AcctTran.TransactionCode
444 NO-ERROR.
445 IF AVAILABLE(StatementLine) THEN RETURN.
447 IF AcctTran.Reference = "" OR AcctTran.Description = "" THEN DO:
448 FIND FIRST Document OF AcctTran NO-LOCK.
449 trn-ref = IF AcctTran.Reference <> "" THEN
450 AcctTran.Reference
451 ELSE
452 Document.Reference.
453 trn-desc = IF AcctTran.Description <> "" THEN
454 AcctTran.Description
455 ELSE
456 Document.Description.
457 END.
458 ELSE IF AcctTran.Reference MATCHES "INV*" THEN DO:
459 trn-ref = "MISC" + SUBSTR( AcctTran.Reference, 4, 20).
460 trn-desc = AcctTran.Description .
461 END.
462 ELSE ASSIGN
463 trn-ref = AcctTran.Reference
464 trn-desc = AcctTran.Description .
466 CREATE StatementLine.
467 StatementLine.LnBatch = AcctTran.BatchCode.
468 StatementLine.LnDoc = AcctTran.DocumentCode.
469 StatementLine.LnTrn = AcctTran.TransactionCode.
470 StatementLine.LnDate = AcctTran.Date.
471 StatementLine.LnRef = trn-ref.
472 StatementLine.LnText = trn-desc.
473 StatementLine.LnAmount = AcctTran.Amount.
475 END PROCEDURE.
477 /* _UIB-CODE-BLOCK-END */
478 &ANALYZE-RESUME
480 &ENDIF
482 &IF DEFINED(EXCLUDE-exception-report) = 0 &THEN
484 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE exception-report Procedure
485 PROCEDURE exception-report :
486 /*------------------------------------------------------------------------------
487 Purpose:
488 ------------------------------------------------------------------------------*/
490 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
491 RUN pclrep-start( No, "reset,simplex,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
493 FOR EACH TenantAmount BY TenantAmount.TenantCode:
494 IF TenantAmount.LastBalance = TenantAmount.ThisBalance
495 AND TenantAmount.LastRental = TenantAmount.ThisRental
496 THEN
497 NEXT.
499 /* Skip tenants with no rental this period */
500 IF TenantAmount.ThisRental = 0 THEN NEXT.
502 /* 14/6/00 Added this reason field so that the user can see why this is
503 appearing on the report */
504 IF TenantAmount.LastBalance <> TenantAmount.ThisBalance THEN
505 exception-reason = "Balances differ.".
506 ELSE IF TenantAmount.LastRental > TenantAmount.ThisRental THEN
507 exception-reason = "Rent decrease.".
508 ELSE IF TenantAmount.LastRenta < TenantAmount.ThisRental THEN
509 exception-reason = "Rent increase.".
510 ELSE
511 exception-reason = "Unknown.".
514 FIND Tenant OF TenantAmount NO-LOCK.
515 pr-line = STRING( TenantAmount.TenantCode, "99999") + " "
516 + STRING( Tenant.Name, "X(40)" ) + " "
517 + STRING( TenantAmount.PropertyCode, "99999") + " "
518 + STRING( TenantAmount.LastBatch, ">>99999") + " "
519 + STRING( TenantAmount.LastBalance, "->>,>>>,>>9.99") + " "
520 + (IF TenantAmount.ThisBalance = ? THEN " Not printed" ELSE STRING( TenantAmount.ThisBalance, "->>,>>>,>>9.99"))
521 + " " + exception-reason.
523 * + " "
524 * + STRING( TenantAmount.LastRental, "->>,>>>,>>9.99") + " "
525 * + (IF TenantAmount.ThisRental = ? THEN " Not charged" ELSE STRING( TenantAmount.ThisRental, "->>,>>>,>>9.99"))
528 RUN pclrep-line( base-font, pr-line ).
529 END.
531 RUN pclrep-line( base-font, "" ).
532 RUN pclrep-line( break2-font, "End of exception report" ).
534 OUTPUT CLOSE.
535 RUN pclrep-finish.
537 END PROCEDURE.
539 /* _UIB-CODE-BLOCK-END */
540 &ANALYZE-RESUME
542 &ENDIF
544 &IF DEFINED(EXCLUDE-get-tenant-details) = 0 &THEN
546 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-tenant-details Procedure
547 PROCEDURE get-tenant-details :
548 /*------------------------------------------------------------------------------
549 Purpose:
550 ------------------------------------------------------------------------------*/
551 DEF VAR i AS INT NO-UNDO.
553 RUN get-tenant-transactions.
555 RUN get-aged-balances( Tenant.TenantCode, current-month, OUTPUT period-balances[1], OUTPUT period-balances[2], OUTPUT period-balances[3], OUTPUT period-balances[4] ).
556 balance-due = 0.
557 DO i = 1 TO 4:
558 /* MESSAGE i period-balances[i] VIEW-AS ALERT-BOX. */
559 balance-due = balance-due + period-balances[i].
560 END.
561 expected-dc = get-expected-dc().
562 /* MESSAGE balance-due expected-dc VIEW-AS ALERT-BOX. */
563 balance-before-dc = balance-due.
564 balance-due = balance-due - expected-dc.
565 period-balances[1] = period-balances[1] - expected-dc.
567 regarding-1 = "".
568 regarding-2 = "".
569 regarding-3 = "".
570 IF Tenant.EntityType = 'P' THEN DO:
571 FIND FIRST Property WHERE Property.PropertyCode = Tenant.EntityCode NO-LOCK NO-ERROR.
572 IF AVAILABLE Property THEN DO:
573 regarding-1 = Property.Name.
574 IF Property.Name <> Property.StreetAddress THEN regarding-2 = Property.StreetAddress.
575 regarding-2 = WRAP( regarding-2, 37 ).
576 IF INDEX( regarding-2, "~n") > 0 THEN ASSIGN
577 regarding-3 = ENTRY( 2, regarding-2, "~n" )
578 regarding-2 = ENTRY( 1, regarding-2, "~n" ).
579 END.
580 END.
581 ELSE IF Tenant.EntityType = 'L' THEN DO:
582 FIND FIRST Company WHERE Company.CompanyCode = Tenant.EntityCode NO-LOCK NO-ERROR.
583 IF AVAILABLE Company THEN regarding-1 = Company.LegalName.
584 END.
586 entity-type = Tenant.EntityType.
587 entity-code = Tenant.EntityCode.
588 client-code = get-entity-client( entity-type, entity-code ).
589 logo-codes = get-logo-codes().
591 tenant-address = Tenant.Name + "~n"
592 + get-best-address( Tenant.BillingContact, "BILL,POST,COUR").
593 /* RUN process/getaddr.p( "T", Tenant.TenantCode, "BILL", OUTPUT tenant-address ). */
595 RUN replace-variables.
597 END PROCEDURE.
599 /* _UIB-CODE-BLOCK-END */
600 &ANALYZE-RESUME
602 &ENDIF
604 &IF DEFINED(EXCLUDE-get-tenant-transactions) = 0 &THEN
606 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-tenant-transactions Procedure
607 PROCEDURE get-tenant-transactions :
608 /*------------------------------------------------------------------------------
609 Purpose:
610 ------------------------------------------------------------------------------*/
611 /* clear the existing statement line records */
612 FOR EACH StatementLine: DELETE StatementLine. END.
614 &SCOPED-DEFINE tran-clause AcctTran.EntityType = 'T' AND ~
615 AcctTran.EntityCode = Tenant.TenantCode AND ~
616 AcctTran.AccountCode = sundry-debtors
618 &SCOPED-DEFINE by-clause BY AcctTran.EntityType BY AcctTran.EntityCode ~
619 BY AcctTran.AccountCode BY AcctTran.Date ~
620 BY AcctTran.BatchCode BY AcctTran.DocumentCode ~
621 BY AcctTran.TransactionCode
623 FIND AccountSummary WHERE AccountSummary.EntityType = "T"
624 AND AccountSummary.EntityCode = Tenant.TenantCode
625 AND AccountSummary.AccountCode = sundry-debtors
626 AND AccountSummary.Balance <> 0 NO-LOCK NO-ERROR.
628 IF NOT(show-zeroes) AND (from-tenant <> to-tenant)
629 AND NOT AVAILABLE(AccountSummary) THEN RETURN.
631 IF from-month = ? OR to-month = ? OR summarise-part THEN DO:
632 FOR EACH AcctTran NO-LOCK WHERE {&tran-clause} AND
633 (AcctTran.ClosingGroup = ? OR
634 (IF summarise-part THEN No ELSE ((AcctTran.ClosedState = "P") OR NOT open-only) ))
635 {&by-clause}:
636 RUN each-transaction.
637 END.
638 IF summarise-part THEN DO:
639 FOR EACH ClosingGroup NO-LOCK WHERE ClosingGroup.EntityType = "T"
640 AND ClosingGroup.EntityCode = Tenant.TenantCode
641 AND ClosingGroup.AccountCode = sundry-debtors
642 AND ClosingGroup.ClosedStatus = "P"
643 BY ClosingGroup.EntityType BY ClosingGroup.EntityCode
644 BY ClosingGroup.AccountCode BY ClosingGroup.Date:
645 RUN each-closing-group.
646 END.
647 END.
648 END.
649 ELSE DO:
650 FOR EACH AcctTran NO-LOCK WHERE {&tran-clause} AND
651 AcctTran.MonthCode >= from-month AND
652 AcctTran.monthCode <= to-month AND
653 (AcctTran.ClosingGroup = ? OR AcctTran.ClosedState = "P" OR NOT open-only )
654 {&by-clause}:
655 RUN each-transaction.
656 END.
657 END.
659 IF open-only AND show-payments-as-open THEN DO:
660 DEF BUFFER ClosedPayment FOR AcctTran.
661 FOR EACH ClosedPayment NO-LOCK WHERE ClosedPayment.EntityType = 'T'
662 AND ClosedPayment.EntityCode = Tenant.TenantCode
663 AND ClosedPayment.AccountCode = sundry-debtors
664 AND ClosedPayment.ClosedState = "F"
665 BY ClosedPayment.EntityType BY ClosedPayment.EntityCode
666 BY ClosedPayment.AccountCode BY ClosedPayment.Date
667 BY ClosedPayment.BatchCode BY ClosedPayment.DocumentCode
668 BY ClosedPayment.TransactionCode:
669 RUN each-closed-payment-group( RECID( ClosedPayment ) ).
670 END.
671 END.
673 END PROCEDURE.
675 /* _UIB-CODE-BLOCK-END */
676 &ANALYZE-RESUME
678 &ENDIF
680 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
682 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
683 PROCEDURE inst-page-footer :
684 /*------------------------------------------------------------------------------
685 Purpose:
686 ------------------------------------------------------------------------------*/
688 END PROCEDURE.
690 /* _UIB-CODE-BLOCK-END */
691 &ANALYZE-RESUME
693 &ENDIF
695 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
697 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
698 PROCEDURE inst-page-header :
699 /*------------------------------------------------------------------------------
700 Purpose: Print any page header
701 ------------------------------------------------------------------------------*/
703 RUN pclrep-line( "univers,Point,6,bold,Proportional", TimeStamp).
704 RUN pclrep-line( "", "" ).
705 RUN pclrep-line( "univers,Point,12,bold,Proportional",
706 "Invoice/Statement Printing - Exception Report" ).
707 RUN pclrep-line( "", "" ).
709 /* Put any column headers here */
710 pr-line = "Tenant Property Batch Last CF Bal This BF Bal Reason". /*"Rent Charged Expected DC" . */
711 RUN pclrep-line( base-font + ",bold", pr-line ).
712 RUN pclrep-down-by(1).
714 END PROCEDURE.
716 /* _UIB-CODE-BLOCK-END */
717 &ANALYZE-RESUME
719 &ENDIF
721 &IF DEFINED(EXCLUDE-invoice-statements) = 0 &THEN
723 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE invoice-statements Procedure
724 PROCEDURE invoice-statements :
725 /*------------------------------------------------------------------------------
726 Purpose:
727 ------------------------------------------------------------------------------*/
729 fixed-codes = get-fixed-codes().
730 copy-only = get-copy-only().
731 variable-codes = get-variable-codes().
732 ctc-office-std-code = ?. /* So the std code is always shown in phone #s */
734 IF prop-code <> ? THEN DO:
735 FOR EACH Tenant NO-LOCK WHERE (NOT(active-only) OR Tenant.Active)
736 AND Tenant.EntityType = 'P' AND Tenant.EntityCode = prop-code
737 BY Tenant.TenantCode:
738 RUN each-tenant.
739 END.
740 END.
741 ELSE DO:
742 FOR EACH Tenant NO-LOCK WHERE (NOT(active-only) OR Tenant.Active)
743 AND Tenant.TenantCode >= from-tenant AND Tenant.TenantCode <= to-tenant
744 /* BY Tenant.EntityCode */ BY Tenant.TenantCode:
745 RUN each-tenant.
746 END.
747 END.
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 token AS CHAR NO-UNDO.
764 DEF VAR i AS INT NO-UNDO.
766 {inc/showopts.i "report-options"}
768 DEF VAR type-of AS CHAR NO-UNDO.
769 DEF VAR range-of AS CHAR NO-UNDO.
771 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
772 token = ENTRY( i, report-options, "~n" ).
774 CASE ENTRY( 1, token ):
775 WHEN "OpenOnly" THEN open-only = Yes.
776 WHEN "ActiveOnly" THEN active-only = Yes.
777 WHEN "HideAging" THEN hide-aging = Yes.
778 WHEN "SummarisePartClosed" THEN summarise-part = Yes.
779 WHEN "ShowZeroes" THEN show-zeroes = Yes.
780 WHEN "ShowDifferences" THEN show-differences = Yes.
781 WHEN "DontPrint" THEN actually-print = No.
783 WHEN "Selection" THEN DO:
784 type-of = ENTRY( 2, token).
785 prop-code = INT( ENTRY( 3, token)).
786 to-tenant = INT( ENTRY( 4, token)) NO-ERROR.
787 IF type-of = "All" THEN
788 ASSIGN from-tenant = 0 to-tenant = 99999 prop-code = ?.
789 ELSE IF type-of = "Tenant" THEN
790 ASSIGN from-tenant = prop-code to-tenant = prop-code prop-code = ?.
791 ELSE IF type-of = "Range" THEN
792 ASSIGN from-tenant = prop-code prop-code = ?.
793 ELSE IF type-of = "Property" THEN
794 ASSIGN from-tenant = ? to-tenant = ?.
795 END.
797 WHEN "months" THEN DO:
798 range-of = ENTRY( 2, token).
799 IF range-of = "Range" THEN ASSIGN
800 from-month = INT( ENTRY( 3, token))
801 to-month = INT( ENTRY( 4, token)).
802 END.
804 WHEN "StatementDate" THEN statement-date = DATE( ENTRY(2,token)).
805 WHEN "AfterBatch" THEN after-batch = INT( ENTRY(2,token)).
806 WHEN "Print" THEN ASSIGN
807 print-original = (LOOKUP( "Original", token ) > 0)
808 print-copy = (LOOKUP( "Copy", token ) > 0).
809 END CASE.
810 END.
812 IF summarise-part THEN open-only = Yes.
813 IF open-only OR range-of <> "Range" THEN ASSIGN from-month = ? to-month = ?.
815 END PROCEDURE.
817 /* _UIB-CODE-BLOCK-END */
818 &ANALYZE-RESUME
820 &ENDIF
822 &IF DEFINED(EXCLUDE-put-continuation) = 0 &THEN
824 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE put-continuation Procedure
825 PROCEDURE put-continuation :
826 /*------------------------------------------------------------------------------
827 Purpose:
828 ------------------------------------------------------------------------------*/
829 DEF VAR printer-codes AS CHAR NO-UNDO.
831 RUN hpgl-moveto( 91, 99 ).
832 RUN hpgl-text( data-font, "* * * continued on next page * * *").
833 RUN hpgl-get-codes( no, yes, OUTPUT printer-codes ).
834 IF actually-print THEN PUT CONTROL printer-codes.
836 IF actually-print THEN PUT CONTROL fixed-codes.
837 IF actually-print THEN PUT CONTROL logo-codes.
838 IF actually-print THEN PUT CONTROL replaced-codes.
839 RUN hpgl-clear.
840 RUN hpgl-text( fixed-font, "").
842 END PROCEDURE.
844 /* _UIB-CODE-BLOCK-END */
845 &ANALYZE-RESUME
847 &ENDIF
849 &IF DEFINED(EXCLUDE-put-statement-lines) = 0 &THEN
851 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE put-statement-lines Procedure
852 PROCEDURE put-statement-lines :
853 /*------------------------------------------------------------------------------
854 Purpose:
855 ------------------------------------------------------------------------------*/
856 DEF VAR tenant-balance AS DEC NO-UNDO INITIAL 0.
857 DEF VAR printer-codes AS CHAR NO-UNDO.
858 DEF VAR tr-row AS INT NO-UNDO INITIAL 0.
860 &SCOP LPP 33
861 RUN hpgl-clear.
862 RUN hpgl-text( fixed-font, "").
863 FOR EACH StatementLine WHERE StatementLine.LnBatch <= after-batch:
864 tenant-balance = tenant-balance + StatementLine.LnAmount .
865 END.
866 balance-bf = tenant-balance.
867 IF tenant-balance <> 0 THEN DO:
868 RUN put-trn-line( tr-row, ?, "", "Balance brought forward", tenant-balance ).
869 tr-row = tr-row + 1.
870 END.
872 FOR EACH StatementLine WHERE StatementLine.LnBatch > after-batch:
873 IF tr-row > {&LPP} THEN DO:
874 RUN put-continuation.
875 tr-row = 0.
876 END.
877 RUN put-trn-line( tr-row, StatementLine.LnDate, StatementLine.LnRef, StatementLine.LnText, StatementLine.LnAmount ).
878 tr-row = tr-row + 1.
879 tenant-balance = tenant-balance + StatementLine.LnAmount .
880 END.
882 IF expected-dc <> 0 AND expected-dc <> ? THEN DO:
883 tr-row = {&LPP}. RUN put-trn-line( tr-row, ?, "", "", ? ).
884 tr-row = tr-row + 1. RUN put-trn-line( tr-row, ?, "", "Balance of Account", tenant-balance ).
885 tr-row = tr-row + 1. RUN put-trn-line( tr-row, ?, "", "Expected direct credit due on " + STRING( statement-month-start, "99/99/9999"), - expected-dc ).
886 END.
888 RUN hpgl-get-codes( no, yes, OUTPUT printer-codes ).
889 IF actually-print THEN PUT CONTROL printer-codes.
891 END PROCEDURE.
893 /* _UIB-CODE-BLOCK-END */
894 &ANALYZE-RESUME
896 &ENDIF
898 &IF DEFINED(EXCLUDE-put-trn-line) = 0 &THEN
900 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE put-trn-line Procedure
901 PROCEDURE put-trn-line :
902 /*------------------------------------------------------------------------------
903 Purpose:
904 ------------------------------------------------------------------------------*/
905 DEF INPUT PARAMETER row AS INT NO-UNDO.
906 DEF INPUT PARAMETER t-date AS DATE NO-UNDO.
907 DEF INPUT PARAMETER t-ref AS CHAR NO-UNDO.
908 DEF INPUT PARAMETER t-text AS CHAR NO-UNDO.
909 DEF INPUT PARAMETER t-amount AS DEC NO-UNDO.
911 RUN hpgl-moveto( 26, 203 - (3 * row)).
912 RUN hpgl-text( "", (IF t-date = ? THEN FILL(" ",10) ELSE STRING( t-date, "99/99/9999")) + " "
913 + STRING( t-ref, "X(20)" )
914 + STRING( t-text, "X(63)" )
915 + (IF t-amount = ? THEN FILL("_",14) ELSE STRING( t-amount, amount-format) )).
917 END PROCEDURE.
919 /* _UIB-CODE-BLOCK-END */
920 &ANALYZE-RESUME
922 &ENDIF
924 &IF DEFINED(EXCLUDE-replace-variables) = 0 &THEN
926 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE replace-variables Procedure
927 PROCEDURE replace-variables :
928 /*------------------------------------------------------------------------------
929 Purpose:
930 ------------------------------------------------------------------------------*/
931 DEF VAR contact-details AS CHAR NO-UNDO.
932 DEF VAR refers-to-property AS LOGI NO-UNDO INITIAL Yes.
934 DEF VAR n AS INT NO-UNDO.
935 DEF VAR i AS INT NO-UNDO.
936 DEF VAR address-lines AS CHAR NO-UNDO.
938 RUN hpgl-clear.
939 address-lines = "".
940 n = NUM-ENTRIES( tenant-address, "~n" ).
941 DO i = 1 TO n:
942 IF i > 1 THEN RUN hpgl-move-relative(0,-4.5).
943 RUN hpgl-text( data-font, ENTRY( i, tenant-address, "~n")).
944 END.
945 address-lines = hpgl-codes.
947 hpgl-codes = variable-codes.
948 RUN hpgl-replace( "@tenant-code@", STRING( Tenant.TenantCode, "99999" ) ).
950 IF Tenant.EntityType <> "P" THEN refers-to-property = No.
951 IF refers-to-property THEN DO:
952 RUN hpgl-replace( "@tenant-code-prompt@", "TENANT NO." ).
953 RUN hpgl-replace( "@property-code-prompt@", "PROPERTY NO." ).
954 RUN hpgl-replace( "@regarding-prompt@", "Your Tenancy" ).
955 END.
956 ELSE DO:
957 RUN hpgl-replace( "@tenant-code-prompt@", "DEBTOR NO." ).
958 RUN hpgl-replace( "@property-code-prompt@", "REFERENCE" ).
959 RUN hpgl-replace( "@regarding-prompt@", "Regarding:" ).
960 END.
961 RUN hpgl-replace( "@regarding-1@", regarding-1 ).
962 RUN hpgl-replace( "@regarding-2@", regarding-2 ).
963 RUN hpgl-replace( "@regarding-3@", regarding-3 ).
964 RUN hpgl-replace( "@property-code@", Tenant.EntityType + STRING( Tenant.EntityCode, "99999")).
966 RUN hpgl-replace( "@aged-1@", STRING( period-balances[1], amount-format) ).
967 RUN hpgl-replace( "@aged-2@", STRING( period-balances[2], amount-format) ).
968 RUN hpgl-replace( "@aged-3@", STRING( period-balances[3], amount-format) ).
969 RUN hpgl-replace( "@aged-4@", STRING( period-balances[4], amount-format) ).
970 RUN hpgl-replace( "@balance-due@", STRING( balance-due, amount-format) ).
972 RUN word-wrap( get-statement-contact( Tenant.EntityType, Tenant.EntityCode ), 95, OUTPUT contact-details ).
973 RUN hpgl-replace( "@any-queries-1@", ENTRY( 1, contact-details, "~n")).
974 IF INDEX( contact-details, "~n" ) > 0 THEN
975 contact-details = ENTRY( 2, contact-details, "~n").
976 ELSE
977 contact-details = "".
978 RUN hpgl-replace( "@any-queries-2@", contact-details).
980 RUN hpgl-replace( "@tenant-address@", address-lines ).
982 replaced-codes = hpgl-codes.
983 hpgl-codes = "".
985 END PROCEDURE.
987 /* _UIB-CODE-BLOCK-END */
988 &ANALYZE-RESUME
990 &ENDIF
992 &IF DEFINED(EXCLUDE-save-tenant-snapshot) = 0 &THEN
994 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE save-tenant-snapshot Procedure
995 PROCEDURE save-tenant-snapshot :
996 /*------------------------------------------------------------------------------
997 Purpose: Save the last posted batch no and carried forward balance
998 ------------------------------------------------------------------------------*/
999 FIND LAST Batch NO-LOCK.
1000 TenantAmount.ThisBalance = balance-bf.
1001 TenantAmount.ThisRental = expected-dc.
1003 IF print-original THEN DO TRANSACTION:
1004 FIND CURRENT Tenant EXCLUSIVE-LOCK.
1005 Tenant.CFBalance = balance-before-dc.
1006 Tenant.BatchLastStatement = Batch.BatchCode.
1007 END.
1009 END PROCEDURE.
1011 /* _UIB-CODE-BLOCK-END */
1012 &ANALYZE-RESUME
1014 &ENDIF
1016 /* ************************ Function Implementations ***************** */
1018 &IF DEFINED(EXCLUDE-get-aging-codes) = 0 &THEN
1020 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-aging-codes Procedure
1021 FUNCTION get-aging-codes RETURNS CHARACTER
1022 ( /* no parameter-definitions */ ) :
1023 /*------------------------------------------------------------------------------
1024 Purpose: Get the codes for aging. I've left some stuff commented out so
1025 that we can extend this later to handle a 'style' value on the
1026 tenant record itself. Currently this is called from get-fixed-codes
1027 if hide-aging is on for the whole run.
1028 ------------------------------------------------------------------------------*/
1029 DEF VAR printer-codes AS CHAR NO-UNDO.
1031 /* RUN hpgl-clear. */
1032 RUN hpgl-moveto( 171, 82 ).
1033 RUN hpgl-box-relative( 26, -5).
1034 RUN hpgl-move-relative( -26, 0).
1035 RUN hpgl-box-relative( 26, -5).
1036 RUN hpgl-move-relative( -26, 0).
1037 RUN hpgl-box-relative( 26, -5).
1038 RUN hpgl-move-relative( -26, 0).
1039 RUN hpgl-box-relative( 26, -5).
1040 RUN hpgl-move-relative( 2.5, 1 ).
1041 RUN hpgl-text( prompt-font, "3 Months + 2 Months 1 Month Current" ).
1043 /* RUN hpgl-get-codes( no, yes, OUTPUT printer-codes ).
1044 RETURN printer-codes.
1046 END FUNCTION.
1048 /* _UIB-CODE-BLOCK-END */
1049 &ANALYZE-RESUME
1051 &ENDIF
1053 &IF DEFINED(EXCLUDE-get-copy-only) = 0 &THEN
1055 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-copy-only Procedure
1056 FUNCTION get-copy-only RETURNS CHARACTER
1057 ( /* no parameter-definitions */ ) :
1058 /*------------------------------------------------------------------------------
1059 Purpose: Get the codes that are the same on every statement
1060 ------------------------------------------------------------------------------*/
1061 DEF VAR printer-codes AS CHAR NO-UNDO.
1062 DEF VAR date-in-words AS CHAR NO-UNDO.
1064 RUN hpgl-clear.
1065 RUN hpgl-moveto( 45, 166 ).
1066 RUN hpgl-shaded-text( "helvetica,proportional,point,108,bold,italic", "COPY", 10 ).
1067 RUN hpgl-move-relative( 16, -50).
1068 RUN hpgl-shaded-text( hpgl-last-font, "ONLY", 10 ).
1070 RUN hpgl-get-codes( no, yes, OUTPUT printer-codes ).
1071 RETURN printer-codes.
1073 END FUNCTION.
1075 /* _UIB-CODE-BLOCK-END */
1076 &ANALYZE-RESUME
1078 &ENDIF
1080 &IF DEFINED(EXCLUDE-get-expected-dc) = 0 &THEN
1082 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-expected-dc Procedure
1083 FUNCTION get-expected-dc RETURNS DECIMAL
1084 ( /* parameter-definitions */ ) :
1085 /*------------------------------------------------------------------------------
1086 Purpose: Get the expected DC due
1087 Notes:
1088 ------------------------------------------------------------------------------*/
1089 IF Tenant.PaymentStyle <> "DC" AND Tenant.PaymentStyle <> "BORD" THEN RETURN 0.0 .
1091 rent-charge-one-period = Yes.
1092 RUN build-tenant-charges( Tenant.TenantCode, statement-month-start, statement-month-end ).
1093 FIND FIRST ChargeDetail NO-ERROR.
1094 IF NOT AVAILABLE(ChargeDetail) THEN RETURN 0.0 .
1096 DEF VAR to-be-charged AS DEC NO-UNDO INITIAL 0.0 .
1097 DEF VAR this-charge AS DEC NO-UNDO INITIAL 0.0 .
1098 DEF VAR taxable-total AS DEC NO-UNDO.
1100 FOR EACH ChargeDetail BREAK BY ChargeDetail.AccountCode:
1101 this-charge = this-charge + ChargeDetail.ChargeAmount.
1102 taxable-total = taxable-total + ChargeDetail.TaxableAmount.
1103 IF LAST-OF( ChargeDetail.AccountCode ) OR ChargeDetail.ChargeType = "S" THEN DO:
1104 to-be-charged = to-be-charged + ROUND( this-charge, 2)
1105 + ROUND( taxable-total * gst-rate, 2).
1106 this-charge = 0.
1107 taxable-total = 0.
1108 END.
1109 END.
1111 RETURN to-be-charged.
1113 END FUNCTION.
1115 /* _UIB-CODE-BLOCK-END */
1116 &ANALYZE-RESUME
1118 &ENDIF
1120 &IF DEFINED(EXCLUDE-get-fixed-codes) = 0 &THEN
1122 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-fixed-codes Procedure
1123 FUNCTION get-fixed-codes RETURNS CHARACTER
1124 ( /* no parameter-definitions */ ) :
1125 /*------------------------------------------------------------------------------
1126 Purpose: Get the codes that are the same on every statement
1127 ------------------------------------------------------------------------------*/
1128 DEF VAR printer-codes AS CHAR NO-UNDO.
1129 DEF VAR date-in-words AS CHAR NO-UNDO.
1131 RUN date-to-word( statement-date, OUTPUT date-in-words ).
1133 RUN hpgl-initialize.
1134 DEF VAR r AS INT NO-UNDO.
1135 DEF VAR c AS INT NO-UNDO.
1136 printer-codes = "reset,eject,simplex,portrait,normal".
1137 IF letterhead-tray <> "" THEN
1138 printer-codes = printer-codes + ",bin," + letterhead-tray.
1139 RUN make-control-string( "PCL", printer-codes, OUTPUT hpgl-initialise-codes, OUTPUT c, OUTPUT r).
1140 RUN hpgl-set-line-width( 0.15 ).
1141 RUN hpgl-moveto( 159, 256 ).
1142 RUN hpgl-text( data-font, date-in-words ).
1143 RUN hpgl-moveto( 52, 27 ).
1144 RUN hpgl-text( data-font, date-in-words ).
1145 RUN hpgl-move-relative( -28, 0).
1146 RUN hpgl-text( prompt-font, "Date" ).
1147 RUN hpgl-moveto( 146, 256 ).
1148 RUN hpgl-text( prompt-font, "DATE" ).
1149 RUN hpgl-move-relative( 0, -4.5).
1150 IF gst-rate > 0 THEN RUN hpgl-text( prompt-font, "TAX INVOICE" ).
1151 RUN hpgl-move-relative( 0, -4.5).
1152 IF gst-rate > 0 THEN RUN hpgl-text( prompt-font, gst-number-name + " " + gst-number ).
1154 RUN hpgl-moveto( 24, 211).
1155 RUN hpgl-box-relative( 173, -115).
1156 RUN hpgl-move-relative( 20, 0).
1157 RUN hpgl-box-relative( 127, -115).
1158 RUN hpgl-move-relative( 30, 0).
1159 RUN hpgl-line-relative( 0, -115).
1161 RUN hpgl-move-relative( 97, -2).
1162 RUN hpgl-set-line-width( 0.4 ).
1163 RUN hpgl-box-relative( 26, -5).
1165 IF NOT(hide-aging) THEN get-aging-codes().
1167 RUN hpgl-moveto( 145, 41).
1168 RUN hpgl-box-relative( 26, -5).
1169 RUN hpgl-move-relative( 0, -8).
1170 RUN hpgl-box-relative( 26, -7).
1171 RUN hpgl-set-line-width( 0.15 ).
1172 RUN hpgl-set-line-type( 2, 3, 1 ).
1173 RUN hpgl-move-relative( -138, 32).
1174 RUN hpgl-line-relative( 196, 0).
1176 RUN hpgl-moveto( 10, 97 ).
1177 RUN hpgl-text( prompt-font, ".." ).
1178 RUN hpgl-move-relative( 192, 0 ).
1179 RUN hpgl-text( prompt-font, ".." ).
1180 RUN hpgl-move-relative( 0, 100 ).
1181 RUN hpgl-text( prompt-font, ".." ).
1182 RUN hpgl-move-relative( -192, 0 ).
1183 RUN hpgl-text( prompt-font, ".." ).
1184 RUN hpgl-move-relative( 20, 10 ).
1185 RUN hpgl-text( prompt-font, "Date" ).
1186 RUN hpgl-move-relative( 17, 0 ).
1187 RUN hpgl-text( prompt-font, "Reference" ).
1188 RUN hpgl-move-relative( 30, 0 ).
1189 RUN hpgl-text( prompt-font, "Details" ).
1190 RUN hpgl-move-relative( 100, 0 ).
1191 RUN hpgl-text( prompt-font, "Amount" ).
1193 RUN hpgl-moveto( 24, 90 ).
1194 RUN hpgl-text( prompt-font + ",bold", "BALANCE NOW DUE" ).
1195 RUN hpgl-move-relative( 0, -53 ).
1196 RUN hpgl-text( hpgl-last-font, "REMITTANCE ADVICE" ).
1197 RUN hpgl-move-relative( 71, 0 ).
1198 RUN hpgl-text( prompt-font, "Balance Now Due" ).
1199 RUN hpgl-move-relative( 0, -9 ).
1200 RUN hpgl-text( prompt-font, "Enter Amount Paid" ).
1201 RUN hpgl-move-relative( 0, -9 ).
1202 RUN hpgl-text( prompt-font, "If this amount differs from the balance due, please" ).
1203 RUN hpgl-move-relative( 0, -4.5 ).
1204 RUN hpgl-text( prompt-font, "explain on the reverse of this form." ).
1206 RUN hpgl-get-codes( no, yes, OUTPUT printer-codes ).
1207 RETURN printer-codes.
1209 END FUNCTION.
1211 /* _UIB-CODE-BLOCK-END */
1212 &ANALYZE-RESUME
1214 &ENDIF
1216 &IF DEFINED(EXCLUDE-get-logo-codes) = 0 &THEN
1218 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-logo-codes Procedure
1219 FUNCTION get-logo-codes RETURNS CHARACTER
1220 ( /* parameter-definitions */ ) :
1221 /*------------------------------------------------------------------------------
1222 Purpose:
1223 Notes:
1224 ------------------------------------------------------------------------------*/
1225 DEF VAR printer-codes AS CHAR NO-UNDO.
1227 RUN hpgl-clear.
1228 RUN client-logo( entity-type, entity-code, client-code ).
1229 RUN client-address( entity-type, entity-code, client-code ).
1230 RUN hpgl-moveto( 24, 55 ).
1231 RUN client-routine( entity-type, entity-code, client-code, "Base-Logo":U ).
1232 RUN hpgl-get-codes( yes, no, OUTPUT printer-codes ).
1234 RETURN printer-codes.
1236 END FUNCTION.
1238 /* _UIB-CODE-BLOCK-END */
1239 &ANALYZE-RESUME
1241 &ENDIF
1243 &IF DEFINED(EXCLUDE-get-statement-contact) = 0 &THEN
1245 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-statement-contact Procedure
1246 FUNCTION get-statement-contact RETURNS CHARACTER
1247 ( INPUT et AS CHAR, INPUT ec AS INT ) :
1248 /*------------------------------------------------------------------------------
1249 Purpose: Return the details of contact people for statement stuff
1250 ------------------------------------------------------------------------------*/
1251 IF LOOKUP( statement-contact, "Manager" ) = 0 AND LOOKUP( statement-contact, "Administrator") = 0 THEN
1252 RETURN statement-contact.
1254 IF et <> "P" THEN RETURN "".
1256 DEF VAR contact-details AS CHAR NO-UNDO INITIAL "Please contact ".
1257 DEF VAR contact-1 AS INT NO-UNDO INITIAL ?.
1258 DEF VAR contact-2 AS INT NO-UNDO INITIAL ?.
1259 FIND Property WHERE Property.PropertyCode = ec NO-LOCK NO-ERROR.
1260 IF NOT AVAILABLE(Property) THEN RETURN "".
1261 IF LOOKUP( statement-contact, "Manager" ) > 0 THEN contact-1 = Property.Manager.
1262 IF LOOKUP( statement-contact, "Administrator" ) > 0 THEN contact-2 = Property.Administrator.
1264 IF contact-1 = ? AND contact-2 <> ? THEN contact-1 = contact-2.
1265 FIND Person WHERE Person.PersonCode = contact-1 NO-LOCK NO-ERROR.
1266 IF NOT AVAILABLE(Person) THEN contact-1 = contact-2 .
1267 IF contact-2 = contact-1 THEN contact-2 = ?.
1268 IF contact-1 = ? THEN RETURN "".
1270 FIND Person WHERE Person.PersonCode = contact-1 NO-LOCK NO-ERROR.
1271 IF NOT AVAILABLE(Person) THEN RETURN "".
1272 contact-details = contact-details + get-fullname( Person.PersonCode )
1273 + " on " + get-best-phone( contact-1, "BUS,BUS2,DDI,MOB").
1275 IF contact-2 > 0 THEN DO:
1276 FIND Person WHERE Person.PersonCode = contact-2 NO-LOCK NO-ERROR.
1277 IF AVAILABLE(Person) THEN DO:
1278 contact-details = contact-details + ", or "
1279 + get-fullname( Person.PersonCode )
1280 + " on " + get-best-phone( contact-1, "BUS,BUS2,DDI,MOB").
1281 contact-details = RIGHT-TRIM( contact-details, ", ").
1282 END.
1283 END.
1284 contact-details = contact-details + " should you have any queries with this invoice.".
1286 RETURN contact-details.
1288 END FUNCTION.
1290 /* _UIB-CODE-BLOCK-END */
1291 &ANALYZE-RESUME
1293 &ENDIF
1295 &IF DEFINED(EXCLUDE-get-variable-codes) = 0 &THEN
1297 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-variable-codes Procedure
1298 FUNCTION get-variable-codes RETURNS CHARACTER
1299 ( /* parameter-definitions */ ) :
1300 /*------------------------------------------------------------------------------
1301 Purpose: Get the codes that vary for each tenant
1302 Notes: Actual variables are replaced in this string using the hpgl-replace
1303 routine to replace @variable@ names.
1304 ------------------------------------------------------------------------------*/
1305 DEF VAR printer-codes AS CHAR NO-UNDO.
1306 DEF VAR temp-codes AS CHAR NO-UNDO.
1308 RUN hpgl-clear.
1309 RUN hpgl-text( prompt-font, "@tenant-code-prompt@" ).
1310 RUN hpgl-move-relative( 0, -4.5).
1311 RUN hpgl-text( prompt-font, "@property-code-prompt@" ).
1312 RUN hpgl-move-relative( 28, 0).
1313 RUN hpgl-text( data-font, "@property-code@" ).
1314 RUN hpgl-move-relative( 0, 4.5).
1315 RUN hpgl-text( data-font, "@tenant-code@" ).
1316 temp-codes = hpgl-codes.
1318 RUN hpgl-clear.
1319 RUN hpgl-moveto( 146, 238 ).
1320 hpgl-codes = hpgl-codes + temp-codes.
1321 RUN hpgl-move-relative( -60, -9).
1322 RUN hpgl-text( prompt-font, "@regarding-prompt@" ).
1323 RUN hpgl-move-relative( 0, -4.5).
1324 RUN hpgl-text( data-font, "@regarding-1@" ).
1325 RUN hpgl-move-relative( 0, -4.5).
1326 RUN hpgl-text( data-font, "@regarding-2@" ).
1327 RUN hpgl-move-relative( 0, -4.5).
1328 RUN hpgl-text( data-font, "@regarding-3@" ).
1330 RUN hpgl-moveto( 24, 246 ).
1331 hpgl-codes = hpgl-codes + "@tenant-address@" .
1333 RUN hpgl-moveto( 24, 22.5 ).
1334 hpgl-codes = hpgl-codes + temp-codes.
1336 RUN hpgl-moveto( 146.1, 37.5 ).
1337 RUN hpgl-text( fixed-font, "@balance-due@" ).
1338 RUN hpgl-move-relative( 26, 53).
1339 RUN hpgl-text( fixed-font, "@balance-due@" ).
1341 IF NOT( hide-aging ) THEN DO:
1342 RUN hpgl-move-relative( 0, -12).
1343 RUN hpgl-text( fixed-font, "@aged-1@" ).
1344 RUN hpgl-move-relative( -26, 0).
1345 RUN hpgl-text( fixed-font, "@aged-2@" ).
1346 RUN hpgl-move-relative( -26, 0).
1347 RUN hpgl-text( fixed-font, "@aged-3@" ).
1348 RUN hpgl-move-relative( -26, 0).
1349 RUN hpgl-text( fixed-font, "@aged-4@" ).
1350 END.
1352 RUN hpgl-moveto( 24, 72 ).
1353 RUN hpgl-text( prompt-font, "@any-queries-1@" ).
1354 RUN hpgl-move-relative( 0, -4.5).
1355 RUN hpgl-text( prompt-font, "@any-queries-2@" ).
1357 RUN hpgl-get-codes( no, yes, OUTPUT printer-codes ).
1359 RETURN printer-codes.
1361 END FUNCTION.
1363 /* _UIB-CODE-BLOCK-END */
1364 &ANALYZE-RESUME
1366 &ENDIF
1368 &IF DEFINED(EXCLUDE-include-lease) = 0 &THEN
1370 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-lease Procedure
1371 FUNCTION include-lease RETURNS LOGICAL
1372 ( INPUT lease-code AS INT ) :
1373 /*------------------------------------------------------------------------------
1374 Purpose:
1375 Notes: Dummy function.
1376 ------------------------------------------------------------------------------*/
1378 RETURN Yes. /* Function return value. */
1380 END FUNCTION.
1382 /* _UIB-CODE-BLOCK-END */
1383 &ANALYZE-RESUME
1385 &ENDIF