Added capital works blank section. Synced calling screen.
[capital-apms-progress.git] / process / rentchrg.p
blob0d3166842a7c2a1de183d6a2acb9b627bae424f6
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File : rentchg.p
6 Purpose : Create monthly charges for Rent and Outgoings
7 Author(s) : Andrew McMillan
8 Created : 27/11/96
9 ------------------------------------------------------------------------*/
10 DEF INPUT PARAMETER process-options AS CHAR NO-UNDO.
12 DEF VAR charge-type AS CHAR NO-UNDO.
13 DEF VAR charge-period LIKE Month.MonthCode NO-UNDO.
14 DEF VAR preview AS LOGICAL NO-UNDO.
15 DEF VAR frequency-list AS CHAR NO-UNDO.
16 DEF VAR debug-mode AS LOGI NO-UNDO INITIAL No.
17 DEF VAR show-differences AS LOGI NO-UNDO INITIAL No.
18 DEF VAR selection-type AS CHAR NO-UNDO INITIAL "".
19 DEF VAR selection-criteria AS CHAR NO-UNDO INITIAL "".
20 DEF VAR property-1 AS INT NO-UNDO INITIAL 0.
21 DEF VAR property-n AS INT NO-UNDO INITIAL 99999.
22 DEF VAR tenant-1 AS INT NO-UNDO INITIAL 0.
23 DEF VAR tenant-n AS INT NO-UNDO INITIAL 99999.
24 DEF VAR company-list AS CHAR NO-UNDO.
25 DEF VAR tenant-subtotals AS LOGI NO-UNDO INITIAL No.
26 RUN parse-parameters.
28 DEF VAR this-document LIKE NewDocument.DocumentCode NO-UNDO.
29 DEF VAR this-transaction LIKE NewAcctTrans.TransactionCode NO-UNDO.
30 DEF VAR debit-total LIKE AcctTran.Amount NO-UNDO.
31 DEF VAR og-total LIKE AcctTran.Amount NO-UNDO.
32 DEF VAR rent-total LIKE AcctTran.Amount NO-UNDO.
33 DEF VAR tax-total LIKE AcctTran.Amount NO-UNDO.
34 DEF VAR untaxed-total LIKE AcctTran.Amount NO-UNDO.
35 DEF VAR tax-amount LIKE AcctTran.Amount NO-UNDO.
36 DEF VAR property-total LIKE AcctTran.Amount NO-UNDO.
37 DEF VAR tenant-total LIKE AcctTran.Amount NO-UNDO.
38 DEF VAR rent-description AS CHAR NO-UNDO.
39 DEF VAR og-description AS CHAR NO-UNDO.
40 DEF VAR line AS CHAR NO-UNDO.
41 DEF VAR i AS INT NO-UNDO.
42 DEF VAR rows AS INT NO-UNDO.
43 DEF VAR cols AS INT NO-UNDO.
44 DEF VAR last-property AS INT INITIAL -1 NO-UNDO.
45 DEF VAR non-monthly-period AS LOGICAL INITIAL No NO-UNDO.
46 DEF VAR property-header-displayed AS LOGICAL INITIAL No NO-UNDO.
49 {inc/ofc-this.i}
50 {inc/ofc-acct.i "DEBTORS" "sundry-debtors"}
51 {inc/ofc-acct.i "RENT" "rent-account"}
52 DEF VAR gst-entity LIKE AcctTran.EntityCode NO-UNDO.
53 IF Office.GST <> ? THEN DO:
54 {inc/ofc-acct.i "GST-OUT" "gst-account"}
55 gst-entity = OfficeControlAccount.EntityCode.
56 END.
57 {inc/ofc-set.i "RentCharge-Sequence" "set-sequence"}
58 IF set-sequence <> "PropertyCode" AND set-sequence <> "TenantCode" THEN
59 set-sequence = "Region".
60 IF selection-type = "RANGE" THEN set-sequence = "PropertyCode".
61 ELSE IF selection-type = "TENANTS" THEN set-sequence = "TenantCode".
63 {inc/ofc-set.i "RentCharge-Partial" "set-partial"}
64 {inc/ofc-set.i "Tenant-Accounts" "tenant-accounts-txt"}
65 DEF VAR tenant-accounts AS LOGI NO-UNDO INITIAL No.
66 IF SUBSTRING(TRIM(tenant-accounts-txt), 1, 1) = "Y" THEN tenant-accounts = Yes.
68 {inc/ofc-set-l.i "GST-Multi-Company" "GST-Multi-Company" }
70 DEF VAR batch-string AS CHAR NO-UNDO.
71 DEF VAR date-string AS CHAR NO-UNDO.
72 FIND Month WHERE Month.MonthCode = charge-period NO-LOCK.
73 batch-string = "Rent charges ".
74 CASE selection-type:
75 WHEN "ALL" THEN batch-string = batch-string + " for all tenants".
76 WHEN "RANGE" THEN batch-string = batch-string + "P" + selection-criteria.
77 WHEN "TENANTS" THEN batch-string = batch-string + "T" + selection-criteria.
78 WHEN "MANAGER" THEN DO:
79 FIND Person WHERE Person.PersonCode = INT( selection-criteria ) NO-LOCK.
80 batch-string = batch-string + " - " + Person.FirstName + " " + Person.LastName + " buildings".
81 END.
82 WHEN "LIST" THEN DO:
83 FIND ConsolidationList WHERE ConsolidationList.Name = selection-criteria NO-LOCK.
84 batch-string = batch-string + " - " + ConsolidationList.Description.
85 END.
86 WHEN "REGION" THEN DO:
87 FIND Region WHERE Region.Region = selection-criteria NO-LOCK.
88 batch-string = batch-string + " - " + Region.Name.
89 END.
90 END CASE.
91 batch-string = batch-string + " to " + STRING( Month.EndDate, "99/99/9999").
93 date-string = " " + STRING( Month.StartDate, "99/99/9999") + " to " + STRING( Month.EndDate, "99/99/9999").
95 DEF VAR user-name AS CHAR NO-UNDO.
96 {inc/username.i "user-name"}
97 FIND Usr WHERE Usr.UserName = user-name NO-LOCK NO-ERROR.
99 DEF VAR pr-line AS CHAR INIT "" NO-UNDO. /* used everywhere to hold print line */
101 DEF VAR title-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
102 DEF VAR time-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
103 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
104 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
105 DEF VAR base-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,normal".
107 /* Doing this here ensures that Batch is scoped to the whole program */
108 DEF VAR batch-code LIKE NewBatch.BatchCode NO-UNDO.
109 FIND LAST Batch NO-LOCK NO-ERROR.
110 batch-code = 1 + (IF AVAILABLE(Batch) THEN Batch.BatchCode ELSE 0).
111 FIND LAST NewBatch NO-LOCK NO-ERROR.
112 IF AVAILABLE(NewBatch) AND NewBatch.BatchCode >= batch-code THEN batch-code = NewBatch.BatchCode + 1.
113 IF NOT preview THEN DO TRANSACTION:
114 CREATE NewBatch.
115 ASSIGN NewBatch.BatchCode = batch-code
116 NewBatch.BatchType = "AUTO"
117 NewBatch.Description = batch-string
118 NewBatch.PersonCode = (IF AVAILABLE(Usr) THEN Usr.PersonCode ELSE 0)
119 NewBatch.DocumentCount = 0
120 NewBatch.Total = 0 .
121 FIND CURRENT NewBatch NO-LOCK.
122 END.
124 /* Doing this here ensures that NewAcctTrans is scoped to the whole program */
125 FIND FIRST NewAcctTrans NO-LOCK NO-ERROR.
127 &SCOPED-DEFINE page-width 180
128 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
130 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
131 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
132 DEF VAR hline2 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
133 hline2 = "Rent Charge Preview: " + batch-string.
134 hline2 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
136 DEFINE FRAME heading-frame WITH 1 DOWN {&with-clause} PAGE-TOP.
137 FORM HEADER
138 timeStamp "Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
139 hline2 FORMAT "X({&page-width})"
140 SKIP (1)
141 WITH FRAME heading-frame.
143 DEFINE TEMP-TABLE TypeTotal NO-UNDO
144 FIELD ChargeType AS CHAR
145 FIELD ChargedAmount AS DEC
146 INDEX XPKTypeTotals IS UNIQUE PRIMARY ChargeType .
148 DEFINE TEMP-TABLE SpecialCharge NO-UNDO
149 FIELD PropertyCode AS INT
150 FIELD TenantCode AS INT
151 FIELD ChargeType AS CHAR
152 FIELD AreaDescription AS CHAR
153 FIELD FromDate AS DATE
154 FIELD ToDate AS DATE
155 FIELD Amount AS DEC
156 FIELD PeriodFraction AS DEC
157 INDEX XPKSpecialCharges IS PRIMARY PropertyCode TenantCode ChargeType.
159 DEF TEMP-TABLE TenantAmount NO-UNDO
160 FIELD TenantCode LIKE Tenant.TenantCode
161 FIELD LastBalance LIKE Tenant.CFBalance
162 FIELD LastBatch LIKE Tenant.BatchLastStatement
163 FIELD ThisBalance LIKE Tenant.CFBalance
164 FIELD LastRental LIKE Tenant.LastRentTotal
165 FIELD ThisRental LIKE Tenant.LastRentTotal
166 FIELD PropertyCode LIKE Tenant.EntityCode
167 INDEX XAK1Amounts IS UNIQUE TenantCode
168 INDEX XPKAmounts IS PRIMARY PropertyCode TenantCode.
170 /* So we report on something -> 0 transitions */
171 FOR EACH Tenant WHERE Tenant.EntityType='P':
172 CREATE TenantAmount.
173 ASSIGN TenantAmount.TenantCode = Tenant.TenantCode
174 TenantAmount.LastRental = Tenant.LastRentTotal
175 TenantAmount.ThisRental = 0
176 TenantAmount.PropertyCode = Tenant.EntityCode.
177 END.
179 /* _UIB-CODE-BLOCK-END */
180 &ANALYZE-RESUME
183 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
185 /* ******************** Preprocessor Definitions ******************** */
187 &Scoped-define PROCEDURE-TYPE Procedure
188 &Scoped-define DB-AWARE no
192 /* _UIB-PREPROCESSOR-BLOCK-END */
193 &ANALYZE-RESUME
196 /* ************************ Function Prototypes ********************** */
198 &IF DEFINED(EXCLUDE-include-lease) = 0 &THEN
200 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-lease Procedure
201 FUNCTION include-lease RETURNS LOGICAL
202 ( INPUT lease-code AS INT ) FORWARD.
204 /* _UIB-CODE-BLOCK-END */
205 &ANALYZE-RESUME
207 &ENDIF
209 &IF DEFINED(EXCLUDE-include-property) = 0 &THEN
211 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-property Procedure
212 FUNCTION include-property RETURNS LOGICAL
213 ( /* parameter-definitions */ ) FORWARD.
215 /* _UIB-CODE-BLOCK-END */
216 &ANALYZE-RESUME
218 &ENDIF
221 /* *********************** Procedure Settings ************************ */
223 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
224 /* Settings for THIS-PROCEDURE
225 Type: Procedure
226 Allow:
227 Frames: 0
228 Add Fields to: Neither
229 Other Settings: CODE-ONLY COMPILE
231 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
233 /* ************************* Create Window ************************** */
235 &ANALYZE-SUSPEND _CREATE-WINDOW
236 /* DESIGN Window definition (used by the UIB)
237 CREATE WINDOW Procedure ASSIGN
238 HEIGHT = 21.25
239 WIDTH = 36.14.
240 /* END WINDOW DEFINITION */
242 &ANALYZE-RESUME
244 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
245 /* ************************* Included-Libraries *********************** */
247 {inc/method/m-txtrep.i}
248 {inc/rentchrg.i}
250 /* _UIB-CODE-BLOCK-END */
251 &ANALYZE-RESUME
257 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
260 /* *************************** Main Block *************************** */
261 ON WRITE OF NewAcctTrans OVERRIDE DO: END.
262 ON WRITE OF NewDocument OVERRIDE DO: END.
264 RUN make-control-string ( "PCL", "reset,landscape,tm,1,a4,lm,4,courier,cpi,18,lpi,9",
265 OUTPUT line, OUTPUT rows, OUTPUT cols ).
267 RUN output-control-file ( line ).
268 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE VALUE(rows).
269 IF preview THEN VIEW FRAME heading-frame.
271 this-document = 0.
272 debit-total = 0.
274 &SCOPED-DEFINE F-E-DEFINITION ~
275 FOR EACH Property NO-LOCK ~
276 WHERE Property.Active AND (NOT Property.ExternallyManaged),~
277 EACH TenancyLease OF Property NO-LOCK ~
278 WHERE TenancyLease.LeaseStatus <> "PAST",~
279 FIRST Tenant OF TenancyLease WHERE Tenant.Active NO-LOCK
280 /* SCOPED-DEFINE ends */
282 IF set-sequence = "PropertyCode":U THEN DO:
283 {&F-E-DEFINITION} BREAK BY Property.PropertyCode BY Tenant.TenantCode:
284 IF FIRST-OF( Tenant.TenantCode ) THEN RUN each-tenant.
285 END.
286 END.
287 ELSE IF set-sequence = "TenantCode":U THEN DO:
288 {&F-E-DEFINITION} BREAK BY Tenant.TenantCode:
289 IF FIRST-OF( Tenant.TenantCode ) THEN RUN each-tenant.
290 END.
291 END.
292 ELSE DO:
293 {&F-E-DEFINITION} BREAK BY Property.Region BY Property.PropertyCode BY Property.ShortName BY Tenant.TenantCode:
294 IF FIRST-OF( Tenant.TenantCode ) THEN RUN each-tenant.
295 END.
296 END.
298 IF preview THEN DO:
299 RUN print-report-totals.
300 IF show-differences THEN RUN exception-report.
301 OUTPUT CLOSE.
302 RUN view-output-file ( preview ).
303 END.
304 ELSE DO:
306 OUTPUT CLOSE.
308 OS-DELETE VALUE( txtrep-control-file ).
309 OS-DELETE VALUE( txtrep-print-file ).
311 DO TRANSACTION:
312 FIND CURRENT NewBatch EXCLUSIVE-LOCK.
313 ASSIGN NewBatch.DocumentCount = this-document
314 NewBatch.Total = debit-total .
315 FIND CURRENT NewBatch NO-LOCK.
316 FIND Month WHERE Month.MonthCode = charge-period NO-LOCK.
317 IF selection-type = "ALL" THEN DO:
318 {inc/ofc-this.i}
319 FIND OfficeSetting OF Office WHERE OfficeSetting.SetName = "Rent-Charged-To" EXCLUSIVE-LOCK NO-ERROR.
320 IF NOT AVAILABLE(OfficeSetting) THEN DO:
321 CREATE OfficeSetting.
322 OfficeSetting.OfficeCode = Office.OfficeCode.
323 OfficeSetting.SetName = "Rent-Charged-To".
324 END.
325 OfficeSetting.SetValue = STRING( Month.EndDate, "99/99/9999").
326 END.
327 END.
329 /* Update the tenant records with the amount charged */
330 FOR EACH TenantAmount, FIRST Tenant OF TenantAmount EXCLUSIVE-LOCK,
331 FIRST Property WHERE Property.PropertyCode = Tenant.EntityCode NO-LOCK:
332 IF include-property() THEN
333 Tenant.LastRentTotal = TenantAmount.ThisRental.
334 END.
336 END.
338 /* _UIB-CODE-BLOCK-END */
339 &ANALYZE-RESUME
342 /* ********************** Internal Procedures *********************** */
344 &IF DEFINED(EXCLUDE-after-each-property) = 0 &THEN
346 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE after-each-property Procedure
347 PROCEDURE after-each-property :
348 /*------------------------------------------------------------------------------
349 Purpose:
350 ------------------------------------------------------------------------------*/
351 DEF INPUT PARAMETER last-code AS INT NO-UNDO.
352 DEF INPUT PARAMETER total-amt AS DEC NO-UNDO.
354 IF last-code > -1 THEN DO:
355 line = "Total rental for P" + STRING(last-code,"99999") + " = " + STRING( total-amt, "->>>,>>>,>>9.99") + " " + STRING( (total-amt * 12), "->>>,>>>,>>9.99") + " p.a.".
356 RUN output-line.
357 line = "".
358 RUN output-line.
359 RUN output-line.
360 END.
362 property-header-displayed = No.
364 END PROCEDURE.
366 /* _UIB-CODE-BLOCK-END */
367 &ANALYZE-RESUME
369 &ENDIF
371 &IF DEFINED(EXCLUDE-charge-rentals) = 0 &THEN
373 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE charge-rentals Procedure
374 PROCEDURE charge-rentals :
375 /*------------------------------------------------------------------------------
376 Purpose:
377 ------------------------------------------------------------------------------*/
378 DEF VAR tenant-rent-total AS DEC NO-UNDO INITIAL 0.
379 DEF VAR taxable-total AS DEC NO-UNDO INITIAL 0.
380 DEF VAR last-type AS CHAR NO-UNDO INITIAL "not a possible type".
381 DEF VAR last-account AS DEC NO-UNDO INITIAL -999999.999 .
382 DEF VAR last-description AS CHAR NO-UNDO INITIAL "".
383 DEF VAR last-up-to AS DATE NO-UNDO.
384 DEF VAR charge-from AS DATE NO-UNDO .
385 DEF VAR annual-charge AS DEC NO-UNDO.
386 DEF VAR period-charge AS DEC NO-UNDO.
388 RUN build-tenant-charges( Tenant.TenantCode, Month.StartDate, Month.EndDate ).
390 FOR EACH ChargeDetail WHERE ChargeDetail.TenantCode = Tenant.TenantCode:
391 IF last-type <> ChargeDetail.ChargeType
392 OR last-account <> ChargeDetail.AccountCode
393 OR last-type = "S"
394 THEN DO TRANSACTION:
395 IF tenant-rent-total <> 0 THEN
396 RUN make-tenant-charge( last-type, last-account, last-description,
397 charge-from, last-up-to, tenant-rent-total, taxable-total ).
398 tenant-rent-total = 0.
399 taxable-total = 0.
400 non-monthly-period = No.
401 charge-from = ChargeDetail.ChargedFrom.
402 last-type = ChargeDetail.ChargeType.
403 last-account = ChargeDetail.AccountCode .
405 IF ChargeDetail.ChargeType = "S" THEN
406 last-description = ChargeDetail.Description.
407 ELSE
408 last-description = ChargeDetail.Description + (IF ChargeDetail.ChargeAmount < 0 THEN " credit" ELSE "").
409 END.
410 tenant-rent-total = tenant-rent-total + ChargeDetail.ChargeAmount.
411 taxable-total = taxable-total + ChargeDetail.TaxableAmount.
412 last-up-to = ChargeDetail.ChargedUpTo .
414 IF ChargeDetail.ChargedUpTo <> Month.EndDate OR ChargeDetail.ChargedFrom <> Month.StartDate THEN
415 non-monthly-period = Yes.
416 END.
418 /* Save the values charged onto the RentCharge record */
419 FOR EACH TenancyLease NO-LOCK WHERE TenancyLease.TenantCode = Tenant.TenantCode,
420 EACH RentCharge EXCLUSIVE-LOCK OF TenancyLease:
421 annual-charge = 0.0 .
422 period-charge = 0.0 .
423 FOR EACH ChargeDetail WHERE ChargeDetail.TenancyLeaseCode = TenancyLease.TenancyLeaseCode
424 AND ChargeDetail.ChargeSeq = RentCharge.Sequence:
425 annual-charge = DEC(ChargeDetail.AnnualAmount) .
426 period-charge = period-charge + DEC(ChargeDetail.ChargeAmount) .
427 END.
428 IF annual-charge <> 0 THEN RentCharge.CurrentAnnualRental = annual-charge .
429 IF period-charge <> 0 THEN RentCharge.CurrentPeriodRental = period-charge .
430 END.
432 IF tenant-rent-total <> 0 THEN
433 RUN make-tenant-charge( last-type, last-account, last-description,
434 charge-from, last-up-to, tenant-rent-total, taxable-total ).
436 IF CAN-FIND( FIRST ChargeDetail WHERE (ChargeDetail.ChargedFrom <> Month.StartDate
437 OR ChargeDetail.ChargedUpTo <> Month.EndDate))
438 THEN
439 RUN log-special-charge.
441 END PROCEDURE.
443 /* _UIB-CODE-BLOCK-END */
444 &ANALYZE-RESUME
446 &ENDIF
448 &IF DEFINED(EXCLUDE-charge-tax) = 0 &THEN
450 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE charge-tax Procedure
451 PROCEDURE charge-tax :
452 /*------------------------------------------------------------------------------
453 Purpose: Create a transaction charging tax
454 ------------------------------------------------------------------------------*/
455 DEF INPUT PARAMETER et LIKE NewAcctTrans.EntityType NO-UNDO.
456 DEF INPUT PARAMETER ec LIKE NewAcctTrans.EntityCode NO-UNDO.
457 DEF INPUT PARAMETER ac LIKE NewAcctTrans.AccountCode NO-UNDO.
458 DEF INPUT PARAMETER dat LIKE NewAcctTrans.Date NO-UNDO.
459 DEF INPUT PARAMETER ref LIKE NewAcctTrans.Reference NO-UNDO.
460 DEF INPUT PARAMETER amt LIKE NewAcctTrans.Amount NO-UNDO.
461 DEF INPUT PARAMETER dsc LIKE NewAcctTrans.Description NO-UNDO.
463 DEF VAR v-gst-entity AS INT NO-UNDO.
465 IF Office.GST = 0 OR amt = 0 THEN RETURN.
466 amt = amt * Office.GST / 100.
467 tax-total = tax-total + amt.
468 RUN create-transaction ( et, ec, ac, dat, ref, amt, "GST, " + dsc, amt ).
470 /* Find the ledger to allocate GST */
471 IF GST-Multi-company = YES THEN DO:
472 /*FIND Property WHERE Property.PropertyCode = ec NO-LOCK.*/
473 ASSIGN v-gst-entity = Property.CompanyCode.
474 END.
475 ELSE v-gst-entity = gst-entity.
477 RUN create-transaction ( (IF tenant-accounts THEN Tenant.EntityType ELSE "L"),
478 (IF tenant-accounts THEN Tenant.EntityCode ELSE gst-entity),
479 gst-account, dat, ref, - amt, "GST, " + dsc, - amt ).
481 END PROCEDURE.
483 /* _UIB-CODE-BLOCK-END */
484 &ANALYZE-RESUME
486 &ENDIF
488 &IF DEFINED(EXCLUDE-create-transaction) = 0 &THEN
490 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-transaction Procedure
491 PROCEDURE create-transaction :
492 /*------------------------------------------------------------------------------
493 Purpose: Create a NewTransaction record
494 ------------------------------------------------------------------------------*/
495 DEF INPUT PARAMETER et LIKE NewAcctTrans.EntityType NO-UNDO.
496 DEF INPUT PARAMETER ec LIKE NewAcctTrans.EntityCode NO-UNDO.
497 DEF INPUT PARAMETER ac LIKE NewAcctTrans.AccountCode NO-UNDO.
498 DEF INPUT PARAMETER dat LIKE NewAcctTrans.Date NO-UNDO.
499 DEF INPUT PARAMETER ref LIKE NewAcctTrans.Reference NO-UNDO.
500 DEF INPUT PARAMETER amt LIKE NewAcctTrans.Amount NO-UNDO.
501 DEF INPUT PARAMETER dsc LIKE NewAcctTrans.Description NO-UNDO.
502 DEF INPUT PARAMETER tax-amount LIKE NewAcctTrans.Amount NO-UNDO.
504 IF amt > 0 THEN debit-total = debit-total + amt.
505 IF et = "P" OR
506 (et = "L" AND (ec <> gst-entity OR ac <> gst-account) ) OR
507 (et = "T" AND tenant-accounts AND ac <> sundry-debtors)
508 THEN DO:
509 tenant-total = tenant-total - amt.
511 IF preview THEN DO:
512 line = " T"
513 + STRING( Tenant.TenantCode, "99999") + " "
514 + STRING( ac, "9999.99") + " "
515 + STRING( dsc, "X(50)" ) + " "
516 + STRING( - amt, "->>>,>>>,>>9.99" ) + " "
517 + STRING( Tenant.Name, "X(50)")
518 + (IF non-monthly-period THEN " non-monthly" ELSE FILL(" ", 12) ) + " "
519 + (IF Office.GST <> ? AND tax-amount <> amt THEN "Tax:" + STRING( - (tax-amount * Office.GST / 100), "->>>,>>>,>>9.99" ) ELSE "").
520 RUN output-line.
521 RETURN.
522 END.
523 END.
525 IF preview THEN RETURN.
527 DO TRANSACTION:
528 IF this-transaction = 0 THEN DO:
529 this-document = this-document + 1.
530 CREATE NewDocument.
531 ASSIGN
532 NewDocument.BatchCode = batch-code
533 NewDocument.DocumentCode = this-document
534 NewDocument.DocumentType = "RENT"
535 NewDocument.Reference = ( et + STRING( ec, "99999") )
536 NewDocument.Description = NewBatch.Description
538 RELEASE NewDocument.
539 END.
541 this-transaction = this-transaction + 1.
542 CREATE NewAcctTrans.
543 ASSIGN
544 NewAcctTrans.BatchCode = batch-code
545 NewAcctTrans.DocumentCode = this-document
546 NewAcctTrans.TransactionCode = this-transaction
547 NewAcctTrans.EntityType = et
548 NewAcctTrans.EntityCode = ec
549 NewAcctTrans.AccountCode = ac
550 NewAcctTrans.Date = dat
551 NewAcctTrans.Reference = ref
552 NewAcctTrans.Amount = amt
553 NewAcctTrans.Description = dsc
556 RELEASE NewAcctTrans.
557 END.
560 END PROCEDURE.
562 /* _UIB-CODE-BLOCK-END */
563 &ANALYZE-RESUME
565 &ENDIF
567 &IF DEFINED(EXCLUDE-each-tenant) = 0 &THEN
569 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
570 PROCEDURE each-tenant :
571 /*------------------------------------------------------------------------------
572 Purpose:
573 ------------------------------------------------------------------------------*/
574 IF NOT include-property() THEN RETURN.
576 this-transaction = 0.
577 non-monthly-period = No.
579 FIND TenantAmount WHERE TenantAmount.TenantCode = Tenant.TenantCode NO-ERROR.
580 IF NOT AVAILABLE(TenantAmount) THEN CREATE TenantAmount.
581 ASSIGN TenantAmount.TenantCode = Tenant.TenantCode
582 TenantAmount.LastRental = Tenant.LastRentTotal
583 TenantAmount.ThisRental = 0
584 TenantAmount.PropertyCode = Tenant.EntityCode.
586 RUN build-tenant-charges( Tenant.TenantCode, Month.StartDate, Month.EndDate ).
587 FIND FIRST ChargeDetail NO-ERROR.
588 IF NOT AVAILABLE(ChargeDetail) THEN RETURN.
590 IF preview THEN DO:
591 IF Property.PropertyCode <> last-property THEN DO:
592 RUN after-each-property( last-property, property-total ).
593 last-property = Property.PropertyCode.
594 property-total = 0.
595 END.
596 RUN property-header.
597 IF tenant-subtotals THEN DO:
598 line = Tenant.Name + " (T" + STRING( Tenant.TenantCode, "99999") + ")".
599 RUN output-line.
600 END.
601 END.
602 tenant-total = 0.
604 RUN charge-rentals.
606 TenantAmount.ThisRental = tenant-total.
608 IF preview AND tenant-subtotals THEN DO:
609 line = FILL( " ", 74) + "===============".
610 RUN output-line.
611 line = "Total charge for tenant " + STRING( Tenant.TenantCode, "99999")
612 + FILL( " ", 45) + STRING( tenant-total, "->>>,>>>,>>9.99").
613 RUN output-line.
614 line = "".
615 RUN output-line.
616 RUN output-line.
617 END.
619 END PROCEDURE.
621 /* _UIB-CODE-BLOCK-END */
622 &ANALYZE-RESUME
624 &ENDIF
626 &IF DEFINED(EXCLUDE-exception-report) = 0 &THEN
628 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE exception-report Procedure
629 PROCEDURE exception-report :
630 /*------------------------------------------------------------------------------
631 Purpose: Produce the exception report.
632 Notes: The printer initialisation is pretty manual since we use three
633 different styles of dealing with the printer in this program. (yuck!)
634 ------------------------------------------------------------------------------*/
635 DEF VAR prt-ctrl AS CHAR NO-UNDO.
636 DEF VAR line-height AS DEC NO-UNDO.
637 DEF VAR cols AS DEC NO-UNDO.
639 pclrep-font-text = "portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9".
640 RUN pcl-control-string ( "reset," + pclrep-font-text, OUTPUT prt-ctrl, OUTPUT cols,
641 OUTPUT line-height, OUTPUT pclrep-page-height ).
642 IF preview THEN
643 PUT UNFORMATTED SKIP(3).
644 ELSE
645 PUT CONTROL prt-ctrl + CHR(12) .
647 ASSIGN
648 pclrep-preview-mode = preview
649 pclrep-font-code = prt-ctrl
650 pclrep-font-height = STRING( line-height )
651 pclrep-current-font-height = line-height
652 pclrep-font-cols = STRING( cols )
653 pclrep-current-font = 1
654 pclrep-page-number = 0
655 pclrep-page-position = 0
656 pclrep-between-pages = No.
658 FOR EACH TenantAmount WHERE TenantAmount.LastRental <> TenantAmount.ThisRental,
659 FIRST Tenant OF TenantAmount NO-LOCK,
660 FIRST Property WHERE Property.PropertyCode = Tenant.EntityCode
661 BY Tenant.TenantCode:
662 IF NOT include-property() THEN NEXT.
663 pr-line = STRING( TenantAmount.TenantCode, "99999") + " "
664 + STRING( Tenant.Name, "X(40)" ) + " "
665 + STRING( TenantAmount.PropertyCode, "99999") + " "
666 + STRING( TenantAmount.LastRental, "->>,>>>,>>9.99") + " "
667 + (IF TenantAmount.ThisRental = ? THEN " Not charged" ELSE STRING( TenantAmount.ThisRental, "->>,>>>,>>9.99")).
668 RUN pclrep-line( base-font, pr-line ).
669 END.
671 RUN pclrep-line( base-font, "" ).
672 RUN pclrep-line( break2-font, "End of exception report" ).
674 END PROCEDURE.
676 /* _UIB-CODE-BLOCK-END */
677 &ANALYZE-RESUME
679 &ENDIF
681 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
683 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
684 PROCEDURE inst-page-footer :
685 /*------------------------------------------------------------------------------
686 Purpose:
687 ------------------------------------------------------------------------------*/
689 END PROCEDURE.
691 /* _UIB-CODE-BLOCK-END */
692 &ANALYZE-RESUME
694 &ENDIF
696 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
698 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
699 PROCEDURE inst-page-header :
700 /*------------------------------------------------------------------------------
701 Purpose: Print any page header
702 ------------------------------------------------------------------------------*/
704 RUN pclrep-line( "univers,Point,6,bold,Proportional", TimeStamp).
705 RUN pclrep-line( "", "" ).
706 RUN pclrep-line( "univers,Point,12,bold,Proportional",
707 "Rent Charges - Exception Report" ).
708 RUN pclrep-line( "", "" ).
710 /* Put any column headers here */
711 pr-line = "Tenant Property Last Rental This Rental" .
712 RUN pclrep-line( base-font + ",bold", pr-line ).
713 RUN pclrep-down-by(1).
715 END PROCEDURE.
717 /* _UIB-CODE-BLOCK-END */
718 &ANALYZE-RESUME
720 &ENDIF
722 &IF DEFINED(EXCLUDE-log-special-charge) = 0 &THEN
724 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE log-special-charge Procedure
725 PROCEDURE log-special-charge :
726 /*------------------------------------------------------------------------------
727 Purpose:
728 ------------------------------------------------------------------------------*/
729 FOR EACH ChargeDetail WHERE ChargeDetail.ChargeAmount <> 0 :
730 CREATE SpecialCharge.
731 SpecialCharge.PropertyCode = Property.PropertyCode.
732 SpecialCharge.TenantCode = Tenant.TenantCode.
733 SpecialCharge.ChargeType = ChargeDetail.ChargeType.
734 SpecialCharge.AreaDescription = ChargeDetail.AreaDescription.
735 SpecialCharge.FromDate = ChargeDetail.ChargedFrom.
736 SpecialCharge.ToDate = ChargeDetail.ChargedUpTo.
737 SpecialCharge.Amount = ChargeDetail.ChargeAmount.
738 SpecialCharge.PeriodFraction = ChargeDetail.PeriodFraction.
739 END.
740 END PROCEDURE.
742 /* _UIB-CODE-BLOCK-END */
743 &ANALYZE-RESUME
745 &ENDIF
747 &IF DEFINED(EXCLUDE-make-tenant-charge) = 0 &THEN
749 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE make-tenant-charge Procedure
750 PROCEDURE make-tenant-charge :
751 /*------------------------------------------------------------------------------
752 Purpose:
753 ------------------------------------------------------------------------------*/
754 DEF INPUT PARAMETER charge-type AS CHAR NO-UNDO.
755 DEF INPUT PARAMETER charge-account AS DEC NO-UNDO.
756 DEF INPUT PARAMETER base-description AS CHAR NO-UNDO.
757 DEF INPUT PARAMETER from-date AS DATE NO-UNDO.
758 DEF INPUT PARAMETER to-date AS DATE NO-UNDO.
759 DEF INPUT PARAMETER rent-amount AS DEC NO-UNDO.
760 DEF INPUT PARAMETER taxable-rent AS DEC NO-UNDO.
762 DEF VAR rent-description AS CHAR NO-UNDO.
764 property-total = property-total + rent-amount.
765 FIND TypeTotal WHERE TypeTotal.ChargeType = charge-type NO-ERROR.
766 IF NOT AVAILABLE(TypeTotal) THEN DO:
767 CREATE TypeTotal.
768 TypeTotal.ChargeType = charge-type.
769 END.
770 TypeTotal.ChargedAmount = TypeTotal.ChargedAmount + rent-amount .
772 rent-description = base-description
773 + " from " + STRING( from-date, "99/99/9999")
774 + " to " + STRING( to-date, "99/99/9999").
776 RUN create-transaction( "T", Tenant.TenantCode, sundry-debtors,
777 Month.StartDate,
778 "T" + STRING( Tenant.TenantCode, "99999"),
779 rent-amount, rent-description, taxable-rent ).
781 IF tenant-accounts THEN
782 RUN create-transaction( "T", Tenant.TenantCode, charge-account,
783 Month.StartDate,
784 "T" + STRING( Tenant.TenantCode, "99999"),
785 - rent-amount, rent-description, - taxable-rent ).
786 ELSE
787 RUN create-transaction( Tenant.EntityType, Tenant.EntityCode, charge-account,
788 Month.StartDate,
789 "T" + STRING( Tenant.TenantCode, "99999"),
790 - rent-amount, rent-description, - taxable-rent ).
792 IF taxable-rent <> 0 THEN
793 RUN charge-tax( "T", Tenant.TenantCode, sundry-debtors, Month.StartDate,
794 "T" + STRING( Tenant.TenantCode, "99999"), taxable-rent, rent-description ).
796 IF Office.GST <> ? THEN
797 untaxed-total = untaxed-total + ( rent-amount - taxable-rent ).
799 END PROCEDURE.
801 /* _UIB-CODE-BLOCK-END */
802 &ANALYZE-RESUME
804 &ENDIF
806 &IF DEFINED(EXCLUDE-output-line) = 0 &THEN
808 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-line Procedure
809 PROCEDURE output-line :
810 /*------------------------------------------------------------------------------
811 Purpose:
812 ------------------------------------------------------------------------------*/
813 IF line = "" THEN
814 PUT SKIP(1).
815 ELSE
816 PUT UNFORMATTED line SKIP.
818 END PROCEDURE.
820 /* _UIB-CODE-BLOCK-END */
821 &ANALYZE-RESUME
823 &ENDIF
825 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
827 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
828 PROCEDURE parse-parameters :
829 /*------------------------------------------------------------------------------
830 Purpose:
831 ------------------------------------------------------------------------------*/
833 DEF VAR charge-type AS CHAR NO-UNDO.
834 DEF VAR charge-period LIKE Month.MonthCode NO-UNDO.
835 DEF VAR preview AS LOGICAL NO-UNDO.
836 DEF VAR frequency-list AS CHAR NO-UNDO.
839 {inc/showopts.i "process-options"}
841 charge-type = ENTRY( 1, process-options, "~n").
842 charge-period = INT( ENTRY( 2, process-options, "~n")).
843 preview = (ENTRY( 3, process-options, "~n") = "Yes").
844 frequency-list = ENTRY( 4, process-options, "~n").
846 DEF VAR i AS INT NO-UNDO.
847 DEF VAR token AS CHAR NO-UNDO.
849 DO i = 5 TO NUM-ENTRIES( process-options, "~n" ):
850 token = ENTRY( i, process-options, "~n" ).
851 CASE( ENTRY( 1, token ) ):
852 WHEN "Property" THEN ASSIGN
853 selection-type = ENTRY( 2, token )
854 selection-criteria = SUBSTRING( token, INDEX( token, ",", INDEX( token, ",") + 1) + 1).
855 WHEN "TenantTotals" THEN tenant-subtotals = Yes.
856 WHEN "ShowDifferences" THEN show-differences = Yes.
857 END CASE.
858 END.
860 IF selection-type = "LIST" THEN DO:
861 FIND ConsolidationList WHERE ConsolidationList.Name = selection-criteria NO-LOCK NO-ERROR.
862 IF AVAILABLE(ConsolidationList) THEN
863 company-list = ConsolidationList.CompanyList.
864 ELSE
865 company-list = "".
866 END.
867 ELSE IF selection-type = "RANGE" THEN DO:
868 property-1 = INT(ENTRY( 1, selection-criteria, "-")).
869 property-n = INT(ENTRY( 2, selection-criteria, "-")).
870 END.
871 ELSE IF selection-type = "TENANTS" THEN DO:
872 tenant-1 = INT(ENTRY( 1, selection-criteria, "-")).
873 tenant-n = INT(ENTRY( 2, selection-criteria, "-")).
874 END.
876 END PROCEDURE.
878 /* _UIB-CODE-BLOCK-END */
879 &ANALYZE-RESUME
881 &ENDIF
883 &IF DEFINED(EXCLUDE-print-report-totals) = 0 &THEN
885 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-report-totals Procedure
886 PROCEDURE print-report-totals :
887 /*------------------------------------------------------------------------------
888 Purpose:
889 ------------------------------------------------------------------------------*/
890 DEF VAR total-total AS DEC NO-UNDO.
892 IF property-total <> 0 THEN RUN after-each-property( last-property, property-total ).
894 IF CAN-FIND( FIRST SpecialCharge ) THEN RUN print-special-charges.
896 line = "". RUN output-line.
897 total-total = 0.
898 FOR EACH TypeTotal,
899 FIRST RentChargeType WHERE RentChargeType.RentChargeType = TypeTotal.ChargeType NO-LOCK:
900 line = "Total " /* + STRING( TypeTotal.ChargeType, "X(6)" ) */
901 + STRING( RentChargeType.Description, "X(30)") + " "
902 + STRING( TypeTotal.ChargedAmount, "->>>,>>>,>>9.99").
903 RUN output-line.
904 total-total = total-total + TypeTotal.ChargedAmount.
905 END.
906 line = FILL(" ",36) + FILL("-",15).
907 RUN output-line.
908 line = "Total "
909 + STRING( "Rent Charged", "X(30)") + " "
910 + STRING( total-total, "->>>,>>>,>>9.99").
911 RUN output-line.
913 line = "". RUN output-line.
914 line = "". RUN output-line.
915 line = "Total Un-taxed = " + STRING( untaxed-total, "->>>,>>>,>>9.99").
916 RUN output-line.
917 line = "Total GST = " + STRING( tax-total, "->>>,>>>,>>9.99").
918 RUN output-line.
919 line = "".
920 RUN output-line.
921 line = "Total for batch = " + STRING( debit-total, "->>>,>>>,>>9.99").
922 RUN output-line.
924 END PROCEDURE.
926 /* _UIB-CODE-BLOCK-END */
927 &ANALYZE-RESUME
929 &ENDIF
931 &IF DEFINED(EXCLUDE-print-special-charges) = 0 &THEN
933 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-special-charges Procedure
934 PROCEDURE print-special-charges :
935 /*------------------------------------------------------------------------------
936 Purpose:
937 ------------------------------------------------------------------------------*/
938 line = "List of Non Monthly charges". RUN output-line.
939 line = "===========================". RUN output-line.
941 line = "Prop Tnnt Type Area description From To Amount Fraction".
942 RUN output-line.
944 FOR EACH SpecialCharge:
945 FIND Property OF SpecialCharge NO-LOCK.
946 FIND Tenant OF SpecialCharge NO-LOCK.
947 line = STRING( SpecialCharge.PropertyCode, ">9999") + " "
948 + STRING( SpecialCharge.TenantCode, ">9999") + " "
949 + STRING( SpecialCharge.ChargeType, "X(4)") + " "
950 + STRING( SpecialCharge.AreaDescription, "X(30)") + " "
951 + STRING( SpecialCharge.FromDate, "99/99/9999") + " "
952 + STRING( SpecialCharge.ToDate, "99/99/9999") + " "
953 + STRING( SpecialCharge.Amount, "->>,>>>,>>9.99") + " "
954 + STRING( SpecialCharge.PeriodFraction, "-9.999999").
955 RUN output-line.
956 END.
958 END PROCEDURE.
960 /* _UIB-CODE-BLOCK-END */
961 &ANALYZE-RESUME
963 &ENDIF
965 &IF DEFINED(EXCLUDE-property-header) = 0 &THEN
967 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-header Procedure
968 PROCEDURE property-header :
969 /*------------------------------------------------------------------------------
970 Purpose:
971 ------------------------------------------------------------------------------*/
972 IF property-header-displayed THEN RETURN.
974 property-header-displayed = Yes.
976 IF AVAILABLE(Property) THEN DO:
977 line = STRING( Property.PropertyCode, "99999") + " "
978 + Property.Name .
979 RUN output-line.
980 line = FILL( "=", LENGTH(line)).
981 RUN output-line.
982 END.
984 END PROCEDURE.
986 /* _UIB-CODE-BLOCK-END */
987 &ANALYZE-RESUME
989 &ENDIF
991 /* ************************ Function Implementations ***************** */
993 &IF DEFINED(EXCLUDE-include-lease) = 0 &THEN
995 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-lease Procedure
996 FUNCTION include-lease RETURNS LOGICAL
997 ( INPUT lease-code AS INT ) :
998 /*------------------------------------------------------------------------------
999 Purpose:
1000 Notes: Dummy function.
1001 ------------------------------------------------------------------------------*/
1003 RETURN Yes. /* Function return value. */
1005 END FUNCTION.
1007 /* _UIB-CODE-BLOCK-END */
1008 &ANALYZE-RESUME
1010 &ENDIF
1012 &IF DEFINED(EXCLUDE-include-property) = 0 &THEN
1014 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-property Procedure
1015 FUNCTION include-property RETURNS LOGICAL
1016 ( /* parameter-definitions */ ) :
1017 /*------------------------------------------------------------------------------
1018 Purpose:
1019 Notes: Returns a True/False whether to include the current property
1020 ------------------------------------------------------------------------------*/
1021 CASE selection-type:
1022 WHEN "ALL" THEN
1023 RETURN TRUE.
1024 WHEN "RANGE" THEN
1025 RETURN (Property.PropertyCode >= property-1)
1026 AND (Property.PropertyCode <= property-n ).
1027 WHEN "TENANTS" THEN
1028 RETURN (Tenant.TenantCode >= tenant-1)
1029 AND (Tenant.TenantCode <= tenant-n ).
1030 WHEN "REGION" THEN
1031 RETURN (Property.Region = selection-criteria).
1032 WHEN "MANAGER" THEN
1033 RETURN (Property.Manager = INT(selection-criteria)).
1034 WHEN "LIST" THEN
1035 RETURN (LOOKUP( STRING(Property.CompanyCode), company-list ) > 0) .
1036 OTHERWISE
1037 MESSAGE "Selection type >>" + selection-type + "<< (" + selection-criteria + ") not yet implemented.".
1038 END CASE.
1040 RETURN FALSE. /* by default */
1042 END FUNCTION.
1044 /* _UIB-CODE-BLOCK-END */
1045 &ANALYZE-RESUME
1047 &ENDIF