1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
6 Purpose
: Create monthly charges for Rent and Outgoings
7 Author
(s
) : Andrew McMillan
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.
18 DEF VAR this-document
LIKE NewDocument.DocumentCode
NO-UNDO.
19 DEF VAR this-transaction
LIKE NewAcctTrans.TransactionCode
NO-UNDO.
20 DEF VAR debit-total
LIKE AcctTran.Amount
NO-UNDO.
21 DEF VAR og-total
LIKE AcctTran.Amount
NO-UNDO.
22 DEF VAR rent-total
LIKE AcctTran.Amount
NO-UNDO.
23 DEF VAR tax-total
LIKE AcctTran.Amount
NO-UNDO.
24 DEF VAR untaxed-total
LIKE AcctTran.Amount
NO-UNDO.
25 DEF VAR tax-amount
LIKE AcctTran.Amount
NO-UNDO.
26 DEF VAR property-total
LIKE AcctTran.Amount
NO-UNDO.
27 DEF VAR tenant-total
LIKE AcctTran.Amount
NO-UNDO.
28 DEF VAR rent-description
AS CHAR NO-UNDO.
29 DEF VAR og-description
AS CHAR NO-UNDO.
30 DEF VAR line
AS CHAR NO-UNDO.
31 DEF VAR i
AS INT NO-UNDO.
32 DEF VAR rows
AS INT NO-UNDO.
33 DEF VAR cols
AS INT NO-UNDO.
34 DEF VAR last-property
AS INT INITIAL -1 NO-UNDO.
35 DEF VAR partial-period
AS LOGICAL INITIAL No
NO-UNDO.
39 {inc
/ofc-acct.i
"DEBTORS" "sundry-debtors"}
40 {inc
/ofc-acct.i
"RENT" "rent-account"}
41 {inc
/ofc-acct.i
"OUTGOINGS" "og-account"}
42 DEF VAR gst-entity
LIKE AcctTran.EntityCode
NO-UNDO.
43 IF Office.GST
<> ?
THEN DO:
44 {inc
/ofc-acct.i
"GST-OUT" "gst-account"}
45 gst-entity
= OfficeControlAccount.EntityCode.
47 {inc
/ofc-set.i
"RentCharge-Type" "set-type"}
48 IF set-type
<> "Accounts" THEN set-type
= "Single".
49 {inc
/ofc-set.i
"RentCharge-Sequence" "set-sequence"}
50 IF set-sequence
<> "PropertyCode" AND set-sequence
<> "TenantCode" THEN
51 set-sequence
= "Region".
52 {inc
/ofc-set.i
"RentCharge-Partial" "set-partial"}
53 {inc
/ofc-set-l.i
"GST-Multi-Company" "GST-Multi-Company" }
56 DEF VAR rent-charge-routine
AS CHAR NO-UNDO.
57 rent-charge-routine
= "charge-rental-" + set-type.
58 IF THIS-PROCEDURE:GET-SIGNATURE( rent-charge-routine
) = "" THEN DO:
59 MESSAGE "The rent charge type '" + set-type
"' is not valid." SKIP(1)
60 "Set it to 'Single' or 'Accounts'"
61 VIEW-AS ALERT-BOX TITLE "Invalid RentCharge-Type setting for office.".
65 DEF VAR batch-string
AS CHAR NO-UNDO.
66 DEF VAR date-string
AS CHAR NO-UNDO.
67 FIND Month
WHERE Month.MonthCode
= charge-period
NO-LOCK.
68 batch-string
= (IF INDEX( charge-type
, "R") > 0 THEN "Rent" ELSE "").
69 IF INDEX( charge-type
, "O") > 0 THEN
70 batch-string
= batch-string
+ (IF INDEX( charge-type
, "R") > 0 THEN " & " ELSE "") + "Outgoings".
71 batch-string
= batch-string
+ " to " + STRING( Month.EndDate
, "99/99/9999").
73 date-string
= " " + STRING( Month.StartDate
, "99/99/9999") + " to " + STRING( Month.EndDate
, "99/99/9999").
74 DEF VAR tenant-date-string
AS CHAR NO-UNDO.
76 DEF VAR user-name
AS CHAR NO-UNDO.
77 {inc
/username.i
"user-name"}
78 FIND Usr
WHERE Usr.UserName
= user-name
NO-LOCK NO-ERROR.
80 /* Doing this here ensures that Batch is scoped to the whole program
*/
81 DEF VAR batch-code
LIKE NewBatch.BatchCode
NO-UNDO.
82 FIND LAST Batch
NO-LOCK NO-ERROR.
83 batch-code
= 1 + (IF AVAILABLE(Batch
) THEN Batch.BatchCode
ELSE 0).
84 FIND LAST NewBatch
NO-LOCK NO-ERROR.
85 IF AVAILABLE(NewBatch
) AND NewBatch.BatchCode
>= batch-code
THEN batch-code
= NewBatch.BatchCode
+ 1.
86 IF NOT preview
THEN DO:
89 NewBatch.BatchCode
= batch-code
90 NewBatch.BatchType
= "AUTO"
91 NewBatch.Description
= batch-string
92 NewBatch.PersonCode
= (IF AVAILABLE(Usr
) THEN Usr.PersonCode
ELSE 0)
93 NewBatch.DocumentCount
= 0
98 /* Doing this here ensures that NewAcctTrans is scoped to the whole program
*/
99 FIND FIRST NewAcctTrans
NO-LOCK NO-ERROR.
101 &SCOPED-DEFINE page-width 180
102 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
104 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
105 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
106 DEF VAR hline2
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
107 hline2
= "Rent Charge Preview: " + batch-string.
108 hline2
= SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
110 DEFINE FRAME heading-frame
WITH 1 DOWN {&with-clause} PAGE-TOP.
112 timeStamp
"Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
113 hline2
FORMAT "X({&page-width})"
115 WITH FRAME heading-frame.
117 /* _UIB-CODE-BLOCK-END
*/
121 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
123 /* ******************** Preprocessor Definitions
******************** */
125 &Scoped-define PROCEDURE-TYPE Procedure
126 &Scoped-define DB-AWARE no
130 /* _UIB-PREPROCESSOR-BLOCK-END
*/
135 /* *********************** Procedure Settings
************************ */
137 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
138 /* Settings for
THIS-PROCEDURE
142 Add Fields to
: Neither
143 Other Settings
: CODE-ONLY
COMPILE
145 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
147 /* ************************* Create Window
************************** */
149 &ANALYZE-SUSPEND _CREATE-WINDOW
150 /* DESIGN Window definition
(used by the UIB
)
151 CREATE WINDOW Procedure
ASSIGN
154 /* END WINDOW DEFINITION
*/
158 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
159 /* ************************* Included-Libraries
*********************** */
161 {inc
/method
/m-txtrep.i
}
163 /* _UIB-CODE-BLOCK-END
*/
170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
173 /* *************************** Main Block
*************************** */
174 ON WRITE OF NewAcctTrans
OVERRIDE DO: END.
175 ON WRITE OF NewDocument
OVERRIDE DO: END.
177 RUN make-control-string
( "PCL", "reset,landscape,tm,1,a4,lm,4,courier,cpi,18,lpi,9",
178 OUTPUT line
, OUTPUT rows
, OUTPUT cols
).
180 RUN output-control-file
( line
).
181 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE VALUE(rows
).
182 IF preview
THEN VIEW FRAME heading-frame.
187 &SCOPED-DEFINE F-E-DEFINITION ~
188 FOR EACH Property
NO-LOCK ~
189 WHERE Property.Active
AND (NOT Property.ExternallyManaged
),~
191 WHERE Tenant.Active
AND Tenant.EntityType
= "P"~
192 AND Tenant.EntityCode
= Property.PropertyCode~
193 AND CAN-FIND( FIRST TenancyLease~
194 WHERE TenancyLease.TenantCode
= Tenant.TenantCode~
195 AND TenancyLease.LeaseStatus
<> "PAST"~
196 AND CAN-FIND( FIRST RentalSpace
OF TenancyLease
WHERE RentalSpace.AreaStatus
<> "V") )~
197 /* SCOPED-DEFINE ends
*/
199 IF set-sequence
= "PropertyCode":U
THEN DO:
200 {&F-E-DEFINITION} BY Property.PropertyCode BY Tenant.TenantCode:
204 ELSE IF set-sequence
= "TenantCode":U
THEN DO:
205 {&F-E-DEFINITION} BY Tenant.TenantCode:
210 {&F-E-DEFINITION} BY Property.Region BY Property.ShortName:
217 RUN after-each-property
( last-property
, property-total
).
221 line
= "Total outgoings = " + STRING( og-total
, "->>>,>>>,>>9.99").
223 line
= "Total rentals = " + STRING( rent-total
, "->>>,>>>,>>9.99").
225 line
= "Total un-taxed = " + STRING( untaxed-total
, "->>>,>>>,>>9.99").
227 line
= "Total GST = " + STRING( tax-total
, "->>>,>>>,>>9.99").
231 line
= "Total for batch = " + STRING( debit-total
, "->>>,>>>,>>9.99").
234 RUN view-output-file
( preview
).
240 OS-DELETE VALUE( txtrep-control-file
).
241 OS-DELETE VALUE( txtrep-print-file
).
244 NewBatch.DocumentCount
= this-document
245 NewBatch.Total
= debit-total
249 /* _UIB-CODE-BLOCK-END
*/
253 /* ********************** Internal Procedures
*********************** */
255 &IF DEFINED(EXCLUDE-after-each-property) = 0 &THEN
257 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE after-each-property Procedure
258 PROCEDURE after-each-property
:
259 /*------------------------------------------------------------------------------
261 ------------------------------------------------------------------------------*/
262 DEF INPUT PARAMETER last-code
AS INT NO-UNDO.
263 DEF INPUT PARAMETER total-amt
AS DEC NO-UNDO.
265 IF last-code
> -1 THEN DO:
266 line
= "Total rental for P" + STRING(last-code
,"99999") + " = " + STRING( total-amt
, "->>>,>>>,>>9.99") + " " + STRING( (total-amt
* 12), "->>>,>>>,>>9.99") + " p.a.".
273 IF AVAILABLE(Property
) THEN DO:
274 line
= STRING( Property.PropertyCode
, "99999") + " "
277 line
= FILL( "=", LENGTH(line
)).
283 /* _UIB-CODE-BLOCK-END
*/
288 &IF DEFINED(EXCLUDE-calculate-outgoings) = 0 &THEN
290 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE calculate-outgoings Procedure
291 PROCEDURE calculate-outgoings
:
292 /*------------------------------------------------------------------------------
296 ------------------------------------------------------------------------------*/
297 DEF INPUT PARAMETER tenant-code
LIKE Tenant.TenantCode
NO-UNDO.
298 DEF OUTPUT PARAMETER TotalOutGoings
AS DEC NO-UNDO INITIAL 0.
300 DEF VAR part-of-month
AS DEC NO-UNDO.
301 DEF VAR og-amount
AS DEC NO-UNDO.
303 FOR EACH TenancyLease
WHERE TenancyLease.TenantCode
= tenant-code
304 AND TenancyLease.PropertyCode
= Property.PropertyCode
305 AND TenancyLease.LeaseStatus
<> "PAST"
306 AND (TenancyLease.LeaseStartDate
< Month.EndDate
OR
307 TenancyLease.LeaseStartDate
= ?
) NO-LOCK:
308 RUN calculate-part-of-month
( OUTPUT part-of-month
).
309 og-amount
= ROUND(((TenancyLease.OutgoingsBudget
* part-of-month
) / 12), 2).
310 TotalOutgoings
= TotalOutgoings
+ og-amount.
315 /* _UIB-CODE-BLOCK-END
*/
320 &IF DEFINED(EXCLUDE-calculate-part-of-month) = 0 &THEN
322 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE calculate-part-of-month Procedure
323 PROCEDURE calculate-part-of-month
:
324 /*------------------------------------------------------------------------------
325 Purpose
: Calculate the portion of the month for which rent is due.
326 ------------------------------------------------------------------------------*/
327 DEF OUTPUT PARAMETER part-of-month
AS DECIMAL NO-UNDO.
329 /* 27 days
= 2219.18 (where full month
= $
2500) */
331 DEF VAR start-day
AS DATE NO-UNDO.
332 DEF VAR stop-day
AS DATE NO-UNDO.
333 DEF VAR month-days
AS INT NO-UNDO.
334 month-days
= (Month.EndDate
- Month.StartDate
) + 1.
336 ASSIGN part-of-month
= 1
337 stop-day
= Month.EndDate
338 start-day
= Month.StartDate.
340 IF TenancyLease.RentEndDate
<> ?
THEN stop-day
= MINIMUM( stop-day
, TenancyLease.RentEndDate
).
342 IF TenancyLease.FirstLeaseStart
<> ?
THEN start-day
= MAXIMUM( start-day
, TenancyLease.FirstLeaseStart
).
343 ELSE IF TenancyLease.LeaseStartDate
<> ?
THEN start-day
= MAXIMUM( start-day
, TenancyLease.LeaseStartDate
).
344 IF TenancyLease.RentStartDate
<> ?
THEN start-day
= MAXIMUM( start-day
, TenancyLease.RentStartDate
).
346 IF start-day
= Month.StartDate
AND stop-day
= Month.EndDate
THEN RETURN.
348 part-of-month
= ((1 + stop-day
- start-day
) / 365 ) * 12.
349 IF part-of-month
>= 1 THEN
351 ELSE IF part-of-month
<= 0 THEN
354 /* IF we're set to not do it then just return with part
= 1 */
355 IF set-partial
= "No" AND part-of-month
<> 0 THEN ASSIGN
356 start-day
= Month.StartDate
357 stop-day
= Month.EndDate
360 IF part-of-month
> 0 AND part-of-month
< 1 THEN DO:
361 partial-period
= Yes.
362 tenant-date-string
= " " + STRING( start-day
, "99/99/9999") + " to " + STRING( stop-day
, "99/99/9999").
367 /* _UIB-CODE-BLOCK-END
*/
372 &IF DEFINED(EXCLUDE-calculate-rental) = 0 &THEN
374 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE calculate-rental Procedure
375 PROCEDURE calculate-rental
:
376 /*------------------------------------------------------------------------------
378 ------------------------------------------------------------------------------*/
379 DEF INPUT PARAMETER tenant-code
LIKE Tenant.TenantCode
NO-UNDO.
380 DEF OUTPUT PARAMETER rent-amount
LIKE AcctTran.Amount
NO-UNDO.
381 DEF OUTPUT PARAMETER contract-rent
LIKE AcctTran.Amount
NO-UNDO.
382 DEF OUTPUT PARAMETER taxable-amount
AS DECIMAL NO-UNDO INITIAL 0.
384 DEF VAR part-of-month
AS DEC NO-UNDO.
385 DEF VAR month-charge
AS DEC NO-UNDO.
386 DEF VAR month-contract
AS DEC NO-UNDO.
390 FOR EACH TenancyLease
WHERE TenancyLease.TenantCode
= tenant-code
391 AND TenancyLease.PropertyCode
= Property.PropertyCode
392 AND TenancyLease.LeaseStatus
<> "PAST"
393 AND (TenancyLease.LeaseStartDate
< Month.EndDate
OR
394 TenancyLease.LeaseStartDate
= ?
) NO-LOCK,
395 EACH RentalSpace
WHERE RentalSpace.TenancyLeaseCode
= TenancyLease.TenancyLeaseCode
396 AND RentalSpace.AreaStatus
<> "V" NO-LOCK:
398 RUN calculate-part-of-month
( OUTPUT part-of-month
).
401 rent-amount
= rent-amount
+ (RentalSpace.ChargedRental
* part-of-month
)
402 contract-rent
= contract-rent
+ (RentalSpace.ContractedRental
* part-of-month
)
403 taxable-amount
= taxable-amount
+ (IF TenancyLease.TaxApplies
THEN (RentalSpace.ChargedRental
* part-of-month
) ELSE 0)
406 rent-amount
= INTEGER((rent-amount
/ 12) * 100) / 100.
407 contract-rent
= INTEGER((contract-rent
/ 12) * 100) / 100.
408 taxable-amount
= INTEGER((taxable-amount
/ 12) * 100) / 100.
412 /* _UIB-CODE-BLOCK-END
*/
417 &IF DEFINED(EXCLUDE-calculate-typed-rental) = 0 &THEN
419 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE calculate-typed-rental Procedure
420 PROCEDURE calculate-typed-rental
:
421 /*------------------------------------------------------------------------------
422 Purpose
: Calculate rentals broken down by area type
423 ------------------------------------------------------------------------------*/
424 DEF INPUT PARAMETER tenant-code
LIKE Tenant.TenantCode
NO-UNDO.
425 DEF OUTPUT PARAMETER rental-types
AS CHAR NO-UNDO.
426 DEF OUTPUT PARAMETER rental-amounts
AS CHAR NO-UNDO.
427 DEF OUTPUT PARAMETER rental-descriptions
AS CHAR NO-UNDO.
428 DEF OUTPUT PARAMETER taxable-amount
AS DECIMAL NO-UNDO INITIAL 0.
430 DEF VAR area-type
AS CHAR NO-UNDO.
431 DEF VAR type-pos
AS INT NO-UNDO.
432 DEF VAR rent-amount
AS DECIMAL NO-UNDO.
433 DEF VAR part-of-month
AS DEC NO-UNDO.
435 FOR EACH TenancyLease
WHERE TenancyLease.TenantCode
= tenant-code
436 AND TenancyLease.LeaseStatus
<> "PAST"
437 AND TenancyLease.PropertyCode
= Property.PropertyCode
438 AND (TenancyLease.LeaseStartDate
< Month.EndDate
OR
439 TenancyLease.LeaseStartDate
= ?
) NO-LOCK,
440 EACH RentalSpace
WHERE RentalSpace.TenancyLeaseCode
= TenancyLease.TenancyLeaseCode
441 AND RentalSpace.AreaStatus
<> "V" NO-LOCK:
442 area-type
= (IF RentalSpace.ChargedRental
< 0 THEN "-" ELSE "+")
443 + RentalSpace.Areatype.
444 type-pos
= INDEX( rental-types
, area-type
) / 2.
445 IF type-pos
= 0 OR RentalSpace.AreaType
= "S" THEN DO:
446 rental-types
= rental-types
+ area-type.
447 type-pos
= LENGTH( rental-types
) / 2.
448 rental-amounts
= rental-amounts
+ (IF rental-amounts
= "" THEN "" ELSE ",") + "0".
449 rental-descriptions
= rental-descriptions
+ (IF rental-descriptions
= "" THEN "" ELSE ",") + RentalSpace.Description.
451 RUN calculate-part-of-month
( OUTPUT part-of-month
).
452 rent-amount
= DECIMAL( ENTRY( type-pos
, rental-amounts
)).
453 IF TenancyLease.TaxApplies
THEN
454 taxable-amount
= taxable-amount
+ ROUND( (RentalSpace.ChargedRental
* part-of-month
) / 12, 2).
455 rent-amount
= rent-amount
+ ROUND( (RentalSpace.ChargedRental
* part-of-month
) / 12, 2).
456 ENTRY( type-pos
, rental-amounts
) = STRING( rent-amount
, "-999999999.99").
458 line
= FILL(" ", 6) + RentalSpace.AreaType
+ " "
459 + STRING( RentalSpace.Description
, "X(40)") + " "
460 + STRING( ROUND( ((RentalSpace.ChargedRental
* part-of-month
) / 12), 2), "->>,>>>,>>9.99").
466 /* _UIB-CODE-BLOCK-END
*/
471 &IF DEFINED(EXCLUDE-charge-outgoings) = 0 &THEN
473 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE charge-outgoings Procedure
474 PROCEDURE charge-outgoings
:
475 /*------------------------------------------------------------------------------
476 Purpose
: Create a transaction charging outgoings
477 ------------------------------------------------------------------------------*/
478 DEF VAR og-amount
AS DECIMAL NO-UNDO.
479 DEF VAR part-of-month
AS DEC NO-UNDO.
481 RUN calculate-outgoings
( Tenant.TenantCode
, OUTPUT og-amount
).
483 IF og-amount
<> 0 THEN DO:
484 property-total
= property-total
+ og-amount.
485 og-total
= og-total
+ og-amount.
487 og-description
= "Outgoings from" + tenant-date-string.
488 RUN create-transaction
( "T", Tenant.TenantCode
, sundry-debtors
,
490 "T" + STRING( Tenant.TenantCode
, "99999"),
495 RUN create-transaction
( Tenant.EntityType
, Tenant.EntityCode
, og-account
,
497 "T" + STRING( Tenant.TenantCode
, "99999"),
503 RUN charge-tax
( "T", Tenant.TenantCode
, sundry-debtors
,
505 "T" + STRING( Tenant.TenantCode
, "99999"),
513 /* _UIB-CODE-BLOCK-END
*/
518 &IF DEFINED(EXCLUDE-charge-rental-accounts) = 0 &THEN
520 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE charge-rental-accounts Procedure
521 PROCEDURE charge-rental-accounts
:
522 /*------------------------------------------------------------------------------
526 ------------------------------------------------------------------------------*/
527 DEF VAR rental-types
AS CHAR NO-UNDO.
528 DEF VAR rental-amounts
AS CHAR NO-UNDO.
529 DEF VAR area-descriptions
AS CHAR NO-UNDO.
531 DEF VAR no-types
AS INT NO-UNDO.
532 DEF VAR i
AS INT NO-UNDO.
533 DEF VAR this-type
AS CHAR NO-UNDO.
534 DEF VAR this-rent
AS DEC NO-UNDO.
535 DEF VAR tenant-rent-total
AS DEC INITIAL 0.00 NO-UNDO.
536 DEF VAR taxable
AS DECIMAL NO-UNDO.
537 DEF VAR descr
AS CHAR NO-UNDO.
539 RUN calculate-typed-rental
( Tenant.TenantCode
, OUTPUT rental-types
, OUTPUT rental-amounts
, OUTPUT area-descriptions
, OUTPUT taxable
).
544 rent-description
= "Rental from" + tenant-date-string.
545 no-types
= LENGTH( rental-types
) / 2.
546 DO i
= 1 TO no-types
:
547 this-type
= SUBSTRING( rental-types
, (2 * i
), 1).
548 this-rent
= DECIMAL( ENTRY( i
, rental-amounts
) ).
549 FIND AreaType
WHERE AreaType.AreaType
= this-type
NO-LOCK.
550 IF this-type
= "S" THEN
551 descr
= ENTRY( i
, area-descriptions
) + tenant-date-string .
553 descr
= AreaType.Description
+ (IF this-rent
< 0 THEN " credit" ELSE "") + tenant-date-string .
555 RUN create-transaction
( "T", Tenant.TenantCode
, sundry-debtors
,
557 "T" + STRING( Tenant.TenantCode
, "99999"),
563 RUN create-transaction
( Tenant.EntityType
, Tenant.EntityCode
, AreaType.AccountCode
,
565 "T" + STRING( Tenant.TenantCode
, "99999"),
570 tenant-rent-total
= tenant-rent-total
+ this-rent.
572 property-total
= property-total
+ tenant-rent-total.
573 rent-total
= rent-total
+ tenant-rent-total.
576 RUN charge-tax
( "T", Tenant.TenantCode
, sundry-debtors
, Month.StartDate
,
577 "T" + STRING( Tenant.TenantCode
, "99999"), taxable
, rent-description
).
579 IF Office.GST
<> ?
THEN
580 untaxed-total
= untaxed-total
+ this-rent
- taxable.
584 /* _UIB-CODE-BLOCK-END
*/
589 &IF DEFINED(EXCLUDE-charge-rental-single) = 0 &THEN
591 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE charge-rental-single Procedure
592 PROCEDURE charge-rental-single
:
593 /*------------------------------------------------------------------------------
594 Purpose
: Create a transaction charging rental.
595 ------------------------------------------------------------------------------*/
596 DEF VAR rent-amount
AS DECIMAL NO-UNDO.
597 DEF VAR contract-rent
AS DECIMAL NO-UNDO.
598 DEF VAR taxable
AS DECIMAL NO-UNDO.
600 RUN calculate-rental
( Tenant.TenantCode
, OUTPUT rent-amount
, OUTPUT contract-rent
, OUTPUT taxable
).
601 IF rent-amount
<> 0 THEN DO:
602 property-total
= property-total
+ rent-amount.
603 rent-total
= rent-total
+ rent-amount.
605 rent-description
= "Rental from" + tenant-date-string.
606 RUN create-transaction
( "T", Tenant.TenantCode
, sundry-debtors
,
608 "T" + STRING( Tenant.TenantCode
, "99999"),
614 RUN create-transaction
( Tenant.EntityType
, Tenant.EntityCode
, rent-account
,
616 "T" + STRING( Tenant.TenantCode
, "99999"),
623 RUN charge-tax
( "T", Tenant.TenantCode
, sundry-debtors
, Month.StartDate
,
624 "T" + STRING( Tenant.TenantCode
, "99999"), taxable
, rent-description
).
626 IF Office.GST
<> ?
THEN
627 untaxed-total
= untaxed-total
+ rent-amount
- taxable.
632 /* _UIB-CODE-BLOCK-END
*/
637 &IF DEFINED(EXCLUDE-charge-tax) = 0 &THEN
639 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE charge-tax Procedure
640 PROCEDURE charge-tax
:
641 /*------------------------------------------------------------------------------
642 Purpose
: Create a transaction charging tax
643 ------------------------------------------------------------------------------*/
644 DEF INPUT PARAMETER et
LIKE NewAcctTrans.EntityType
NO-UNDO.
645 DEF INPUT PARAMETER ec
LIKE NewAcctTrans.EntityCode
NO-UNDO.
646 DEF INPUT PARAMETER ac
LIKE NewAcctTrans.AccountCode
NO-UNDO.
647 DEF INPUT PARAMETER dat
LIKE NewAcctTrans.Date
NO-UNDO.
648 DEF INPUT PARAMETER ref
LIKE NewAcctTrans.Reference
NO-UNDO.
649 DEF INPUT PARAMETER amt
LIKE NewAcctTrans.Amount
NO-UNDO.
650 DEF INPUT PARAMETER dsc
LIKE NewAcctTrans.Description
NO-UNDO.
652 DEF VAR v-gst-entity
LIKE NewAcctTrans.EntityCode
NO-UNDO.
654 IF Office.GST
= 0 OR amt
= 0 THEN RETURN.
655 amt
= amt
* Office.GST
/ 100.
656 tax-total
= tax-total
+ amt.
657 RUN create-transaction
( et
, ec
, ac
,
658 dat
, ref
, amt
, "GST, " + dsc
, amt
).
660 /* Find the ledger to allocate GST
*/
661 IF GST-Multi-company
= YES THEN DO:
662 /*FIND Property
WHERE Property.PropertyCode
= ec
NO-LOCK.
*/
663 ASSIGN v-gst-entity
= Property.CompanyCode.
665 ELSE v-gst-entity
= gst-entity.
667 RUN create-transaction
( "L", v-gst-entity
, gst-account
,
668 dat
, ref
, - amt
, "GST, " + dsc
, - amt
).
673 /* _UIB-CODE-BLOCK-END
*/
678 &IF DEFINED(EXCLUDE-create-transaction) = 0 &THEN
680 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-transaction Procedure
681 PROCEDURE create-transaction
:
682 /*------------------------------------------------------------------------------
683 Purpose
: Create a NewTransaction record
684 ------------------------------------------------------------------------------*/
685 DEF INPUT PARAMETER et
LIKE NewAcctTrans.EntityType
NO-UNDO.
686 DEF INPUT PARAMETER ec
LIKE NewAcctTrans.EntityCode
NO-UNDO.
687 DEF INPUT PARAMETER ac
LIKE NewAcctTrans.AccountCode
NO-UNDO.
688 DEF INPUT PARAMETER dat
LIKE NewAcctTrans.Date
NO-UNDO.
689 DEF INPUT PARAMETER ref
LIKE NewAcctTrans.Reference
NO-UNDO.
690 DEF INPUT PARAMETER amt
LIKE NewAcctTrans.Amount
NO-UNDO.
691 DEF INPUT PARAMETER dsc
LIKE NewAcctTrans.Description
NO-UNDO.
692 DEF INPUT PARAMETER tax-amount
LIKE NewAcctTrans.Amount
NO-UNDO.
694 IF amt
> 0 THEN debit-total
= debit-total
+ amt.
697 (et
= "L" AND ec
= gst-entity
AND ac
= gst-account
AND set-type
= "ACCOUNTS":U
)
700 + STRING( Tenant.TenantCode
, "99999") + " "
701 + STRING( ac
, "9999.99") + " "
702 + STRING( dsc
, "X(50)" ) + " "
703 + STRING( - amt
, "->>>,>>>,>>9.99" ) + " "
704 + STRING( Tenant.Name
, "X(50)")
705 + (IF partial-period
THEN " part period" ELSE FILL(" ", 12) ) + " "
706 + (IF Office.GST
<> ?
AND tax-amount
<> amt
THEN STRING( - (tax-amount
* Office.GST
/ 100), "->>>,>>>,>>9.99" ) ELSE "").
708 tenant-total
= tenant-total
- amt.
712 IF this-transaction
= 0 THEN DO:
713 this-document
= this-document
+ 1.
716 NewDocument.BatchCode
= batch-code
717 NewDocument.DocumentCode
= this-document
718 NewDocument.DocumentType
= "RENT"
719 NewDocument.Reference
= ( et
+ STRING( ec
, "99999") )
720 NewDocument.Description
= NewBatch.Description
725 this-transaction
= this-transaction
+ 1.
728 NewAcctTrans.BatchCode
= batch-code
729 NewAcctTrans.DocumentCode
= this-document
730 NewAcctTrans.TransactionCode
= this-transaction
731 NewAcctTrans.EntityType
= et
732 NewAcctTrans.EntityCode
= ec
733 NewAcctTrans.AccountCode
= ac
734 NewAcctTrans.Date
= dat
735 NewAcctTrans.Reference
= ref
736 NewAcctTrans.Amount
= amt
737 NewAcctTrans.Description
= dsc
740 RELEASE NewAcctTrans.
743 /* _UIB-CODE-BLOCK-END
*/
748 &IF DEFINED(EXCLUDE-each-tenant) = 0 &THEN
750 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
751 PROCEDURE each-tenant
:
752 /*------------------------------------------------------------------------------
756 ------------------------------------------------------------------------------*/
757 this-transaction
= 0.
761 IF Property.PropertyCode
<> last-property
THEN DO:
762 RUN after-each-property
( last-property
, property-total
).
763 last-property
= Property.PropertyCode.
766 IF set-type
= "ACCOUNTS":U
THEN DO:
767 line
= Tenant.Name
+ " (T" + STRING( Tenant.TenantCode
, "99999") + ")".
773 tenant-date-string
= date-string.
774 IF INDEX( charge-type
, "R") > 0 THEN RUN VALUE(rent-charge-routine
) IN THIS-PROCEDURE.
775 IF INDEX( charge-type
, "O") > 0 THEN RUN charge-outgoings.
777 IF preview
AND set-type
= "ACCOUNTS":U
THEN DO:
778 line
= FILL( " ", 74) + "===============".
780 line
= "Total charge for tenant " + STRING( Tenant.TenantCode
, "99999")
781 + FILL( " ", 45) + STRING( tenant-total
, "->>>,>>>,>>9.99").
790 /* _UIB-CODE-BLOCK-END
*/
795 &IF DEFINED(EXCLUDE-output-line) = 0 &THEN
797 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-line Procedure
798 PROCEDURE output-line
:
799 /*------------------------------------------------------------------------------
801 ------------------------------------------------------------------------------*/
805 PUT UNFORMATTED line
SKIP.
809 /* _UIB-CODE-BLOCK-END
*/
814 &IF DEFINED(EXCLUDE-parse-options) = 0 &THEN
816 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-options Procedure
817 PROCEDURE parse-options
:
818 /*------------------------------------------------------------------------------
820 ------------------------------------------------------------------------------*/
822 DEF VAR charge-type
AS CHAR NO-UNDO.
823 DEF VAR charge-period
LIKE Month.MonthCode
NO-UNDO.
824 DEF VAR preview
AS LOGICAL NO-UNDO.
825 DEF VAR frequency-list
AS CHAR NO-UNDO.
828 {inc
/showopts.i
"process-options"}
830 charge-type
= ENTRY( 1, process-options
, "~n").
831 charge-period
= INT( ENTRY( 2, process-options
, "~n")).
832 preview
= (ENTRY( 3, process-options
, "~n") = "Yes").
833 frequency-list
= ENTRY( 4, process-options
, "~n").
837 /* _UIB-CODE-BLOCK-END
*/