1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
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
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.
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.
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.
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:
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
98 FIND CURRENT NewBatch
NO-LOCK.
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.
115 timeStamp
"Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
116 hline2
FORMAT "X({&page-width})"
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
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'
:
150 ASSIGN TenantAmount.TenantCode
= Tenant.TenantCode
151 TenantAmount.LastRental
= Tenant.LastRentTotal
152 TenantAmount.ThisRental
= 0
153 TenantAmount.PropertyCode
= Tenant.EntityCode.
156 /* _UIB-CODE-BLOCK-END
*/
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
*/
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
*/
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
*/
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
*/
209 /* *********************** Procedure Settings
************************ */
211 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
212 /* Settings for
THIS-PROCEDURE
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
228 /* END WINDOW DEFINITION
*/
232 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
233 /* ************************* Included-Libraries
*********************** */
235 {inc
/method
/m-txtrep.i
}
238 /* _UIB-CODE-BLOCK-END
*/
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.
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.
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.
280 RUN print-report-totals.
282 RUN view-output-file
( preview
).
284 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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.".
308 property-header-displayed
= No.
312 /* _UIB-CODE-BLOCK-END
*/
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
).
342 /* _UIB-CODE-BLOCK-END
*/
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.
365 (et
= "L" AND (ec
<> gst-entity
OR ac
<> gst-account
) ) OR
366 (et
= "T" AND tenant-accounts
AND ac
<> sundry-debtors
)
368 tenant-total
= tenant-total
- amt.
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 "").
384 IF preview
THEN RETURN.
387 IF this-transaction
= 0 THEN DO:
388 this-document
= this-document
+ 1.
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
400 this-transaction
= this-transaction
+ 1.
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.
421 /* _UIB-CODE-BLOCK-END
*/
426 &IF DEFINED(EXCLUDE-do-journal) = 0 &THEN
428 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE do-journal Procedure
429 PROCEDURE do-journal
:
430 /*------------------------------------------------------------------------------
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
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.
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.
463 last-description
= ChargeDetail.Description
+ (IF ChargeDetail.ChargeAmount
< 0 THEN " credit" ELSE "").
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.
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
) .
482 IF annual-charge
<> 0 THEN RentCharge.CurrentAnnualRental
= annual-charge .
483 IF period-charge
<> 0 THEN RentCharge.CurrentPeriodRental
= period-charge .
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
)
493 RUN log-special-charge.
497 /* _UIB-CODE-BLOCK-END
*/
502 &IF DEFINED(EXCLUDE-each-tenant) = 0 &THEN
504 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
505 PROCEDURE each-tenant
:
506 /*------------------------------------------------------------------------------
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.
527 IF Property.PropertyCode
<> last-property
THEN DO:
528 RUN after-each-property
( last-property
, property-total
).
529 last-property
= Property.PropertyCode.
533 IF tenant-subtotals
THEN DO:
534 line
= Tenant.Name
+ " (T" + STRING( Tenant.TenantCode
, "99999") + ")".
542 TenantAmount.ThisRental
= tenant-total.
544 IF preview
AND tenant-subtotals
THEN DO:
545 line
= FILL( " ", 74) + "===============".
547 line
= "Total charge for tenant " + STRING( Tenant.TenantCode
, "99999")
548 + FILL( " ", 45) + STRING( tenant-total
, "->>>,>>>,>>9.99").
557 /* _UIB-CODE-BLOCK-END
*/
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
).
579 PUT UNFORMATTED SKIP(3).
581 PUT CONTROL prt-ctrl
+ CHR(12) .
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
).
605 RUN pclrep-line
( base-font
, "" ).
606 RUN pclrep-line
( break2-font
, "End of exception report" ).
610 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
621 ------------------------------------------------------------------------------*/
625 /* _UIB-CODE-BLOCK-END
*/
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).
651 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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.
676 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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:
710 TypeTotal.ChargeType
= charge-type.
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
).
727 /* _UIB-CODE-BLOCK-END
*/
732 &IF DEFINED(EXCLUDE-output-line) = 0 &THEN
734 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-line Procedure
735 PROCEDURE output-line
:
736 /*------------------------------------------------------------------------------
738 ------------------------------------------------------------------------------*/
742 PUT UNFORMATTED line
SKIP.
746 /* _UIB-CODE-BLOCK-END
*/
751 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
753 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
754 PROCEDURE parse-parameters
:
755 /*------------------------------------------------------------------------------
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
769 entity-1
= INT( ENTRY( 2, token
) )
770 entity-n
= INT( ENTRY( 3, token
) ).
771 WHEN "Tenants" THEN ASSIGN
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.
782 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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.
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").
808 total-total
= total-total
+ TypeTotal.ChargedAmount.
810 line
= FILL(" ",36) + FILL("-",15).
813 + STRING( "Rent Charged", "X(30)") + " "
814 + STRING( total-total
, "->>>,>>>,>>9.99").
817 line
= "".
RUN output-line.
818 line
= "".
RUN output-line.
819 line
= "Total Un-taxed = " + STRING( untaxed-total
, "->>>,>>>,>>9.99").
821 line
= "Total GST = " + STRING( tax-total
, "->>>,>>>,>>9.99").
825 line
= "Total for batch = " + STRING( debit-total
, "->>>,>>>,>>9.99").
830 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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".
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").
864 /* _UIB-CODE-BLOCK-END
*/
869 &IF DEFINED(EXCLUDE-property-header) = 0 &THEN
871 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-header Procedure
872 PROCEDURE property-header
:
873 /*------------------------------------------------------------------------------
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") + " "
884 line
= FILL( "=", LENGTH(line
)).
890 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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
) .
915 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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
).
935 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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
).
955 /* _UIB-CODE-BLOCK-END
*/