1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
6 Purpose
: Transactions by Ledger Account report
7 Author
(s
) : Andrew McMillan
8 ------------------------------------------------------------------------*/
10 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
12 DEF VAR company-1
LIKE AcctTran.EntityCode
NO-UNDO.
13 DEF VAR company-2
LIKE AcctTran.EntityCode
NO-UNDO.
14 DEF VAR month-1
AS INTEGER FORMAT "9999" NO-UNDO.
15 DEF VAR month-2
AS INTEGER FORMAT "9999" NO-UNDO.
16 DEF VAR show-all
AS LOGICAL NO-UNDO.
17 DEF VAR account-1
LIKE AcctTran.AccountCode
NO-UNDO.
18 DEF VAR account-2
LIKE AcctTran.AccountCode
NO-UNDO.
19 DEF VAR preview
AS LOGICAL NO-UNDO.
20 DEF VAR earliest-date
AS DATE NO-UNDO.
21 DEF VAR earliest-batch
AS INT NO-UNDO.
22 DEF VAR export-fname
AS CHAR NO-UNDO.
23 DEF VAR group-name
AS CHAR NO-UNDO.
24 DEF VAR list-name
AS CHAR NO-UNDO INITIAL ?.
25 DEF VAR show-relations
AS LOGI
NO-UNDO INITIAL Yes.
26 DEF VAR base-pattern
AS CHAR NO-UNDO INITIAL ?.
27 DEF VAR account-pattern
AS CHAR NO-UNDO INITIAL ?.
29 DEF VAR show-month-totals
AS LOGICAL INITIAL no
NO-UNDO.
30 DEF VAR show-opening-balances
AS LOGICAL INITIAL Yes
NO-UNDO.
31 DEF VAR no-show-zero
AS LOGICAL INITIAL no
NO-UNDO.
32 DEF VAR base-entity-type
AS CHAR INITIAL "L" NO-UNDO.
/* The basic entity we deal with
*/
33 DEF VAR sort-entity-type
AS CHAR NO-UNDO.
/* The sequence for output
*/
35 DEF VAR exclude-year-end
AS LOGI
NO-UNDO.
36 DEF VAR balances-only
AS LOGI
NO-UNDO.
39 {inc
/ofc-set-l.i
"Transactions-Show-ChequeNo" "show-cheque-no"}
41 DEF VAR consol-accounts
AS CHAR INITIAL "" NO-UNDO.
42 IF list-name
<> ?
THEN DO:
43 FIND ConsolidationList
NO-LOCK WHERE ConsolidationList.Name
= list-name
NO-ERROR.
47 DEF VAR prt-ctrl
AS CHAR NO-UNDO.
48 DEF VAR rows
AS INT NO-UNDO.
49 DEF VAR cols
AS INT NO-UNDO.
51 DEF VAR grand-total
LIKE AcctTran.Amount
INITIAL 0 NO-UNDO.
53 DEF VAR user-name
AS CHAR NO-UNDO.
54 DEF VAR timeStamp
AS CHAR FORMAT "X(54)" NO-UNDO.
55 DEF VAR dispReference
AS CHARACTER COLUMN-LABEL "Reference" FORMAT "x(13)" NO-UNDO.
56 DEF VAR dispDescription
AS CHARACTER NO-UNDO.
57 DEF VAR dispName
AS CHARACTER FORMAT "X(80)" NO-UNDO.
59 DEF VAR money-length
AS INT NO-UNDO INIT 19.
60 DEF VAR dispAmount
AS CHARACTER FORMAT "X(19)" NO-UNDO.
62 DEF VAR last-month
AS INT NO-UNDO INITIAL ?.
63 DEF VAR tr-this-month
AS LOGICAL NO-UNDO.
64 DEF VAR tr-this-company
AS LOGICAL NO-UNDO.
65 DEF VAR tr-this-account
AS LOGICAL NO-UNDO.
66 DEF VAR company-total
LIKE AcctTran.Amount
NO-UNDO.
67 DEF VAR account-total
LIKE AcctTran.Amount
NO-UNDO.
69 DEF VAR m1-start
AS DATE NO-UNDO.
70 DEF VAR m2-end
AS DATE NO-UNDO.
72 FIND Month
WHERE Month.MonthCode
= month-1
NO-LOCK.
73 m1-start
= Month.StartDate.
75 FIND Month
WHERE Month.MonthCode
= month-2
NO-LOCK.
76 m2-end
= Month.EndDate.
78 &SCOPED-DEFINE page-width 126
79 DEF VAR hline2
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
80 DEF VAR hline3
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
81 hline2
= "Transactions for ".
82 IF AVAILABLE(ConsolidationList
) THEN
83 hline2
= hline2
+ "Consolidation List " + ConsolidationList.Name
+ " - " + ConsolidationList.Description.
84 ELSE IF company-1
= company-2
THEN DO:
85 FIND FIRST Company
WHERE Company.CompanyCode
= company-1
NO-LOCK NO-ERROR.
86 hline2
= hline2
+ (IF AVAILABLE(Company
) THEN Company.LegalName
ELSE "Company not on file")
87 + " (L" + TRIM( STRING( company-1
, ">>>>9")) + ")".
90 hline2
= hline2
+ "Company " + TRIM(STRING(company-1
,">>>>9")) + " to " + TRIM(STRING(company-2
,">>>>9")).
92 hline2
= hline2
+ ", from " + STRING( m1-start
, "99/99/9999") +
93 " to " + STRING( m2-end
, "99/99/9999")
94 + (IF earliest-date
> DATE(1,1,1) THEN (" and dated after " + STRING(earliest-date
,"99/99/9999")) ELSE "").
95 hline2
= SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
97 IF group-name
= "" THEN DO:
98 hline3
= "Accounts " + STRING(account-1
, "9999.99") + " to " + STRING(account-2
, "9999.99").
99 IF account-pattern
<> ?
THEN hline3
= hline3
+ " matching " + base-pattern .
102 FIND AccountGroup
WHERE AccountGroup.AccountGroupCode
= group-name
NO-LOCK.
103 hline3
= "Account group " + group-name
+ " - " + AccountGroup.Name.
105 IF NOT show-opening-balances
THEN hline3
= hline3
+ " (opening balances not shown)".
106 hline3
= SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline3) ) / 2)) + hline3.
108 /* define all the frames for the report
*/
109 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
111 DEFINE FRAME default-frame
WITH DOWN {&with-clause}.
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})"
117 hline3
FORMAT "X({&page-width})"
118 SKIP (2) " Date Reference Amount Description" SPACE(40) "Related records"
119 WITH FRAME heading-frame.
121 DEFINE FRAME total-frame-1
WITH DOWN {&with-clause}.
127 WITH FRAME total-frame-1.
129 DEFINE FRAME report-frame-1
WITH DOWN {&with-clause}.
133 WITH FRAME report-frame-1.
135 DEFINE FRAME report-frame-2
WITH DOWN {&with-clause}.
137 AcctTran.Date
COLUMN-LABEL "Date" FORMAT "99/99/9999"
139 /* dispAmount
COLUMN-LABEL "Amount" */
140 dispDescription
COLUMN-LABEL "Description" FORMAT "X(81)"
141 WITH FRAME report-frame-2.
144 {inc
/ofc-acct.i
"IC-BASE" "ic-base"}
146 /* _UIB-CODE-BLOCK-END
*/
150 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
152 /* ******************** Preprocessor Definitions
******************** */
154 &Scoped-define PROCEDURE-TYPE Procedure
155 &Scoped-define DB-AWARE no
159 /* _UIB-PREPROCESSOR-BLOCK-END
*/
163 /* ************************ Function Prototypes
********************** */
165 &IF DEFINED(EXCLUDE-balance-is-zero) = 0 &THEN
167 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD balance-is-zero Procedure
168 FUNCTION balance-is-zero
RETURNS LOGICAL
169 ( /* no parameter-definitions
*/ ) FORWARD.
171 /* _UIB-CODE-BLOCK-END
*/
176 &IF DEFINED(EXCLUDE-check-pattern-match) = 0 &THEN
178 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD check-pattern-match Procedure
179 FUNCTION check-pattern-match
RETURNS LOGICAL
180 ( INPUT ac
AS DEC ) FORWARD.
182 /* _UIB-CODE-BLOCK-END
*/
187 &IF DEFINED(EXCLUDE-format-big-money) = 0 &THEN
189 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD format-big-money Procedure
190 FUNCTION format-big-money
RETURNS CHARACTER
191 ( INPUT amt
AS DEC ) FORWARD.
193 /* _UIB-CODE-BLOCK-END
*/
198 &IF DEFINED(EXCLUDE-interco-outside-group) = 0 &THEN
200 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD interco-outside-group Procedure
201 FUNCTION interco-outside-group
RETURNS LOGICAL
202 ( INPUT ac
AS DEC ) FORWARD.
204 /* _UIB-CODE-BLOCK-END
*/
210 /* *********************** Procedure Settings
************************ */
212 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
213 /* Settings for
THIS-PROCEDURE
217 Add Fields to
: Neither
218 Other Settings
: CODE-ONLY
COMPILE
220 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
222 /* ************************* Create Window
************************** */
224 &ANALYZE-SUSPEND _CREATE-WINDOW
225 /* DESIGN Window definition
(used by the UIB
)
226 CREATE WINDOW Procedure
ASSIGN
229 /* END WINDOW DEFINITION
*/
233 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
234 /* ************************* Included-Libraries
*********************** */
236 {inc
/method
/m-txtrep.i
}
238 /* _UIB-CODE-BLOCK-END
*/
245 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
248 /* *************************** Main Block
*************************** */
249 {inc
/username.i
"user-name"}
250 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
251 IF export-fname
= "" THEN DO:
252 RUN make-control-string
( "PCL", "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9",
253 OUTPUT prt-ctrl
, OUTPUT rows
, OUTPUT cols
).
255 RUN output-control-file
( prt-ctrl
).
256 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE VALUE(rows
).
258 VIEW FRAME heading-frame.
261 OUTPUT TO VALUE(export-fname
) KEEP-MESSAGES .
262 PUT UNFORMATTED '
"Batch","Doc","Trn","Type","Entity","Account","Reference","Date","Amount","Narrative","Related records","Flag","Flagged By"'
SKIP .
265 IF sort-entity-type
<> base-entity-type
THEN DO:
266 IF group-name
<> "" THEN DO:
267 FOR EACH ChartOfAccount
OF AccountGroup
NO-LOCK BY ChartOfAccount.AccountCode
:
268 RUN each-account-by-account.
272 FOR EACH ChartOfAccount
NO-LOCK
273 WHERE ChartOfAccount.AccountCode
>= account-1
AND ChartOfAccount.AccountCode
<= account-2
274 BY ChartOfAccount.AccountCode
:
275 RUN each-account-by-account.
279 ELSE IF AVAILABLE(ConsolidationList
) THEN DO:
280 DEF VAR entry-no
AS INT NO-UNDO INITIAL 0.
281 consol-accounts
= STRING( ic-base
, "9999.99").
282 ic-base
= TRUNC( ic-base
/ 1000, 0 ) * 1000.
283 DO entry-no
= 1 TO NUM-ENTRIES( ConsolidationList.CompanyList
):
284 consol-accounts
= consol-accounts
+ "," + STRING( ic-base
+ DEC( ENTRY( entry-no
, ConsolidationList.CompanyList
)), "9999.99").
286 DO entry-no
= 1 TO NUM-ENTRIES( ConsolidationList.CompanyList
):
287 FIND Company
NO-LOCK WHERE Company.CompanyCode
= INT(ENTRY(entry-no
, ConsolidationList.CompanyList
)) NO-ERROR.
288 IF NOT AVAILABLE(Company
) THEN NEXT.
289 RUN each-company-by-company.
293 FOR EACH Company
NO-LOCK
294 WHERE Company.CompanyCode
>= company-1
AND Company.CompanyCode
<= company-2
295 BY Company.CompanyCode
:
296 RUN each-company-by-company.
301 IF export-fname
= "" THEN DO:
302 IF (company-1
= company-2
AND sort-entity-type
= base-entity-type
)
303 OR (account-1
= account-2
AND sort-entity-type
<> base-entity-type
)
307 dispName
= "Entire report".
308 RUN disp-totals
(grand-total
).
311 RUN view-output-file
( preview
).
316 /* _UIB-CODE-BLOCK-END
*/
320 /* ********************** Internal Procedures
*********************** */
322 &IF DEFINED(EXCLUDE-disp-entity-account) = 0 &THEN
324 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-entity-account Procedure
325 PROCEDURE disp-entity-account
:
326 /*------------------------------------------------------------------------------
327 Purpose
: Set the dispEntityName variable to the current account.
328 ------------------------------------------------------------------------------*/
329 dispName
= STRING(ChartOfAccount.AccountCode
, "9999.99") + ", " +
333 /* _UIB-CODE-BLOCK-END
*/
338 &IF DEFINED(EXCLUDE-disp-entity-company) = 0 &THEN
340 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-entity-company Procedure
341 PROCEDURE disp-entity-company
:
342 /*------------------------------------------------------------------------------
343 Purpose
: Set the dispEntityName variable to the current company.
344 ------------------------------------------------------------------------------*/
345 dispName
= Company.LegalName
+
346 " (" + STRING(Company.CompanyCode
, "999") + ")".
349 /* _UIB-CODE-BLOCK-END
*/
354 &IF DEFINED(EXCLUDE-disp-month-totals) = 0 &THEN
356 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-month-totals Procedure
357 PROCEDURE disp-month-totals
:
358 /*------------------------------------------------------------------------------
360 ------------------------------------------------------------------------------*/
361 DEF INPUT PARAMETER month-code
AS INT NO-UNDO.
362 DEF INPUT PARAMETER month-total
AS DEC NO-UNDO.
363 DEF INPUT PARAMETER next-month-code
AS INT NO-UNDO.
365 /* MESSAGE 1 show-month-totals tr-this-month month-code last-month month-total.
*/
366 IF NOT(show-month-totals
) THEN RETURN.
368 DEF BUFFER MyMonth
FOR Month.
370 IF month-code
<> ?
THEN DO:
371 IF tr-this-month
THEN DO:
372 FIND MyMonth
WHERE MyMonth.MonthCode
= month-code
NO-LOCK NO-ERROR.
373 dispName
= "closing balance at " + STRING( MyMonth.EndDate
, "99/99/9999").
374 RUN disp-totals
( account-total
).
380 last-month
= next-month-code.
384 /* _UIB-CODE-BLOCK-END
*/
389 &IF DEFINED(EXCLUDE-disp-totals) = 0 &THEN
391 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-totals Procedure
392 PROCEDURE disp-totals
:
393 /*------------------------------------------------------------------------------
395 ------------------------------------------------------------------------------*/
396 DEF INPUT PARAMETER disp-total
AS DECIMAL NO-UNDO.
398 IF export-fname
<> "" THEN RETURN.
400 MESSAGE FILL(" ",30) " -------------".
401 dispReference
= STRING( (IF dispName
BEGINS "closin" THEN "" ELSE "Total"), "X(13)").
402 MESSAGE " " FILL(" ", 10) dispReference format-big-money
(disp-total
) dispName.
406 /* _UIB-CODE-BLOCK-END
*/
411 &IF DEFINED(EXCLUDE-display-headings-if-needed) = 0 &THEN
413 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE display-headings-if-needed Procedure
414 PROCEDURE display-headings-if-needed
:
415 /*------------------------------------------------------------------------------
416 Purpose
: If this is the first transaction for an account or company
(or both
)
417 we need to display the appropriate headings.
418 ------------------------------------------------------------------------------*/
420 IF export-fname
<> "" THEN RETURN.
422 /* For the major sort sequence
*/
423 IF NOT tr-this-company
AND sort-entity-type
= "L" THEN DO:
424 IF company-1
<> company-2
THEN DO:
425 RUN disp-entity-company.
426 DISPLAY dispName
WITH FRAME report-frame-1.
427 DOWN WITH FRAME report-frame-1.
429 tr-this-company
= yes.
431 ELSE IF NOT tr-this-account
AND sort-entity-type
= "A" THEN DO:
432 RUN disp-entity-account.
433 DISPLAY dispName
WITH FRAME report-frame-1.
434 DOWN WITH FRAME report-frame-1.
435 tr-this-account
= yes.
438 /* For the minor sort sequence
*/
439 IF NOT tr-this-company
THEN DO:
440 RUN disp-entity-company.
441 DISPLAY dispName
WITH FRAME report-frame-1.
442 DOWN WITH FRAME report-frame-1.
443 tr-this-company
= yes.
445 ELSE IF NOT tr-this-account
THEN DO:
446 RUN disp-entity-account.
447 DISPLAY dispName
WITH FRAME report-frame-1.
448 DOWN WITH FRAME report-frame-1.
449 tr-this-account
= yes.
454 /* _UIB-CODE-BLOCK-END
*/
459 &IF DEFINED(EXCLUDE-each-account) = 0 &THEN
461 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-account Procedure
462 PROCEDURE each-account
:
463 /*------------------------------------------------------------------------------
464 Purpose
: Display transactions for a single account
465 ------------------------------------------------------------------------------*/
466 IF account-pattern
<> ?
AND NOT check-pattern-match
( ChartOfAccount.AccountCode
) THEN RETURN.
467 IF no-show-zero
AND balance-is-zero
() THEN RETURN.
468 IF show-opening-balances
THEN RUN show-opening-balance.
470 IF ( ChartOfAccount.HighVolume
AND (NOT show-all
) ) OR balances-only
THEN DO:
471 /* special treatment for high volume accounts
*/
472 RUN each-volume-account.
477 FOR EACH AccountBalance
NO-LOCK
478 WHERE AccountBalance.EntityType
= base-entity-type
479 AND AccountBalance.EntityCode
= Company.CompanyCode
480 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
481 AND AccountBalance.MonthCode
>= month-1
482 AND AccountBalance.MonthCode
<= month-2
,
483 FIRST Month
OF AccountBalance
NO-LOCK
486 RUN disp-month-totals
( last-month
, account-total
, AccountBalance.MonthCode
).
489 FOR EACH AcctTran
NO-LOCK OF AccountBalance
490 WHERE AcctTran.Date
>= earliest-date
,
491 FIRST Document
NO-LOCK OF AcctTran
WHERE
492 ( IF exclude-year-end
THEN Document.DocumentType
<> "YEND" ELSE True
)
493 BY AcctTran.EntityType
BY AcctTran.EntityCode
BY AcctTran.AccountCode
494 BY AcctTran.MonthCode
BY AcctTran.Date
495 BY AcctTran.BatchCode
BY AcctTran.DocumentCode
BY AcctTran.TransactionCode
497 RUN each-transaction.
501 FOR EACH AcctTran
NO-LOCK OF AccountBalance
WHERE AcctTran.Date
>= earliest-date
,
502 FIRST Document
NO-LOCK OF AcctTran
503 BY AcctTran.EntityType
BY AcctTran.EntityCode
BY AcctTran.AccountCode
504 BY AcctTran.MonthCode
BY AcctTran.Date
505 BY AcctTran.BatchCode
BY AcctTran.DocumentCode
BY AcctTran.TransactionCode
507 RUN each-transaction.
514 /* _UIB-CODE-BLOCK-END
*/
519 &IF DEFINED(EXCLUDE-each-account-by-account) = 0 &THEN
521 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-account-by-account Procedure
522 PROCEDURE each-account-by-account
:
523 /*------------------------------------------------------------------------------
524 Purpose
: Loop for all companies within an account
525 ------------------------------------------------------------------------------*/
531 IF AVAILABLE(ConsolidationList
) THEN DO:
532 DEF VAR entry-no
AS INT NO-UNDO INITIAL 0.
533 DO entry-no
= 1 TO NUM-ENTRIES( ConsolidationList.CompanyList
):
534 FIND Company
NO-LOCK WHERE Company.CompanyCode
= INT(ENTRY(entry-no
, ConsolidationList.CompanyList
)) NO-ERROR.
535 IF NOT AVAILABLE(Company
) THEN NEXT.
537 ASSIGN company-total
= 0
538 tr-this-company
= no .
542 IF tr-this-company
THEN DO:
543 RUN disp-entity-company.
544 RUN disp-totals
( company-total
).
549 FOR EACH Company
NO-LOCK WHERE Company.CompanyCode
>= company-1
550 AND Company.CompanyCode
<= company-2
551 AND CAN-FIND( FIRST AccountBalance
552 WHERE AccountBalance.EntityType
= base-entity-type
553 AND AccountBalance.EntityCode
= Company.CompanyCode
554 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
555 AND AccountBalance.MonthCode
<= month-2
) :
556 ASSIGN company-total
= 0
557 tr-this-company
= no .
561 IF tr-this-company
THEN DO:
562 RUN disp-entity-company.
563 RUN disp-totals
( company-total
).
568 IF tr-this-account
THEN DO:
569 RUN disp-entity-account.
570 RUN disp-totals
( account-total
).
571 grand-total
= grand-total
+ account-total.
576 /* _UIB-CODE-BLOCK-END
*/
581 &IF DEFINED(EXCLUDE-each-company-by-company) = 0 &THEN
583 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-company-by-company Procedure
584 PROCEDURE each-company-by-company
:
585 /*------------------------------------------------------------------------------
586 Purpose
: Loop for all accounts of company
587 ------------------------------------------------------------------------------*/
594 IF group-name
<> "" THEN DO:
595 FOR EACH ChartOfAccount
OF AccountGroup
NO-LOCK
596 WHERE CAN-FIND( FIRST AccountBalance
597 WHERE AccountBalance.EntityType
= base-entity-type
598 AND AccountBalance.EntityCode
= Company.CompanyCode
599 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
600 AND AccountBalance.MonthCode
<= month-2
) :
602 IF interco-outside-group
( ChartOfAccount.AccountCode
) THEN NEXT.
604 ASSIGN account-total
= 0
605 tr-this-account
= no .
609 IF tr-this-account
THEN DO:
610 RUN disp-entity-account.
611 RUN disp-totals
( account-total
).
616 FOR EACH ChartOfAccount
NO-LOCK
617 WHERE ChartOfAccount.AccountCode
>= account-1
618 AND ChartOfAccount.AccountCode
<= account-2
619 AND CAN-FIND( FIRST AccountBalance
620 WHERE AccountBalance.EntityType
= base-entity-type
621 AND AccountBalance.EntityCode
= Company.CompanyCode
622 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
623 AND AccountBalance.MonthCode
<= month-2
) :
631 IF tr-this-account
THEN DO:
632 RUN disp-entity-account.
633 RUN disp-totals
( account-total
).
638 IF tr-this-company
THEN DO:
639 RUN disp-entity-company.
640 RUN disp-totals
( company-total
).
641 grand-total
= grand-total
+ company-total.
646 /* _UIB-CODE-BLOCK-END
*/
651 &IF DEFINED(EXCLUDE-each-transaction) = 0 &THEN
653 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-transaction Procedure
654 PROCEDURE each-transaction
:
655 /*------------------------------------------------------------------------------
657 ------------------------------------------------------------------------------*/
658 IF AcctTran.BatchCode
< earliest-batch
THEN RETURN.
659 IF exclude-year-end
THEN DO:
660 FIND Document
OF AcctTran
NO-LOCK.
661 IF Document.DocumentType
= "YEND"
662 OR Document.Description
BEGINS "Y/E Transfer to Ret"
663 OR Document.Description
BEGINS "Y/E Accumulated P&L"
664 OR (AcctTran.EntityType
= "P" AND Document.Description
BEGINS "Y/E Clear Propacc Balance" )
668 RUN display-headings-if-needed.
670 dispReference
= STRING( (IF (AcctTran.Reference
= "") THEN (Document.Reference
) ELSE (AcctTran.Reference
) ), "X(12)" )
671 + ( IF (AcctTran.ClosingGroup
> 0) THEN "*" ELSE " " ).
672 dispDescription
= IF (AcctTran.Description
= "") THEN (Document.Description
) ELSE (AcctTran.Description
).
675 IF show-relations
THEN DO:
676 IF SUBSTRING(dispReference
, 1, 3) = "INV" THEN DO:
677 FIND Invoice
WHERE Invoice.InvoiceNo
= INT( SUBSTRING(dispReference
, 4)) NO-LOCK NO-ERROR.
678 IF AVAILABLE(Invoice
) THEN DO:
679 dispDescription
= STRING( dispDescription
, "X(51)").
680 IF Invoice.EntityType
= "T" THEN DO:
681 FIND Tenant
WHERE Tenant.TenantCode
= Invoice.EntityCode
NO-LOCK NO-ERROR.
683 dispDescription
= dispDescription
684 + Invoice.EntityType
+ STRING(Invoice.EntityCode
)
685 + (IF AVAILABLE(Tenant
) THEN " " + Tenant.Name
ELSE "").
688 dispDescription
= dispDescription
+ Invoice.EntityType
+ STRING(Invoice.EntityCode
).
691 ELSE IF SUBSTRING(dispReference
, 1, 4) = "VCHR" THEN DO:
692 FIND Voucher
WHERE Voucher.VoucherSeq
= INT( SUBSTRING(dispReference
, 5)) NO-LOCK NO-ERROR.
693 IF AVAILABLE(Voucher
) THEN DO:
694 FIND Creditor
OF Voucher
NO-LOCK NO-ERROR.
695 dispDescription
= STRING( dispDescription
, "X(51)")
696 + (IF show-cheque-no
THEN Voucher.BankAccountCode
+ STRING(Voucher.ChequeNo
,"999999" + ", ") ELSE "")
697 + "C" + STRING(Voucher.CreditorCode
)
698 + (IF AVAILABLE(Creditor
) THEN " " + Creditor.Name
ELSE "").
703 IF export-fname
<> "" THEN RUN export-transaction .
705 dispAmount
= format-big-money
( AcctTran.Amount
).
706 MESSAGE " " STRING(AcctTran.Date
, "99/99/9999") dispReference dispAmount dispDescription.
712 WITH FRAME report-frame-2.
714 DOWN WITH FRAME report-frame-2.
*/
718 account-total
= account-total
+ AcctTran.Amount
719 company-total
= company-total
+ AcctTran.Amount
724 /* _UIB-CODE-BLOCK-END
*/
729 &IF DEFINED(EXCLUDE-each-volume-account) = 0 &THEN
731 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-volume-account Procedure
732 PROCEDURE each-volume-account
:
733 /*------------------------------------------------------------------------------
734 Purpose
: Display balance only for a high-volume account
735 ------------------------------------------------------------------------------*/
736 DEF VAR transaction-total
AS DECIMAL NO-UNDO.
738 transaction-total
= 0.
739 FOR EACH AccountBalance
NO-LOCK
740 WHERE AccountBalance.EntityType
= base-entity-type
741 AND AccountBalance.EntityCode
= Company.CompanyCode
742 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
743 AND AccountBalance.MonthCode
>= month-1
744 AND AccountBalance.MonthCode
<= month-2
,
745 FIRST Month
OF AccountBalance
NO-LOCK
749 FOR EACH AcctTran
NO-LOCK OF AccountBalance
WHERE AcctTran.Date
>= earliest-date
750 AND AcctTran.BatchCode
>= earliest-batch
,
751 FIRST Document
NO-LOCK OF AcctTran
WHERE
752 ( IF exclude-year-end
THEN Document.DocumentType
<> "YEND" ELSE True
)
753 BY AcctTran.EntityType
BY AcctTran.EntityCode
BY AcctTran.AccountCode
754 BY AcctTran.MonthCode
BY AcctTran.Date
755 BY AcctTran.BatchCode
BY AcctTran.DocumentCode
BY AcctTran.TransactionCode
759 transaction-total
= transaction-total
+ AcctTran.Amount
765 account-total
= account-total
+ transaction-total
766 company-total
= company-total
+ transaction-total
769 RUN display-headings-if-needed.
771 IF export-fname
= "" THEN DO:
772 dispAmount
= format-big-money
( transaction-total
).
773 MESSAGE " " STRING( m2-end
, "99/99/9999") FILL(" ", 13) dispAmount
"Sum of transactions in period".
778 /* _UIB-CODE-BLOCK-END
*/
783 &IF DEFINED(EXCLUDE-export-transaction) = 0 &THEN
785 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE export-transaction Procedure
786 PROCEDURE export-transaction
:
787 /*------------------------------------------------------------------------------
791 ------------------------------------------------------------------------------*/
792 DEF VAR FlagBy
AS CHAR INITIAL "" NO-UNDO.
794 FIND Person
WHERE Person.PersonCode
= AcctTran.FlaggedBy
NO-LOCK NO-ERROR.
795 IF AVAILABLE(Person
) THEN
796 FlagBy
= Person.FirstName
+ " " + Person.LastName.
799 AcctTran.BatchCode '
,'
800 AcctTran.DocumentCode '
,'
801 AcctTran.TransactionCode '
,"'
802 AcctTran.EntityType '",'
803 AcctTran.EntityCode '
,'
804 AcctTran.AccountCode '
,"'
808 TRIM( SUBSTRING(dispDescription,1,50)) '","'
809 TRIM( SUBSTRING(dispDescription,51)) '","'
810 AcctTran.FlagAttention '","'
815 /* _UIB-CODE-BLOCK-END
*/
820 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
822 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
823 PROCEDURE parse-parameters
:
824 /*------------------------------------------------------------------------------
826 ------------------------------------------------------------------------------*/
827 DEF VAR some-options
AS CHAR NO-UNDO.
828 DEF VAR complex-options
AS CHAR NO-UNDO.
829 DEF VAR pos
AS INT NO-UNDO.
832 {inc
/showopts.i
"report-options"}
833 pos
= INDEX( report-options
, "~n").
834 IF pos
= ?
THEN pos
= 0.
835 complex-options
= SUBSTRING( report-options
, pos
+ 1).
836 report-options
= ENTRY( 1, report-options
, "~n").
838 some-options
= ENTRY( 1, report-options
).
839 company-1
= INTEGER( ENTRY( 2, report-options
)).
840 company-2
= INTEGER( ENTRY( 3, report-options
)).
841 month-1
= INTEGER( ENTRY( 4, report-options
)).
842 month-2
= INTEGER( ENTRY( 5, report-options
)).
843 show-all
= (ENTRY( 6, report-options
) = "Yes").
844 account-1
= DECIMAL( ENTRY( 7, report-options
)).
845 account-2
= DECIMAL( ENTRY( 8, report-options
)).
846 preview
= (ENTRY( 9, report-options
) = "Yes").
847 earliest-date
= DATE(ENTRY(10, report-options
)).
848 earliest-batch
= INTEGER( ENTRY(11, report-options
)).
849 export-fname
= ENTRY(12, report-options
).
850 group-name
= ENTRY(13, report-options
).
852 /* Now detail to the complex options string
*/
853 DEF VAR i
AS INT NO-UNDO.
854 DEF VAR token
AS CHAR NO-UNDO.
857 DO i
= 1 TO NUM-ENTRIES( complex-options
, "~n" ):
858 token
= ENTRY( i
, complex-options
, "~n" ).
859 CASE( ENTRY( 1, token
) ):
860 WHEN "ConsolidationList" THEN DO:
861 pos
= LENGTH( ENTRY(1,token
) ).
862 IF pos
= ?
THEN pos
= 0.
863 list-name
= TRIM( SUBSTRING( token
, pos
+ 2 )).
865 WHEN "NoRelations" THEN show-relations
= No.
866 WHEN "MonthTotals" THEN show-month-totals
= Yes.
867 WHEN "SortBy" THEN sort-entity-type
= ENTRY( 2, token
).
868 WHEN "NonZeroOnly" THEN no-show-zero
= Yes.
869 WHEN "BalancesOnly" THEN balances-only
= Yes.
870 WHEN "NoOpeningBalances" THEN show-opening-balances
= No.
871 WHEN "ExcludeYearEnd" THEN exclude-year-end
= Yes.
872 WHEN "AccountsLike" THEN ASSIGN
873 base-pattern
= STRING( ENTRY(2,token
), "XXXX.XX")
874 account-pattern
= REPLACE( base-pattern
, "*", ".").
880 /* _UIB-CODE-BLOCK-END
*/
885 &IF DEFINED(EXCLUDE-show-opening-balance) = 0 &THEN
887 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE show-opening-balance Procedure
888 PROCEDURE show-opening-balance
:
889 /*------------------------------------------------------------------------------
890 Purpose
: Calculate and display the opening balance
891 ------------------------------------------------------------------------------*/
892 DEF VAR opening-balance
LIKE AcctTran.Amount
NO-UNDO.
895 FOR EACH AccountBalance
NO-LOCK
896 WHERE AccountBalance.EntityType
= base-entity-type
897 AND AccountBalance.EntityCode
= Company.CompanyCode
898 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
899 AND AccountBalance.MonthCode
< month-1
:
900 opening-balance
= opening-balance
+ AccountBalance.Balance.
903 IF earliest-date
> DATE(1,1,1) THEN DO:
904 FOR EACH AcctTran
NO-LOCK
905 WHERE AcctTran.EntityType
= base-entity-type
906 AND AcctTran.EntityCode
= Company.CompanyCode
907 AND AcctTran.AccountCode
= ChartOfAccount.AccountCode
908 AND AcctTran.MonthCode
= month-1
909 AND AcctTran.Date
< earliest-date
:
910 opening-balance
= opening-balance
+ AcctTran.Amount.
914 IF opening-balance
<> 0 THEN DO:
915 RUN display-headings-if-needed.
916 FIND LAST Month
WHERE Month.MonthCode
< month-1
NO-LOCK.
918 dispReference
= "O/Bal "
919 dispDescription
= "Opening Balance"
923 IF export-fname
= "" THEN DO:
924 MESSAGE " " STRING(Month.EndDate
+ 1, "99/99/9999") dispReference format-big-money
(opening-balance
) dispDescription.
925 IF show-month-totals
THEN PUT SKIP(1).
928 PUT UNFORMATTED '
,,,"'
929 base-entity-type '",' Company.CompanyCode '
,' ChartOfAccount.AccountCode '
,"'
930 TRIM(dispReference) '","'
938 account-total
= account-total
+ opening-balance
939 company-total
= company-total
+ opening-balance
945 /* _UIB-CODE-BLOCK-END
*/
950 /* ************************ Function Implementations
***************** */
952 &IF DEFINED(EXCLUDE-balance-is-zero) = 0 &THEN
954 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION balance-is-zero Procedure
955 FUNCTION balance-is-zero
RETURNS LOGICAL
956 ( /* no parameter-definitions
*/ ) :
957 /*------------------------------------------------------------------------------
958 Purpose
: Check the balance of the account over the period. If it is
0, then
959 return the string
"ZERO".
960 ------------------------------------------------------------------------------*/
961 DEF VAR bal-total
AS DEC INITIAL 0 NO-UNDO.
963 FIND AccountSummary
WHERE AccountSummary.EntityType
= base-entity-type
964 AND AccountSummary.EntityCode
= Company.CompanyCode
965 AND AccountSummary.AccountCode
= ChartOfAccount.AccountCode
967 IF AVAILABLE(AccountSummary
) THEN bal-total
= AccountSummary.Balance.
969 /* Subtract back to get balance at end of period
*/
970 FOR EACH AccountBalance
NO-LOCK
971 WHERE AccountBalance.EntityType
= base-entity-type
972 AND AccountBalance.EntityCode
= Company.CompanyCode
973 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
974 AND AccountBalance.MonthCode
> month-2
:
975 bal-total
= bal-total
- AccountBalance.Balance.
978 RETURN (bal-total
= 0).
982 /* _UIB-CODE-BLOCK-END
*/
987 &IF DEFINED(EXCLUDE-check-pattern-match) = 0 &THEN
989 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION check-pattern-match Procedure
990 FUNCTION check-pattern-match
RETURNS LOGICAL
991 ( INPUT ac
AS DEC ) :
992 /*------------------------------------------------------------------------------
993 Purpose
: Check that this account matches an
OK pattern
995 ------------------------------------------------------------------------------*/
996 DEF VAR ac-text
AS CHAR NO-UNDO.
998 ac-text
= STRING( ac
, "9999.99").
999 RETURN ac-text
MATCHES account-pattern.
1003 /* _UIB-CODE-BLOCK-END
*/
1008 &IF DEFINED(EXCLUDE-format-big-money) = 0 &THEN
1010 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION format-big-money Procedure
1011 FUNCTION format-big-money
RETURNS CHARACTER
1012 ( INPUT amt
AS DEC ) :
1013 /*------------------------------------------------------------------------------
1014 Purpose
: Work around problems experienced formatting billions
1015 ------------------------------------------------------------------------------*/
1016 DEF VAR formatted
AS CHAR NO-UNDO.
1017 formatted
= STRING( amt
, ">>,>>>,>>>,>>9.99CR").
1018 /* MESSAGE "Fmt1" formatted.
1019 formatted
= STRING( amt
, ">>>>>>>>>>>9.99CR").
1020 /* MESSAGE "Fmt1" formatted.
*/
1021 formatted
= SUBSTRING( formatted
, 1, 3) + ","
1022 + SUBSTRING( formatted
, 4, 3) + ","
1023 + SUBSTRING( formatted
, 7, 3) + ","
1024 + SUBSTRING( formatted
, 10).
1025 /* MESSAGE "Fmt2" formatted.
*/
1026 formatted
= LEFT-TRIM(formatted
, ", ").
1027 formatted
= FILL(" ", money-length
- LENGTH(formatted
)) + formatted.
1028 /* MESSAGE "Fmt3" formatted.
*/
1034 /* _UIB-CODE-BLOCK-END
*/
1039 &IF DEFINED(EXCLUDE-interco-outside-group) = 0 &THEN
1041 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION interco-outside-group Procedure
1042 FUNCTION interco-outside-group
RETURNS LOGICAL
1043 ( INPUT ac
AS DEC ) :
1044 /*------------------------------------------------------------------------------
1047 ------------------------------------------------------------------------------*/
1048 /* we disable the whole thing at the moment
*/
1051 IF consol-accounts
= "" THEN RETURN No.
1052 IF (TRUNC( ac
/ 1000, 0) * 1000) <> ic-base
THEN RETURN No.
1053 IF LOOKUP( STRING(ac
, "9999.99"), consol-accounts
) > 0 THEN RETURN No.
1059 /* _UIB-CODE-BLOCK-END
*/