Added capital works blank section. Synced calling screen.
[capital-apms-progress.git] / process / gst-liable-leases.p
blob9d75ec3640df095da5130bb6ef84d19acde089fc
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File : process/gst-liable-leases.p
6 Purpose : Journal for GST Liable leases where GST is not charged
7 to tenants as part of rental.
9 Author(s) : Andrew McMillan
10 Created : 18/5/2000
11 ------------------------------------------------------------------------*/
12 DEF INPUT PARAMETER process-options AS CHAR NO-UNDO.
14 DEF VAR preview AS LOGI NO-UNDO INITIAL No.
15 DEF VAR period-start AS DATE NO-UNDO.
16 DEF VAR entity-type LIKE EntityType.EntityType NO-UNDO.
17 DEF VAR entity-1 LIKE AcctTran.EntityCode NO-UNDO.
18 DEF VAR entity-n LIKE AcctTran.EntityCode NO-UNDO.
19 DEF VAR debug AS LOGI NO-UNDO INITIAL Yes.
21 DEF VAR tenant-subtotals AS LOGI NO-UNDO INITIAL Yes.
22 RUN parse-parameters.
24 DEF VAR this-document LIKE NewDocument.DocumentCode NO-UNDO.
25 DEF VAR this-transaction LIKE NewAcctTrans.TransactionCode NO-UNDO.
26 DEF VAR debit-total LIKE AcctTran.Amount NO-UNDO.
27 DEF VAR og-total LIKE AcctTran.Amount NO-UNDO.
28 DEF VAR rent-total LIKE AcctTran.Amount NO-UNDO.
29 DEF VAR tax-total LIKE AcctTran.Amount NO-UNDO.
30 DEF VAR untaxed-total LIKE AcctTran.Amount NO-UNDO.
31 DEF VAR tax-amount LIKE AcctTran.Amount NO-UNDO.
32 DEF VAR property-total LIKE AcctTran.Amount NO-UNDO.
33 DEF VAR tenant-total LIKE AcctTran.Amount NO-UNDO.
34 DEF VAR rent-description AS CHAR NO-UNDO.
35 DEF VAR og-description AS CHAR NO-UNDO.
36 DEF VAR charge-period AS INT NO-UNDO.
37 DEF VAR line AS CHAR NO-UNDO.
38 DEF VAR i AS INT NO-UNDO.
39 DEF VAR rows AS INT NO-UNDO.
40 DEF VAR cols AS INT NO-UNDO.
41 DEF VAR last-property AS INT INITIAL -1 NO-UNDO.
42 DEF VAR non-monthly-period AS LOGICAL INITIAL No NO-UNDO.
43 DEF VAR property-header-displayed AS LOGICAL INITIAL No NO-UNDO.
46 {inc/ofc-this.i}
47 {inc/ofc-acct.i "DEBTORS" "sundry-debtors"}
48 {inc/ofc-acct.i "RENT" "rent-account"}
49 DEF VAR gst-entity LIKE AcctTran.EntityCode NO-UNDO.
50 IF Office.GST <> ? THEN DO:
51 {inc/ofc-acct.i "GST-OUT" "gst-account"}
52 gst-entity = OfficeControlAccount.EntityCode.
53 END.
54 {inc/ofc-set.i "RentCharge-Sequence" "set-sequence"}
55 IF set-sequence <> "PropertyCode" AND set-sequence <> "TenantCode" THEN
56 set-sequence = "Region".
57 {inc/ofc-set.i "RentCharge-Partial" "set-partial"}
58 {inc/ofc-set.i "Tenant-Accounts" "tenant-accounts-txt"}
59 DEF VAR tenant-accounts AS LOGI NO-UNDO INITIAL No.
60 IF SUBSTRING(TRIM(tenant-accounts-txt), 1, 1) = "Y" THEN tenant-accounts = Yes.
62 DEF VAR batch-string AS CHAR NO-UNDO.
63 DEF VAR date-string AS CHAR NO-UNDO.
64 FIND LAST Month WHERE Month.StartDate <= period-start NO-LOCK.
65 charge-period = Month.MonthCode.
66 batch-string = "GST Rental Liabilities for "
67 + entity-type + STRING(entity-1) + "-" + entity-type + STRING(entity-n)
68 + " to " + STRING( Month.EndDate, "99/99/9999").
70 date-string = " " + STRING( Month.StartDate, "99/99/9999") + " to " + STRING( Month.EndDate, "99/99/9999").
72 DEF VAR user-name AS CHAR NO-UNDO.
73 {inc/username.i "user-name"}
74 FIND Usr WHERE Usr.UserName = user-name NO-LOCK NO-ERROR.
76 DEF VAR pr-line AS CHAR INIT "" NO-UNDO. /* used everywhere to hold print line */
78 DEF VAR title-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
79 DEF VAR time-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
80 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
81 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
82 DEF VAR base-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,normal".
84 /* Doing this here ensures that Batch is scoped to the whole program */
85 DEF VAR batch-code LIKE NewBatch.BatchCode NO-UNDO.
86 FIND LAST Batch NO-LOCK NO-ERROR.
87 batch-code = 1 + (IF AVAILABLE(Batch) THEN Batch.BatchCode ELSE 0).
88 FIND LAST NewBatch NO-LOCK NO-ERROR.
89 IF AVAILABLE(NewBatch) AND NewBatch.BatchCode >= batch-code THEN batch-code = NewBatch.BatchCode + 1.
90 IF NOT preview THEN DO TRANSACTION:
91 CREATE NewBatch.
92 ASSIGN NewBatch.BatchCode = batch-code
93 NewBatch.BatchType = "AUTO"
94 NewBatch.Description = batch-string
95 NewBatch.PersonCode = (IF AVAILABLE(Usr) THEN Usr.PersonCode ELSE 0)
96 NewBatch.DocumentCount = 0
97 NewBatch.Total = 0 .
98 FIND CURRENT NewBatch NO-LOCK.
99 END.
101 /* Doing this here ensures that NewAcctTrans is scoped to the whole program */
102 FIND FIRST NewAcctTrans NO-LOCK NO-ERROR.
104 &SCOPED-DEFINE page-width 180
105 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
107 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
108 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
109 DEF VAR hline2 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
110 hline2 = "Rent Charge Preview: " + batch-string.
111 hline2 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
113 DEFINE FRAME heading-frame WITH 1 DOWN {&with-clause} PAGE-TOP.
114 FORM HEADER
115 timeStamp "Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
116 hline2 FORMAT "X({&page-width})"
117 SKIP (1)
118 WITH FRAME heading-frame.
120 DEFINE TEMP-TABLE TypeTotal NO-UNDO
121 FIELD ChargeType AS CHAR
122 FIELD ChargedAmount AS DEC
123 INDEX XPKTypeTotals IS UNIQUE PRIMARY ChargeType .
125 DEFINE TEMP-TABLE SpecialCharge NO-UNDO
126 FIELD PropertyCode AS INT
127 FIELD TenantCode AS INT
128 FIELD ChargeType AS CHAR
129 FIELD AreaDescription AS CHAR
130 FIELD FromDate AS DATE
131 FIELD ToDate AS DATE
132 FIELD Amount AS DEC
133 FIELD PeriodFraction AS DEC
134 INDEX XPKSpecialCharges IS PRIMARY PropertyCode TenantCode ChargeType.
136 DEF TEMP-TABLE TenantAmount NO-UNDO
137 FIELD TenantCode LIKE Tenant.TenantCode
138 FIELD LastBalance LIKE Tenant.CFBalance
139 FIELD LastBatch LIKE Tenant.BatchLastStatement
140 FIELD ThisBalance LIKE Tenant.CFBalance
141 FIELD LastRental LIKE Tenant.LastRentTotal
142 FIELD ThisRental LIKE Tenant.LastRentTotal
143 FIELD PropertyCode LIKE Tenant.EntityCode
144 INDEX XAK1Amounts IS UNIQUE TenantCode
145 INDEX XPKAmounts IS PRIMARY PropertyCode TenantCode.
147 /* So we report on something -> 0 transitions */
148 FOR EACH Tenant WHERE Tenant.EntityType='P':
149 CREATE TenantAmount.
150 ASSIGN TenantAmount.TenantCode = Tenant.TenantCode
151 TenantAmount.LastRental = Tenant.LastRentTotal
152 TenantAmount.ThisRental = 0
153 TenantAmount.PropertyCode = Tenant.EntityCode.
154 END.
156 /* _UIB-CODE-BLOCK-END */
157 &ANALYZE-RESUME
160 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
162 /* ******************** Preprocessor Definitions ******************** */
164 &Scoped-define PROCEDURE-TYPE Procedure
165 &Scoped-define DB-AWARE no
169 /* _UIB-PREPROCESSOR-BLOCK-END */
170 &ANALYZE-RESUME
173 /* ************************ Function Prototypes ********************** */
175 &IF DEFINED(EXCLUDE-include-lease) = 0 &THEN
177 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-lease Procedure
178 FUNCTION include-lease RETURNS LOGICAL
179 ( INPUT lease-code AS INT ) FORWARD.
181 /* _UIB-CODE-BLOCK-END */
182 &ANALYZE-RESUME
184 &ENDIF
186 &IF DEFINED(EXCLUDE-include-property) = 0 &THEN
188 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-property Procedure
189 FUNCTION include-property RETURNS LOGICAL
190 ( /* parameter-definitions */ ) FORWARD.
192 /* _UIB-CODE-BLOCK-END */
193 &ANALYZE-RESUME
195 &ENDIF
197 &IF DEFINED(EXCLUDE-include-tenant) = 0 &THEN
199 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-tenant Procedure
200 FUNCTION include-tenant RETURNS LOGICAL
201 ( /* parameter-definitions */ ) FORWARD.
203 /* _UIB-CODE-BLOCK-END */
204 &ANALYZE-RESUME
206 &ENDIF
209 /* *********************** Procedure Settings ************************ */
211 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
212 /* Settings for THIS-PROCEDURE
213 Type: Procedure
214 Allow:
215 Frames: 0
216 Add Fields to: Neither
217 Other Settings: CODE-ONLY COMPILE
219 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
221 /* ************************* Create Window ************************** */
223 &ANALYZE-SUSPEND _CREATE-WINDOW
224 /* DESIGN Window definition (used by the UIB)
225 CREATE WINDOW Procedure ASSIGN
226 HEIGHT = 20.7
227 WIDTH = 36.14.
228 /* END WINDOW DEFINITION */
230 &ANALYZE-RESUME
232 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
233 /* ************************* Included-Libraries *********************** */
235 {inc/method/m-txtrep.i}
236 {inc/rentchrg.i}
238 /* _UIB-CODE-BLOCK-END */
239 &ANALYZE-RESUME
245 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
248 /* *************************** Main Block *************************** */
249 ON WRITE OF NewAcctTrans OVERRIDE DO: END.
250 ON WRITE OF NewDocument OVERRIDE DO: END.
251 check-lease-inclusion = Yes.
253 RUN make-control-string ( "PCL", "reset,landscape,tm,1,a4,lm,4,courier,cpi,18,lpi,9",
254 OUTPUT line, OUTPUT rows, OUTPUT cols ).
256 RUN output-control-file ( line ).
257 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE VALUE(rows).
258 IF preview THEN VIEW FRAME heading-frame.
260 this-document = 0.
261 debit-total = 0.
263 FOR EACH Property NO-LOCK WHERE Property.Active AND (NOT Property.ExternallyManaged),
264 EACH TenancyLease OF Property NO-LOCK WHERE TenancyLease.LeaseStatus <> "PAST",
265 FIRST Tenant OF TenancyLease WHERE Tenant.Active NO-LOCK
266 BREAK BY Property.PropertyCode BY Tenant.TenantCode:
267 IF FIRST-OF( Tenant.TenantCode ) THEN RUN each-tenant.
268 END.
270 OUTPUT CLOSE.
272 DO TRANSACTION:
273 FIND CURRENT NewBatch EXCLUSIVE-LOCK.
274 ASSIGN NewBatch.DocumentCount = this-document
275 NewBatch.Total = debit-total .
276 FIND CURRENT NewBatch NO-LOCK.
277 FIND Month WHERE Month.MonthCode = charge-period NO-LOCK.
278 END.
280 RUN print-report-totals.
281 OUTPUT CLOSE.
282 RUN view-output-file ( preview ).
284 /* _UIB-CODE-BLOCK-END */
285 &ANALYZE-RESUME
288 /* ********************** Internal Procedures *********************** */
290 &IF DEFINED(EXCLUDE-after-each-property) = 0 &THEN
292 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE after-each-property Procedure
293 PROCEDURE after-each-property :
294 /*------------------------------------------------------------------------------
295 Purpose:
296 ------------------------------------------------------------------------------*/
297 DEF INPUT PARAMETER last-code AS INT NO-UNDO.
298 DEF INPUT PARAMETER total-amt AS DEC NO-UNDO.
300 IF last-code > -1 THEN DO:
301 line = "Total rental for P" + STRING(last-code,"99999") + " = " + STRING( total-amt, "->>>,>>>,>>9.99") + " " + STRING( (total-amt * 12), "->>>,>>>,>>9.99") + " p.a.".
302 RUN output-line.
303 line = "".
304 RUN output-line.
305 RUN output-line.
306 END.
308 property-header-displayed = No.
310 END PROCEDURE.
312 /* _UIB-CODE-BLOCK-END */
313 &ANALYZE-RESUME
315 &ENDIF
317 &IF DEFINED(EXCLUDE-charge-tax) = 0 &THEN
319 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE charge-tax Procedure
320 PROCEDURE charge-tax :
321 /*------------------------------------------------------------------------------
322 Purpose: Create a transaction charging tax
323 ------------------------------------------------------------------------------*/
324 DEF INPUT PARAMETER et LIKE NewAcctTrans.EntityType NO-UNDO.
325 DEF INPUT PARAMETER ec LIKE NewAcctTrans.EntityCode NO-UNDO.
326 DEF INPUT PARAMETER ac LIKE NewAcctTrans.AccountCode NO-UNDO.
327 DEF INPUT PARAMETER dat LIKE NewAcctTrans.Date NO-UNDO.
328 DEF INPUT PARAMETER ref LIKE NewAcctTrans.Reference NO-UNDO.
329 DEF INPUT PARAMETER amt LIKE NewAcctTrans.Amount NO-UNDO.
330 DEF INPUT PARAMETER dsc LIKE NewAcctTrans.Description NO-UNDO.
332 IF Office.GST = 0 OR amt = 0 THEN RETURN.
333 amt = amt * Office.GST / 100.
334 tax-total = tax-total + amt.
335 RUN create-transaction ( et, ec, ac, dat, ref, amt, "GST, " + dsc, amt ).
336 RUN create-transaction ( (IF tenant-accounts THEN Tenant.EntityType ELSE "L"),
337 (IF tenant-accounts THEN Tenant.EntityCode ELSE gst-entity),
338 gst-account, dat, ref, - amt, "GST, " + dsc, - amt ).
340 END PROCEDURE.
342 /* _UIB-CODE-BLOCK-END */
343 &ANALYZE-RESUME
345 &ENDIF
347 &IF DEFINED(EXCLUDE-create-transaction) = 0 &THEN
349 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-transaction Procedure
350 PROCEDURE create-transaction :
351 /*------------------------------------------------------------------------------
352 Purpose: Create a NewTransaction record
353 ------------------------------------------------------------------------------*/
354 DEF INPUT PARAMETER et LIKE NewAcctTrans.EntityType NO-UNDO.
355 DEF INPUT PARAMETER ec LIKE NewAcctTrans.EntityCode NO-UNDO.
356 DEF INPUT PARAMETER ac LIKE NewAcctTrans.AccountCode NO-UNDO.
357 DEF INPUT PARAMETER dat LIKE NewAcctTrans.Date NO-UNDO.
358 DEF INPUT PARAMETER ref LIKE NewAcctTrans.Reference NO-UNDO.
359 DEF INPUT PARAMETER amt LIKE NewAcctTrans.Amount NO-UNDO.
360 DEF INPUT PARAMETER dsc LIKE NewAcctTrans.Description NO-UNDO.
361 DEF INPUT PARAMETER tax-amount LIKE NewAcctTrans.Amount NO-UNDO.
363 IF amt > 0 THEN debit-total = debit-total + amt.
364 IF et = "P" OR
365 (et = "L" AND (ec <> gst-entity OR ac <> gst-account) ) OR
366 (et = "T" AND tenant-accounts AND ac <> sundry-debtors)
367 THEN DO:
368 tenant-total = tenant-total - amt.
370 IF preview THEN DO:
371 line = " T"
372 + STRING( Tenant.TenantCode, "99999") + " "
373 + STRING( ac, "9999.99") + " "
374 + STRING( dsc, "X(50)" ) + " "
375 + STRING( - amt, "->>>,>>>,>>9.99" ) + " "
376 + STRING( Tenant.Name, "X(50)")
377 + (IF non-monthly-period THEN " non-monthly" ELSE FILL(" ", 12) ) + " "
378 + (IF Office.GST <> ? AND tax-amount <> amt THEN "Tax:" + STRING( - (tax-amount * Office.GST / 100), "->>>,>>>,>>9.99" ) ELSE "").
379 RUN output-line.
380 RETURN.
381 END.
382 END.
384 IF preview THEN RETURN.
386 DO TRANSACTION:
387 IF this-transaction = 0 THEN DO:
388 this-document = this-document + 1.
389 CREATE NewDocument.
390 ASSIGN
391 NewDocument.BatchCode = batch-code
392 NewDocument.DocumentCode = this-document
393 NewDocument.DocumentType = "RENT"
394 NewDocument.Reference = ( et + STRING( ec, "99999") )
395 NewDocument.Description = NewBatch.Description
397 RELEASE NewDocument.
398 END.
400 this-transaction = this-transaction + 1.
401 CREATE NewAcctTrans.
402 ASSIGN
403 NewAcctTrans.BatchCode = batch-code
404 NewAcctTrans.DocumentCode = this-document
405 NewAcctTrans.TransactionCode = this-transaction
406 NewAcctTrans.EntityType = et
407 NewAcctTrans.EntityCode = ec
408 NewAcctTrans.AccountCode = ac
409 NewAcctTrans.Date = dat
410 NewAcctTrans.Reference = ref
411 NewAcctTrans.Amount = amt
412 NewAcctTrans.Description = dsc
415 RELEASE NewAcctTrans.
416 END.
419 END PROCEDURE.
421 /* _UIB-CODE-BLOCK-END */
422 &ANALYZE-RESUME
424 &ENDIF
426 &IF DEFINED(EXCLUDE-do-journal) = 0 &THEN
428 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE do-journal Procedure
429 PROCEDURE do-journal :
430 /*------------------------------------------------------------------------------
431 Purpose:
432 ------------------------------------------------------------------------------*/
433 DEF VAR tenant-rent-total AS DEC NO-UNDO INITIAL 0.
434 DEF VAR taxable-total AS DEC NO-UNDO.
435 DEF VAR last-type AS CHAR NO-UNDO INITIAL "not a possible type".
436 DEF VAR last-account AS DEC NO-UNDO INITIAL -999999.999 .
437 DEF VAR last-description AS CHAR NO-UNDO INITIAL "".
438 DEF VAR last-up-to AS DATE NO-UNDO.
439 DEF VAR charge-from AS DATE NO-UNDO .
440 DEF VAR annual-charge AS DEC NO-UNDO.
441 DEF VAR period-charge AS DEC NO-UNDO.
443 RUN build-tenant-charges( Tenant.TenantCode, Month.StartDate, Month.EndDate ).
445 FOR EACH ChargeDetail WHERE ChargeDetail.TenantCode = Tenant.TenantCode:
446 IF last-type <> ChargeDetail.ChargeType
447 OR last-account <> ChargeDetail.AccountCode
448 OR last-type = "S"
449 THEN DO TRANSACTION:
450 IF tenant-rent-total <> 0 THEN
451 RUN make-tenant-charge( last-type, last-account, last-description,
452 charge-from, last-up-to, tenant-rent-total, taxable-total ).
453 tenant-rent-total = 0.
454 taxable-total = 0.
455 non-monthly-period = No.
456 charge-from = ChargeDetail.ChargedFrom.
457 last-type = ChargeDetail.ChargeType.
458 last-account = ChargeDetail.AccountCode .
460 IF ChargeDetail.ChargeType = "S" THEN
461 last-description = ChargeDetail.Description.
462 ELSE
463 last-description = ChargeDetail.Description + (IF ChargeDetail.ChargeAmount < 0 THEN " credit" ELSE "").
464 END.
465 tenant-rent-total = tenant-rent-total + ChargeDetail.ChargeAmount.
466 last-up-to = ChargeDetail.ChargedUpTo .
468 IF ChargeDetail.ChargedUpTo <> Month.EndDate OR ChargeDetail.ChargedFrom <> Month.StartDate THEN
469 non-monthly-period = Yes.
470 END.
472 /* Save the values charged onto the RentCharge record */
473 FOR EACH TenancyLease NO-LOCK WHERE TenancyLease.TenantCode = Tenant.TenantCode,
474 EACH RentCharge EXCLUSIVE-LOCK OF TenancyLease:
475 annual-charge = 0.0 .
476 period-charge = 0.0 .
477 FOR EACH ChargeDetail WHERE ChargeDetail.TenancyLeaseCode = TenancyLease.TenancyLeaseCode
478 AND ChargeDetail.ChargeSeq = RentCharge.Sequence:
479 annual-charge = DEC(ChargeDetail.AnnualAmount) .
480 period-charge = period-charge + DEC(ChargeDetail.ChargeAmount) .
481 END.
482 IF annual-charge <> 0 THEN RentCharge.CurrentAnnualRental = annual-charge .
483 IF period-charge <> 0 THEN RentCharge.CurrentPeriodRental = period-charge .
484 END.
486 IF tenant-rent-total <> 0 THEN
487 RUN make-tenant-charge( last-type, last-account, last-description,
488 charge-from, last-up-to, tenant-rent-total, taxable-total ).
490 IF CAN-FIND( FIRST ChargeDetail WHERE ChargeDetail.ChargedFrom <> Month.StartDate
491 OR ChargeDetail.ChargedUpTo <> Month.EndDate )
492 THEN
493 RUN log-special-charge.
495 END PROCEDURE.
497 /* _UIB-CODE-BLOCK-END */
498 &ANALYZE-RESUME
500 &ENDIF
502 &IF DEFINED(EXCLUDE-each-tenant) = 0 &THEN
504 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
505 PROCEDURE each-tenant :
506 /*------------------------------------------------------------------------------
507 Purpose:
508 ------------------------------------------------------------------------------*/
509 IF NOT include-property() THEN RETURN.
510 IF NOT include-tenant() THEN RETURN.
512 this-transaction = 0.
513 non-monthly-period = No.
515 FIND TenantAmount WHERE TenantAmount.TenantCode = Tenant.TenantCode NO-ERROR.
516 IF NOT AVAILABLE(TenantAmount) THEN CREATE TenantAmount.
517 ASSIGN TenantAmount.TenantCode = Tenant.TenantCode
518 TenantAmount.LastRental = Tenant.LastRentTotal
519 TenantAmount.ThisRental = 0
520 TenantAmount.PropertyCode = Tenant.EntityCode.
522 RUN build-tenant-charges( Tenant.TenantCode, Month.StartDate, Month.EndDate ).
523 FIND FIRST ChargeDetail NO-ERROR.
524 IF NOT AVAILABLE(ChargeDetail) THEN RETURN.
526 IF preview THEN DO:
527 IF Property.PropertyCode <> last-property THEN DO:
528 RUN after-each-property( last-property, property-total ).
529 last-property = Property.PropertyCode.
530 property-total = 0.
531 END.
532 RUN property-header.
533 IF tenant-subtotals THEN DO:
534 line = Tenant.Name + " (T" + STRING( Tenant.TenantCode, "99999") + ")".
535 RUN output-line.
536 END.
537 END.
538 tenant-total = 0.
540 RUN do-journal.
542 TenantAmount.ThisRental = tenant-total.
544 IF preview AND tenant-subtotals THEN DO:
545 line = FILL( " ", 74) + "===============".
546 RUN output-line.
547 line = "Total charge for tenant " + STRING( Tenant.TenantCode, "99999")
548 + FILL( " ", 45) + STRING( tenant-total, "->>>,>>>,>>9.99").
549 RUN output-line.
550 line = "".
551 RUN output-line.
552 RUN output-line.
553 END.
555 END PROCEDURE.
557 /* _UIB-CODE-BLOCK-END */
558 &ANALYZE-RESUME
560 &ENDIF
562 &IF DEFINED(EXCLUDE-exception-report) = 0 &THEN
564 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE exception-report Procedure
565 PROCEDURE exception-report :
566 /*------------------------------------------------------------------------------
567 Purpose: Produce the exception report.
568 Notes: The printer initialisation is pretty manual since we use three
569 different styles of dealing with the printer in this program. (yuck!)
570 ------------------------------------------------------------------------------*/
571 DEF VAR prt-ctrl AS CHAR NO-UNDO.
572 DEF VAR line-height AS DEC NO-UNDO.
573 DEF VAR cols AS DEC NO-UNDO.
575 pclrep-font-text = "portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9".
576 RUN pcl-control-string ( "reset," + pclrep-font-text, OUTPUT prt-ctrl, OUTPUT cols,
577 OUTPUT line-height, OUTPUT pclrep-page-height ).
578 IF preview THEN
579 PUT UNFORMATTED SKIP(3).
580 ELSE
581 PUT CONTROL prt-ctrl + CHR(12) .
583 ASSIGN
584 pclrep-preview-mode = preview
585 pclrep-font-code = prt-ctrl
586 pclrep-font-height = STRING( line-height )
587 pclrep-current-font-height = line-height
588 pclrep-font-cols = STRING( cols )
589 pclrep-current-font = 1
590 pclrep-page-number = 0
591 pclrep-page-position = 0
592 pclrep-between-pages = No.
594 FOR EACH TenantAmount WHERE TenantAmount.LastRental <> TenantAmount.ThisRental,
595 FIRST Tenant OF TenantAmount NO-LOCK
596 BY Tenant.TenantCode:
597 pr-line = STRING( TenantAmount.TenantCode, "99999") + " "
598 + STRING( Tenant.Name, "X(40)" ) + " "
599 + STRING( TenantAmount.PropertyCode, "99999") + " "
600 + STRING( TenantAmount.LastRental, "->>,>>>,>>9.99") + " "
601 + (IF TenantAmount.ThisRental = ? THEN " Not charged" ELSE STRING( TenantAmount.ThisRental, "->>,>>>,>>9.99")).
602 RUN pclrep-line( base-font, pr-line ).
603 END.
605 RUN pclrep-line( base-font, "" ).
606 RUN pclrep-line( break2-font, "End of exception report" ).
608 END PROCEDURE.
610 /* _UIB-CODE-BLOCK-END */
611 &ANALYZE-RESUME
613 &ENDIF
615 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
617 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
618 PROCEDURE inst-page-footer :
619 /*------------------------------------------------------------------------------
620 Purpose:
621 ------------------------------------------------------------------------------*/
623 END PROCEDURE.
625 /* _UIB-CODE-BLOCK-END */
626 &ANALYZE-RESUME
628 &ENDIF
630 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
632 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
633 PROCEDURE inst-page-header :
634 /*------------------------------------------------------------------------------
635 Purpose: Print any page header
636 ------------------------------------------------------------------------------*/
638 RUN pclrep-line( "univers,Point,6,bold,Proportional", TimeStamp).
639 RUN pclrep-line( "", "" ).
640 RUN pclrep-line( "univers,Point,12,bold,Proportional",
641 "Rent Charges - Exception Report" ).
642 RUN pclrep-line( "", "" ).
644 /* Put any column headers here */
645 pr-line = "Tenant Property Last Rental This Rental" .
646 RUN pclrep-line( base-font + ",bold", pr-line ).
647 RUN pclrep-down-by(1).
649 END PROCEDURE.
651 /* _UIB-CODE-BLOCK-END */
652 &ANALYZE-RESUME
654 &ENDIF
656 &IF DEFINED(EXCLUDE-log-special-charge) = 0 &THEN
658 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE log-special-charge Procedure
659 PROCEDURE log-special-charge :
660 /*------------------------------------------------------------------------------
661 Purpose:
662 ------------------------------------------------------------------------------*/
663 FOR EACH ChargeDetail:
664 CREATE SpecialCharge.
665 SpecialCharge.PropertyCode = Property.PropertyCode.
666 SpecialCharge.TenantCode = Tenant.TenantCode.
667 SpecialCharge.ChargeType = ChargeDetail.ChargeType.
668 SpecialCharge.AreaDescription = ChargeDetail.AreaDescription.
669 SpecialCharge.FromDate = ChargeDetail.ChargedFrom.
670 SpecialCharge.ToDate = ChargeDetail.ChargedUpTo.
671 SpecialCharge.Amount = ChargeDetail.ChargeAmount.
672 SpecialCharge.PeriodFraction = ChargeDetail.PeriodFraction.
673 END.
674 END PROCEDURE.
676 /* _UIB-CODE-BLOCK-END */
677 &ANALYZE-RESUME
679 &ENDIF
681 &IF DEFINED(EXCLUDE-make-tenant-charge) = 0 &THEN
683 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE make-tenant-charge Procedure
684 PROCEDURE make-tenant-charge :
685 /*------------------------------------------------------------------------------
686 Purpose:
687 ------------------------------------------------------------------------------*/
688 DEF INPUT PARAMETER charge-type AS CHAR NO-UNDO.
689 DEF INPUT PARAMETER charge-account AS DEC NO-UNDO.
690 DEF INPUT PARAMETER base-description AS CHAR NO-UNDO.
691 DEF INPUT PARAMETER from-date AS DATE NO-UNDO.
692 DEF INPUT PARAMETER to-date AS DATE NO-UNDO.
693 DEF INPUT PARAMETER rent-amount AS DEC NO-UNDO.
694 DEF INPUT PARAMETER taxable-rent AS DEC NO-UNDO.
696 DEF VAR rent-description AS CHAR NO-UNDO.
699 /* The taxable amount will be the rental times the GST ratio */
700 /* I.e. if GST is 10%, this will be 10/11ths or (100/110) */
701 taxable-rent = rent-amount * (1 - (100 / (Office.GST + 100))).
703 /* MESSAGE rent-amount taxable-rent . */
706 property-total = property-total + rent-amount.
707 FIND TypeTotal WHERE TypeTotal.ChargeType = charge-type NO-ERROR.
708 IF NOT AVAILABLE(TypeTotal) THEN DO:
709 CREATE TypeTotal.
710 TypeTotal.ChargeType = charge-type.
711 END.
712 TypeTotal.ChargedAmount = TypeTotal.ChargedAmount + rent-amount .
714 rent-description = base-description
715 + " from " + STRING( from-date, "99/99/9999")
716 + " to " + STRING( to-date, "99/99/9999").
718 IF taxable-rent > 0 THEN
719 RUN charge-tax( Tenant.EntityType, Tenant.EntityCode, rent-account, Month.StartDate,
720 "T" + STRING( Tenant.TenantCode, "99999"), taxable-rent, rent-description ).
722 IF Office.GST <> ? THEN
723 untaxed-total = untaxed-total + ( rent-amount - taxable-rent ).
725 END PROCEDURE.
727 /* _UIB-CODE-BLOCK-END */
728 &ANALYZE-RESUME
730 &ENDIF
732 &IF DEFINED(EXCLUDE-output-line) = 0 &THEN
734 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-line Procedure
735 PROCEDURE output-line :
736 /*------------------------------------------------------------------------------
737 Purpose:
738 ------------------------------------------------------------------------------*/
739 IF line = "" THEN
740 PUT SKIP(1).
741 ELSE
742 PUT UNFORMATTED line SKIP.
744 END PROCEDURE.
746 /* _UIB-CODE-BLOCK-END */
747 &ANALYZE-RESUME
749 &ENDIF
751 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
753 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
754 PROCEDURE parse-parameters :
755 /*------------------------------------------------------------------------------
756 Purpose:
757 ------------------------------------------------------------------------------*/
758 DEF VAR i AS INT NO-UNDO.
759 DEF VAR token AS CHAR NO-UNDO.
761 {inc/showopts.i "process-options"}
764 DO i = 1 TO NUM-ENTRIES( process-options, "~n" ):
765 token = ENTRY( i, process-options, "~n" ).
766 CASE( ENTRY( 1, token ) ):
767 WHEN "Properties" THEN ASSIGN
768 entity-type = "P"
769 entity-1 = INT( ENTRY( 2, token ) )
770 entity-n = INT( ENTRY( 3, token ) ).
771 WHEN "Tenants" THEN ASSIGN
772 entity-type = "T"
773 entity-1 = INT( ENTRY( 2, token ) )
774 entity-n = INT( ENTRY( 3, token ) ).
775 WHEN "PeriodStart" THEN period-start = DATE( ENTRY(2,token) ).
776 WHEN "Preview" THEN preview = Yes.
777 END CASE.
778 END.
780 END PROCEDURE.
782 /* _UIB-CODE-BLOCK-END */
783 &ANALYZE-RESUME
785 &ENDIF
787 &IF DEFINED(EXCLUDE-print-report-totals) = 0 &THEN
789 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-report-totals Procedure
790 PROCEDURE print-report-totals :
791 /*------------------------------------------------------------------------------
792 Purpose:
793 ------------------------------------------------------------------------------*/
794 DEF VAR total-total AS DEC NO-UNDO.
796 IF property-total <> 0 THEN RUN after-each-property( last-property, property-total ).
798 IF CAN-FIND( FIRST SpecialCharge ) THEN RUN print-special-charges.
800 line = "". RUN output-line.
801 total-total = 0.
802 FOR EACH TypeTotal,
803 FIRST RentChargeType WHERE RentChargeType.RentChargeType = TypeTotal.ChargeType NO-LOCK:
804 line = "Total " /* + STRING( TypeTotal.ChargeType, "X(6)" ) */
805 + STRING( RentChargeType.Description, "X(30)") + " "
806 + STRING( TypeTotal.ChargedAmount, "->>>,>>>,>>9.99").
807 RUN output-line.
808 total-total = total-total + TypeTotal.ChargedAmount.
809 END.
810 line = FILL(" ",36) + FILL("-",15).
811 RUN output-line.
812 line = "Total "
813 + STRING( "Rent Charged", "X(30)") + " "
814 + STRING( total-total, "->>>,>>>,>>9.99").
815 RUN output-line.
817 line = "". RUN output-line.
818 line = "". RUN output-line.
819 line = "Total Un-taxed = " + STRING( untaxed-total, "->>>,>>>,>>9.99").
820 RUN output-line.
821 line = "Total GST = " + STRING( tax-total, "->>>,>>>,>>9.99").
822 RUN output-line.
823 line = "".
824 RUN output-line.
825 line = "Total for batch = " + STRING( debit-total, "->>>,>>>,>>9.99").
826 RUN output-line.
828 END PROCEDURE.
830 /* _UIB-CODE-BLOCK-END */
831 &ANALYZE-RESUME
833 &ENDIF
835 &IF DEFINED(EXCLUDE-print-special-charges) = 0 &THEN
837 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-special-charges Procedure
838 PROCEDURE print-special-charges :
839 /*------------------------------------------------------------------------------
840 Purpose:
841 ------------------------------------------------------------------------------*/
842 line = "List of Non Monthly charges". RUN output-line.
843 line = "===========================". RUN output-line.
845 line = "Prop Tnnt Type Area description From To Amount Fraction".
846 RUN output-line.
848 FOR EACH SpecialCharge:
849 FIND Property OF SpecialCharge NO-LOCK.
850 FIND Tenant OF SpecialCharge NO-LOCK.
851 line = STRING( SpecialCharge.PropertyCode, ">9999") + " "
852 + STRING( SpecialCharge.TenantCode, ">9999") + " "
853 + STRING( SpecialCharge.ChargeType, "X(4)") + " "
854 + STRING( SpecialCharge.AreaDescription, "X(30)") + " "
855 + STRING( SpecialCharge.FromDate, "99/99/9999") + " "
856 + STRING( SpecialCharge.ToDate, "99/99/9999") + " "
857 + STRING( SpecialCharge.Amount, "->>,>>>,>>9.99") + " "
858 + STRING( SpecialCharge.PeriodFraction, "-9.999999").
859 RUN output-line.
860 END.
862 END PROCEDURE.
864 /* _UIB-CODE-BLOCK-END */
865 &ANALYZE-RESUME
867 &ENDIF
869 &IF DEFINED(EXCLUDE-property-header) = 0 &THEN
871 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-header Procedure
872 PROCEDURE property-header :
873 /*------------------------------------------------------------------------------
874 Purpose:
875 ------------------------------------------------------------------------------*/
876 IF property-header-displayed THEN RETURN.
878 property-header-displayed = Yes.
880 IF AVAILABLE(Property) THEN DO:
881 line = STRING( Property.PropertyCode, "99999") + " "
882 + Property.Name .
883 RUN output-line.
884 line = FILL( "=", LENGTH(line)).
885 RUN output-line.
886 END.
888 END PROCEDURE.
890 /* _UIB-CODE-BLOCK-END */
891 &ANALYZE-RESUME
893 &ENDIF
895 /* ************************ Function Implementations ***************** */
897 &IF DEFINED(EXCLUDE-include-lease) = 0 &THEN
899 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-lease Procedure
900 FUNCTION include-lease RETURNS LOGICAL
901 ( INPUT lease-code AS INT ) :
902 /*------------------------------------------------------------------------------
903 Purpose:
904 Notes: Returns a True/False whether to include the current lease
905 ------------------------------------------------------------------------------*/
906 DEF BUFFER loc_Lease FOR TenancyLease.
908 FIND loc_Lease WHERE TenancyLeaseCode = lease-code NO-LOCK NO-ERROR.
909 IF NOT AVAILABLE(loc_Lease) THEN RETURN FALSE.
911 RETURN loc_Lease.HasRatchet AND NOT( loc_Lease.TaxApplies ) .
913 END FUNCTION.
915 /* _UIB-CODE-BLOCK-END */
916 &ANALYZE-RESUME
918 &ENDIF
920 &IF DEFINED(EXCLUDE-include-property) = 0 &THEN
922 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-property Procedure
923 FUNCTION include-property RETURNS LOGICAL
924 ( /* parameter-definitions */ ) :
925 /*------------------------------------------------------------------------------
926 Purpose:
927 Notes: Returns a True/False whether to include the current property
928 ------------------------------------------------------------------------------*/
929 IF entity-type <> "P" THEN RETURN TRUE. /* we aren't selecting by property */
931 RETURN (Property.PropertyCode >= entity-1 AND Property.PropertyCode <= entity-n ).
933 END FUNCTION.
935 /* _UIB-CODE-BLOCK-END */
936 &ANALYZE-RESUME
938 &ENDIF
940 &IF DEFINED(EXCLUDE-include-tenant) = 0 &THEN
942 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-tenant Procedure
943 FUNCTION include-tenant RETURNS LOGICAL
944 ( /* parameter-definitions */ ) :
945 /*------------------------------------------------------------------------------
946 Purpose:
947 Notes: Returns a True/False whether to include the current tenant
948 ------------------------------------------------------------------------------*/
949 IF entity-type <> "T" THEN RETURN TRUE. /* we aren't selecting by tenant */
951 RETURN (Tenant.TenantCode >= entity-1 AND Tenant.TenantCode <= entity-n ).
953 END FUNCTION.
955 /* _UIB-CODE-BLOCK-END */
956 &ANALYZE-RESUME
958 &ENDIF