1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /* The report options are
:
5 * Entity-Type
,<T
> - only entity type
"<T>" is examined
6 * Entity-Range
,<e1
>,<en
> - only entities in the range
<e1
> to
<en
> are checked
7 * Action
,<action
> - <action
> may be
"Fix" or
"Check"
8 * Preview
- causes report to be previewed
10 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
12 DEF VAR fix-action
AS CHAR INITIAL "Check" NO-UNDO.
13 DEF VAR preview
AS LOGICAL NO-UNDO INITIAL No.
14 DEF VAR month-1
AS INT NO-UNDO INITIAL -99999.
15 DEF VAR month-n
AS INT NO-UNDO INITIAL 99999.
16 DEF VAR entity-t
AS CHAR NO-UNDO INITIAL "".
17 DEF VAR entity-1
AS INT NO-UNDO INITIAL 0.
18 DEF VAR entity-n
AS INT NO-UNDO INITIAL 99999.
19 DEF VAR file-name
AS CHAR NO-UNDO INITIAL "".
20 DEF VAR exporting
AS LOGI
NO-UNDO.
21 DEF VAR check-TBS
AS LOGI
NO-UNDO INITIAL No.
22 DEF VAR check-Cr
AS LOGI
NO-UNDO INITIAL No.
23 DEF VAR check-Db
AS LOGI
NO-UNDO INITIAL No.
24 DEF VAR check-batches
AS LOGI
NO-UNDO INITIAL No.
25 DEF VAR batch-1
AS INT NO-UNDO INITIAL -99999.
26 DEF VAR batch-n
AS INT NO-UNDO INITIAL 99999.
27 DEF VAR test-sub-bal
AS LOGI
NO-UNDO INITIAL No.
28 DEF VAR test-no-gl
AS LOGI
NO-UNDO INITIAL No.
29 DEF VAR test-no-sub
AS LOGI
NO-UNDO INITIAL No.
30 DEF VAR test-groups
AS LOGI
NO-UNDO INITIAL No.
33 DEF VAR act-total
AS DECIMAL NO-UNDO.
34 DEF VAR actt-total
AS DECIMAL NO-UNDO.
35 DEF VAR acb-total
AS DECIMAL NO-UNDO.
36 DEF VAR cls-total
AS DECIMAL NO-UNDO.
37 DEF VAR act-missing
AS CHAR NO-UNDO.
39 /* formatting stuff
*/
40 DEF VAR column-head
AS CHAR NO-UNDO INITIAL "".
41 DEF VAR need-header
AS LOGI
NO-UNDO INITIAL Yes.
42 DEF VAR base-font
AS CHAR NO-UNDO INITIAL "Courier,cpi,19,lpi,8,Fixed,Normal".
43 DEF VAR section-font
AS CHAR NO-UNDO INITIAL "univers,Point,8,bold,Proportional".
44 DEF VAR user-name
AS CHAR NO-UNDO.
45 {inc
/username.i
"user-name"}
48 {inc
/ofc-acct.i
"DEBTORS" "sundry-debtors"}
49 {inc
/ofc-acct.i
"CREDITORS" "sundry-creditors"}
50 DEF VAR creditor-company
AS INT NO-UNDO.
51 creditor-company
= OfficeControlAccount.EntityCode.
53 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
54 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
56 DEF TEMP-TABLE GL-Bal
NO-UNDO
57 FIELD CompanyCode
AS INT FORMAT ">>999" LABEL " Coy"
58 FIELD AccountCode
AS INT FORMAT "9999.99" LABEL "Account"
59 FIELD MonthCode
AS INT
60 FIELD Balance
AS DEC FORMAT ">>>,>>>,>>9.99CR" LABEL " Tnt Sum".
62 DEF TEMP-TABLE IC-Bal
NO-UNDO
63 FIELD CompanyCode
AS INT FORMAT ">>999" LABEL " Coy"
64 FIELD MonthCode
AS INT
67 DEF TEMP-TABLE DoneIt
NO-UNDO
69 INDEX XPKDone
IS UNIQUE PRIMARY KeyDone.
71 /* _UIB-CODE-BLOCK-END
*/
75 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
77 /* ******************** Preprocessor Definitions
******************** */
79 &Scoped-define PROCEDURE-TYPE Procedure
83 /* _UIB-PREPROCESSOR-BLOCK-END
*/
87 /* ************************ Function Prototypes
********************** */
89 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD accttran-error Procedure
90 FUNCTION accttran-error
RETURNS CHARACTER
91 ( INPUT error-text
AS CHAR ) FORWARD.
93 /* _UIB-CODE-BLOCK-END
*/
97 /* *********************** Procedure Settings
************************ */
99 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
100 /* Settings for
THIS-PROCEDURE
104 Add Fields to
: Neither
105 Other Settings
: CODE-ONLY
COMPILE
107 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
109 /* ************************* Create Window
************************** */
111 &ANALYZE-SUSPEND _CREATE-WINDOW
112 /* DESIGN Window definition
(used by the UIB
)
113 CREATE WINDOW Procedure
ASSIGN
116 /* END WINDOW DEFINITION
*/
122 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
123 /* ************************* Included-Libraries
*********************** */
125 {inc
/method
/m-txtrep.i
}
128 /* _UIB-CODE-BLOCK-END
*/
133 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
136 /* *************************** Main Block
*************************** */
137 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
139 RUN pclrep-start
( preview
, "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
141 IF check-TBS
THEN DO:
143 DEF VAR ledger-t
AS DEC INITIAL 0 NO-UNDO.
144 DEF VAR ledger-b
AS DEC INITIAL 0 NO-UNDO.
145 DEF VAR ledger-s
AS DEC INITIAL 0 NO-UNDO.
147 column-head
= " Account Month Acct Balance Trans. Value ".
148 RUN check-missing-balances
( (fix-action
= "Fix") ).
149 /* RUN check-missing-summaries
( (fix-action
= "Fix") ).
*/
150 RUN check-account-balances
( (fix-action
= "Fix") ).
151 RUN check-account-summaries
( (fix-action
= "Fix") ).
153 RUN pclrep-down-by
(2).
154 RUN pclrep-line
( base-font
, "GL Totals: Summary = " + STRING( ledger-s
, "->>,>>>,>>>,>>9.99") ).
155 RUN pclrep-line
( base-font
, " Balances = " + STRING( ledger-b
, "->>,>>>,>>>,>>9.99") ).
156 RUN pclrep-line
( base-font
, " Transactions = " + STRING( ledger-b
, "->>,>>>,>>>,>>9.99") ).
158 IF check-db
THEN RUN check-tenants.
159 IF check-cr
THEN RUN check-creditors.
161 IF check-batches
THEN
162 RUN check-batch-intercompany.
166 RUN view-output-file
( preview
).
168 /* _UIB-CODE-BLOCK-END
*/
172 /* ********************** Internal Procedures
*********************** */
174 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-account-balances Procedure
175 PROCEDURE check-account-balances
:
176 /*------------------------------------------------------------------------------
178 ------------------------------------------------------------------------------*/
179 DEF INPUT PARAMETER fix-it
AS LOGICAL NO-UNDO.
181 DEF VAR month-text
AS CHAR NO-UNDO.
182 RUN new-section
( "Checking account balance records" ).
184 FOR EACH AccountBalance
NO-LOCK WHERE AccountBalance.EntityType
BEGINS entity-t
185 AND AccountBalance.EntityCode
>= entity-1
186 AND AccountBalance.EntityCode
<= entity-n
187 AND AccountBalance.MonthCode
>= month-1
188 AND AccountBalance.MonthCode
<= month-n
189 BY AccountBalance.EntityType
BY AccountBalance.EntityCode
190 BY AccountBalance.AccountCode
BY AccountBalance.MonthCode
:
193 FOR EACH AcctTran
NO-LOCK OF AccountBalance
:
194 actt-total
= actt-total
+ AcctTran.Amount.
196 IF actt-total
<> AccountBalance.Balance
THEN DO:
197 FIND Month
WHERE Month.MonthCode
= AccountBalance.MonthCode
NO-LOCK.
198 month-text
= SUBSTRING( STRING( Month.StartDate
, "99/99/9999" ), 4, 7).
200 RUN pclrep-line
( base-font
, SUBSTITUTE( "&1 &2 &3 &4 &5 &6",
201 AccountBalance.EntityType
,
202 STRING(AccountBalance.EntityCode
, "99999"),
203 STRING(AccountBalance.AccountCode
, "9999.99"),
205 STRING( AccountBalance.Balance
, ">>>,>>>,>>>,>>9.99CR"),
206 STRING( actt-total
, ">>>,>>>,>>>,>>9.99CR") )).
208 RUN set-account-balance
( AccountBalance.EntityType
,
209 AccountBalance.EntityCode
, AccountBalance.AccountCode
,
210 AccountBalance.MonthCode
, actt-total
).
214 IF AccountBalance.EntityType
= "L" THEN ASSIGN
215 ledger-t
= ledger-t
+ actt-total
216 ledger-b
= ledger-b
+ AccountBalance.Balance.
222 /* _UIB-CODE-BLOCK-END
*/
226 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-account-summaries Procedure
227 PROCEDURE check-account-summaries
:
228 /*------------------------------------------------------------------------------
230 ------------------------------------------------------------------------------*/
231 DEF INPUT PARAMETER fix-it
AS LOGICAL NO-UNDO.
233 RUN new-section
( "Checking account summary records" ).
235 FOR EACH AccountSummary
NO-LOCK WHERE AccountBalance.EntityType
BEGINS entity-t
236 AND AccountSummary.EntityCode
>= entity-1
237 AND AccountSummary.EntityCode
<= entity-n
238 BY AccountSummary.EntityType
239 BY AccountSummary.EntityCode
240 BY AccountSummary.AccountCode
:
243 FOR EACH AccountBalance
NO-LOCK OF AccountSummary
:
244 acb-total
= acb-total
+ AccountBalance.Balance.
246 IF AccountSummary.EntityType
<> "J" THEN RUN check-chart-of-accounts
( fix-it
).
247 IF acb-total
<> AccountSummary.Balance
THEN DO:
249 RUN pclrep-line
( base-font
, SUBSTITUTE( "&1 &2 &3 &4 &5",
250 AccountSummary.EntityType
,
251 STRING(AccountSummary.EntityCode
, "99999"),
252 STRING(AccountSummary.AccountCode
, "9999.99"),
253 STRING( AccountSummary.Balance
, ">>>,>>>,>>>,>>9.99CR"),
254 STRING( acb-total
, ">>>,>>>,>>>,>>9.99CR") )).
256 RUN set-account-summary
( AccountSummary.EntityType
,
257 AccountSummary.EntityCode
, AccountSummary.AccountCode
, acb-total
).
261 IF AccountSummary.EntityType
= "L" THEN ASSIGN
262 ledger-b
= ledger-b
+ acb-total
263 ledger-s
= ledger-s
+ AccountSummary.Balance.
269 /* _UIB-CODE-BLOCK-END
*/
273 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-batch-intercompany Procedure
274 PROCEDURE check-batch-intercompany
:
275 /*------------------------------------------------------------------------------
277 ------------------------------------------------------------------------------*/
278 DEF VAR batch-total
AS DEC NO-UNDO.
279 DEF VAR n-bad
AS INT NO-UNDO INITIAL 0.
281 column-head
= " Account Month Acct Balance Trans. Value ".
282 RUN new-section
( "Checking batches" ).
284 FOR EACH Batch
WHERE Batch.BatchCode
>= batch-1
285 AND Batch.BatchCode
<= batch-n
NO-LOCK:
286 FOR EACH IC-Bal
: DELETE IC-Bal.
END.
288 FOR EACH AcctTran
OF Batch
NO-LOCK:
289 IF AcctTran.EntityType
= "L" THEN DO:
290 batch-total
= batch-total
+ AcctTran.Amount.
291 FIND IC-Bal
WHERE IC-Bal.CompanyCode
= AcctTran.EntityCode
292 AND IC-Bal.MonthCode
= AcctTran.MonthCode
NO-LOCK NO-ERROR.
293 IF NOT AVAILABLE(IC-Bal
) THEN CREATE IC-Bal.
294 IC-Bal.CompanyCode
= AcctTran.EntityCode.
295 IC-Bal.MonthCode
= AcctTran.MonthCode.
296 IC-Bal.Amount
= IC-Bal.Amount
+ AcctTran.Amount .
298 IF INDEX( "LPJTCF", AcctTran.EntityType
) = 0 THEN accttran-error
( "Unknown Entity Type '" + AcctTran.EntityType
+ "'").
299 IF AcctTran.EntityCode
< 1 OR AcctTran.EntityCode
> 99999 OR AcctTran.EntityCode
= ?
THEN
300 accttran-error
( "Bad entity code '" + null-str
(STRING(AcctTran.EntityCode
),"?") + "'").
301 IF AcctTran.AccountCode
< 0.01 OR AcctTran.AccountCode
> 9999.99 OR AcctTran.EntityCode
= ?
THEN
302 accttran-error
( "Bad account code '" + null-str
(STRING(AcctTran.AccountCode
),"?") + "'").
304 FOR EACH IC-Bal
WHERE IC-Bal.Amount
<> 0:
306 RUN pclrep-line
( base-font
, SUBSTITUTE( "Batch &1 bad intercompany for ledger &2, month &3 ",
307 Batch.BatchCode
, IC-Bal.CompanyCode
, IC-Bal.MonthCode
) ).
309 IF batch-total
<> 0 THEN DO:
312 RUN pclrep-line
( base-font
, SUBSTITUTE( "Batch &1 intercompany does not balance.",
316 IF (fix-action
= "Fix")
317 AND CAN-FIND( FIRST IC-Bal
WHERE IC-Bal.Amount
<> 0)
319 RUN fix-batch-intercompany
(Batch.BatchCode
).
322 RUN pclrep-line
( base-font
, SUBSTITUTE(" &1 unbalanced batches found", n-bad
) ).
326 /* _UIB-CODE-BLOCK-END
*/
330 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-chart-of-accounts Procedure
331 PROCEDURE check-chart-of-accounts
:
332 /*------------------------------------------------------------------------------
333 Purpose
: Check if the account is in the chart of accounts
334 ------------------------------------------------------------------------------*/
335 DEF INPUT PARAMETER fix-it
AS LOGICAL NO-UNDO.
337 IF AccountSummary.Balance
<> 0 AND NOT CAN-FIND( ChartOfAccount
OF AccountSummary
) THEN DO:
340 CREATE ChartOfAccount.
342 ChartOfAccount.AccountCode
= AccountSummary.AccountCode
343 ChartOfAccount.AccountGroupCode
= "ZZZZ"
344 ChartOfAccount.HighVolume
= no
345 ChartOfAccount.Name
= "Unknown (" + STRING( AccountSummary.AccountCode
, "9999.99") + ")"
347 RUN pclrep-line
( base-font
, SUBSTITUTE( "No ChartOfAccount record for account &1 - account added.",
348 AccountSummary.AccountCode
) ).
351 RUN pclrep-line
( base-font
, SUBSTITUTE( "No ChartOfAccount record for account &1 .",
352 AccountSummary.AccountCode
) ).
357 /* _UIB-CODE-BLOCK-END
*/
361 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-creditors Procedure
362 PROCEDURE check-creditors
:
363 /*------------------------------------------------------------------------------
365 ------------------------------------------------------------------------------*/
367 IF test-sub-bal
THEN RUN creditor-versus-gl.
368 IF test-no-gl
THEN RUN no-gl-consequence
( "C", sundry-creditors
).
369 IF test-no-sub
THEN RUN gl-not-consequence
( "C", sundry-creditors
).
371 IF test-groups
THEN DO:
372 column-head
= " Batch Doc # Amount Creditor Account ".
373 RUN new-section
( "Scan for groups of Creditor transactions which do not add to zero" ).
374 need-header
= check-TBS
OR check-db
OR test-sub-bal
OR test-no-gl
OR test-no-sub.
375 FOR EACH Creditor
NO-LOCK BY Creditor.CreditorCode
:
376 RUN test-closed-groups
( "C", Creditor.CreditorCode
, sundry-creditors
).
382 /* _UIB-CODE-BLOCK-END
*/
386 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-missing-balances Procedure
387 PROCEDURE check-missing-balances
:
388 /*------------------------------------------------------------------------------
390 ------------------------------------------------------------------------------*/
391 DEF INPUT PARAMETER fix-it
AS LOGICAL NO-UNDO.
393 DEF VAR code
AS CHAR NO-UNDO.
394 DEF VAR month-text
AS CHAR NO-UNDO.
397 FOR EACH AcctTran
WHERE AcctTran.EntityType
BEGINS entity-t
398 AND AcctTran.EntityCode
>= entity-1
399 AND AcctTran.EntityCode
<= entity-n
400 AND AcctTran.MonthCode
>= month-1
401 AND AcctTran.MonthCode
<= month-n
402 AND NOT CAN-FIND( AccountBalance
OF AcctTran
) NO-LOCK:
404 IF NOT fix-it
THEN DO:
405 code
= AcctTran.EntityType
+ STRING(AcctTran.EntityCode
)
406 + STRING(AcctTran.AccountCode
) + STRING(AcctTran.MonthCode
).
407 IF CAN-FIND( DoneIt
WHERE DoneIt.KeyDone
= code
) THEN NEXT.
409 DoneIt.KeyDone
= code.
411 FIND Month
WHERE Month.MonthCode
= AcctTran.MonthCode
NO-LOCK NO-ERROR.
412 month-text
= (IF AVAILABLE(Month
) THEN SUBSTRING( STRING( Month.StartDate
, "99/99/9999" ), 4, 7) ELSE "Month" + STRING(AcctTran.MonthCode
) + " missing").
414 RUN pclrep-line
( base-font
, SUBSTITUTE( "&1 &2 &3 &4 &5",
416 STRING(AcctTran.EntityCode
, "99999"),
417 STRING(AcctTran.AccountCode
, "9999.99"),
419 " monthly balance record is missing") ).
421 RUN set-account-balance
( AcctTran.EntityType
, AcctTran.EntityCode
,
422 AcctTran.AccountCode
, AcctTran.MonthCode
, 0).
427 /* _UIB-CODE-BLOCK-END
*/
431 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-missing-summaries Procedure
432 PROCEDURE check-missing-summaries
:
433 /*------------------------------------------------------------------------------
435 ------------------------------------------------------------------------------*/
436 DEF INPUT PARAMETER fix-it
AS LOGICAL NO-UNDO.
438 DEF VAR code
AS CHAR NO-UNDO.
441 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
BEGINS entity-t
442 AND AccountBalance.EntityCode
>= entity-1
443 AND AccountBalance.EntityCode
<= entity-n
444 AND NOT CAN-FIND( AccountSummary
OF AccountBalance
) NO-LOCK:
446 IF NOT fix-it
THEN DO:
447 code
= AccountBalance.EntityType
+ STRING(AccountBalance.EntityCode
)
448 + STRING(AccountBalance.AccountCode
) + STRING(AccountBalance.MonthCode
).
449 IF CAN-FIND( DoneIt
WHERE DoneIt.KeyDone
= code
) THEN NEXT.
451 DoneIt.KeyDone
= code.
454 RUN pclrep-line
( base-font
, SUBSTITUTE( "&1 &2 &3 &4 &5",
455 AccountBalance.EntityType
,
456 STRING(AccountBalance.EntityCode
, "99999"),
457 STRING(AccountBalance.AccountCode
, "9999.99"),
459 " account summary record is missing") ).
461 RUN set-account-summary
( AccountBalance.EntityType
, AccountBalance.EntityCode
,
462 AccountBalance.AccountCode
, 0).
467 /* _UIB-CODE-BLOCK-END
*/
471 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-tenants Procedure
472 PROCEDURE check-tenants
:
473 /*------------------------------------------------------------------------------
475 ------------------------------------------------------------------------------*/
477 IF test-sub-bal
THEN RUN tenant-versus-gl.
478 IF test-no-gl
THEN RUN no-gl-consequence
( "T", sundry-debtors
).
479 IF test-no-sub
THEN RUN gl-not-consequence
( "T", sundry-debtors
).
481 IF test-groups
THEN DO:
482 column-head
= " Batch Doc # Amount Tenant Account ".
483 RUN new-section
( "Scan for groups of Tenant transactions which do not add to zero").
484 need-header
= check-TBS
OR test-sub-bal
OR test-no-gl
OR test-no-sub.
485 FOR EACH Tenant
NO-LOCK BY Tenant.TenantCode
:
486 RUN test-closed-groups
( "T", Tenant.TenantCode
, sundry-debtors
).
492 /* _UIB-CODE-BLOCK-END
*/
496 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-done Procedure
497 PROCEDURE clear-done
:
498 /*------------------------------------------------------------------------------
499 Purpose
: Clear the
"DoneIt" table
500 ------------------------------------------------------------------------------*/
501 FOR EACH DoneIt
: DELETE DoneIt.
END.
504 /* _UIB-CODE-BLOCK-END
*/
508 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE creditor-versus-gl Procedure
509 PROCEDURE creditor-versus-gl
:
510 /*------------------------------------------------------------------------------
512 ------------------------------------------------------------------------------*/
514 FIND Company
WHERE Company.CompanyCode
= creditor-company
NO-LOCK.
516 FOR EACH Creditor
NO-LOCK:
517 FIND FIRST AccountBalance
WHERE AccountBalance.EntityType
= "C"
518 AND AccountBalance.EntityCode
= Creditor.CreditorCode
521 IF AVAILABLE(AccountBalance
) THEN DO:
522 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= "C"
523 AND AccountBalance.EntityCode
= Creditor.CreditorCode
525 FIND GL-Bal
WHERE GL-Bal.CompanyCode
= Company.CompanyCode
526 AND GL-Bal.AccountCode
= AccountBalance.AccountCode
527 AND GL-Bal.MonthCode
= AccountBalance.MonthCode
NO-ERROR.
528 IF NOT AVAILABLE(GL-Bal
) THEN DO:
530 GL-Bal.CompanyCode
= Company.CompanyCode.
531 GL-Bal.MonthCode
= AccountBalance.MonthCode.
532 GL-Bal.AccountCode
= AccountBalance.AccountCode.
534 GL-Bal.Balance
= GL-Bal.Balance
+ AccountBalance.Balance .
539 DEF VAR gb-tot
LIKE GL-Bal.Balance
NO-UNDO.
540 DEF VAR ab-tot
LIKE GL-Bal.Balance
NO-UNDO.
542 DEF VAR acb-Balance
AS CHAR FORMAT "X(17)" NO-UNDO LABEL " GL Balance".
544 column-head
= "Company Account Month Cred Balance GL Balance".
545 RUN new-section
( "Scan for GL Creditors Control where balance <> sum of Creditors of that company").
547 FOR EACH GL-Bal
WHERE GL-Bal.Balance
<> 0:
548 FIND FIRST Month
OF GL-Bal
NO-LOCK.
549 FIND AccountBalance
WHERE AccountBalance.EntityType
= "L"
550 AND AccountBalance.EntityCode
= GL-Bal.CompanyCode
551 AND AccountBalance.AccountCode
= GL-Bal.AccountCode
552 AND AccountBalance.MonthCode
= GL-Bal.MonthCode
555 acb-Balance
= (IF AVAILABLE(AccountBalance
) THEN STRING( AccountBalance.Balance
, ">>>,>>>,>>9.99CR") ELSE "not on file").
556 IF NOT AVAILABLE(AccountBalance
) OR GL-Bal.Balance
<> AccountBalance.Balance
THEN DO:
558 RUN pclrep-line
( base-font
, SUBSTITUTE( " &1 &2 &3 &4 &5",
559 STRING( GL-Bal.CompanyCode
, "99999"),
560 STRING( GL-Bal.AccountCode
, "9999.99"),
561 SUBSTR( STRING(Month.StartDate
, "99/99/9999"), 4),
562 STRING( GL-Bal.Balance
, ">>>,>>>,>>>,>>9.99CR"),
564 gb-tot
= gb-tot
+ GL-Bal.Balance .
565 IF AVAILABLE(AccountBalance
) THEN ab-tot
= ab-tot
+ AccountBalance.Balance.
570 DEF VAR line
AS CHAR NO-UNDO.
571 DEF VAR under
AS CHAR NO-UNDO.
573 line
= FILL(" ",22) + "&1 &2".
574 under
= " " + FILL("-",15) + " ".
575 RUN pclrep-line
( base-font
, SUBSTITUTE( line
, under
, under
) ).
576 RUN pclrep-line
( base-font
, SUBSTITUTE( line
,
577 STRING( gb-tot
, ">>>,>>>,>>>,>>9.99CR"),
578 STRING( ab-tot
, ">>>,>>>,>>>,>>9.99CR") )).
582 /* _UIB-CODE-BLOCK-END
*/
586 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE fix-batch-intercompany Procedure
587 PROCEDURE fix-batch-intercompany
:
588 /*------------------------------------------------------------------------------
590 ------------------------------------------------------------------------------*/
591 DEF INPUT PARAMETER batch-code
AS INT NO-UNDO.
593 DEF BUFFER tmp_Batch
FOR Batch.
594 RUN new-section
( "Fixing intercompany for batch" + STRING(batch-code
) ).
595 FIND tmp_Batch
WHERE tmp_Batch.BatchCode
= batch-code
NO-LOCK NO-ERROR.
598 FIND LAST Document
OF tmp_Batch
EXCLUSIVE-LOCK NO-ERROR.
599 IF AVAILABLE(Document
) AND Document.DocumentType
= "ICOA" THEN DO:
600 FOR EACH AcctTran
OF Document
:
603 FOR EACH AcctTran
OF Document
:
609 /* now we just create a
"NewBatch" and tell the system it is only partly-posted
*/
610 FIND NewBatch
WHERE NewBatch.BatchCode
= batch-code
NO-LOCK NO-ERROR.
611 IF NOT AVAILABLE(NewBatch
) THEN DO:
613 BUFFER-COPY tmp_Batch
TO NewBatch.
614 NewBatch.BatchType
= "PART," + STRING(batch-code
).
615 MESSAGE "Batch" batch-code
"is now 'part-posted' - please complete update".
617 ELSE IF NewBatch.BatchType
BEGINS "PART" THEN
618 MESSAGE "Batch" batch-code
"is already 'part-posted' - please complete update".
620 MESSAGE "Batch" batch-code
"is not updated! Status:" NewBatch.BatchType.
626 /* _UIB-CODE-BLOCK-END
*/
630 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE gl-not-consequence Procedure
631 PROCEDURE gl-not-consequence
:
632 /*------------------------------------------------------------------------------
634 ------------------------------------------------------------------------------*/
635 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
636 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
638 DEF BUFFER ConsOfTran
FOR AcctTran.
639 DEF VAR a-total
AS DEC NO-UNDO INITIAL 0.
640 DEF VAR m-total
AS DEC NO-UNDO INITIAL 0.
641 DEF VAR g-total
AS DEC NO-UNDO INITIAL 0.
643 column-head
= " Batch Doc # Amount Company Account ".
644 RUN new-section
( "Scan for " + et
+ "/" + STRING(ac
,"9999.99")
645 + " control account transactions which are not consequential postings").
647 FOR EACH Company
NO-LOCK,
648 EACH AcctTran
NO-LOCK WHERE AcctTran.EntityType
= "L"
649 AND AcctTran.EntityCode
= Company.CompanyCode
650 AND AcctTran.AccountCode
= ac
:
651 FIND FIRST ConsOfTran
WHERE ConsOfTran.BatchCode
= AcctTran.BatchCode
652 AND ConsOfTran.DocumentCode
= AcctTran.DocumentCode
653 AND ConsOfTran.TransactionCode
< AcctTran.TransactionCode
654 AND ConsOfTran.EntityType
= et
655 AND ConsOfTran.AccountCode
= AcctTran.AccountCode
656 AND ConsOfTran.Amount
= AcctTran.Amount
658 IF NOT AVAILABLE(ConsOfTran
) THEN DO:
660 RUN pclrep-line
( base-font
, SUBSTITUTE( "&1 &2 &3 &4 &5 &6 &7",
661 STRING( AcctTran.BatchCode
, ">>>>9"),
662 STRING( AcctTran.DocumentCode
, ">>>>9"),
663 STRING( AcctTran.Amount
, ">,>>>,>>>,>>9.99CR"),
664 STRING( AcctTran.EntityCode
, "99999"),
665 STRING( AcctTran.AccountCode
, "9999.99"),
666 STRING( AcctTran.Reference
, "X(14)"),
667 AcctTran.Description
) ).
668 g-total
= g-total
+ AcctTran.Amount .
672 RUN pclrep-line
( base-font
, FILL(" ",16) + FILL( "-", 12) ).
673 RUN pclrep-line
( base-font
, FILL(" ",12) + STRING( g-total
, ">,>>>,>>>,>>9.99CR") ).
677 /* _UIB-CODE-BLOCK-END
*/
681 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
682 PROCEDURE inst-page-footer
:
683 /*------------------------------------------------------------------------------
684 Purpose
: Print any page footer
685 ------------------------------------------------------------------------------*/
689 /* _UIB-CODE-BLOCK-END
*/
693 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
694 PROCEDURE inst-page-header
:
695 /*------------------------------------------------------------------------------
696 Purpose
: Print any page header
697 ------------------------------------------------------------------------------*/
698 DEF VAR line
AS CHAR NO-UNDO.
700 RUN pclrep-line
( "univers,Point,7,bold,Proportional", TimeStamp
).
701 RUN pclrep-line
( "", "" ).
702 RUN pclrep-line
( "univers,Point,12,bold,Proportional",
703 FILL(" ",40) + "System Integrity Report" ).
705 RUN pclrep-line
( "univers,Point,7,normal,Proportional", "").
706 RUN pclrep-line
( "univers,Point,9,normal,Proportional", hdr-run-description
).
708 RUN pclrep-line
( "", "" ).
714 /* _UIB-CODE-BLOCK-END
*/
718 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE new-section Procedure
719 PROCEDURE new-section
:
720 /*------------------------------------------------------------------------------
722 ------------------------------------------------------------------------------*/
723 DEF INPUT PARAMETER section-header
AS CHAR NO-UNDO.
725 RUN pclrep-down-by
(1.4).
726 RUN pclrep-line
( section-font
, section-header
).
731 /* _UIB-CODE-BLOCK-END
*/
735 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE no-gl-consequence Procedure
736 PROCEDURE no-gl-consequence
:
737 /*------------------------------------------------------------------------------
739 ------------------------------------------------------------------------------*/
740 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
741 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
743 DEF BUFFER CoyTran
FOR AcctTran.
745 column-head
= " Batch Doc # Amount Tenant Account ".
746 RUN new-section
( "Scan for " + et
+ "/" + STRING(ac
,"9999.99")
747 + " control account transactions where there is no consequential posting to the GL").
749 FOR EACH AcctTran
NO-LOCK WHERE AcctTran.EntityType
= et
:
750 FIND FIRST CoyTran
WHERE CoyTran.BatchCode
= AcctTran.BatchCode
751 AND CoyTran.DocumentCode
= AcctTran.DocumentCode
752 AND CoyTran.TransactionCode
> AcctTran.TransactionCode
753 AND CoyTran.EntityType
= "L"
754 AND CoyTran.AccountCode
= AcctTran.AccountCode
755 AND CoyTran.Amount
= AcctTran.Amount
757 IF NOT AVAILABLE(CoyTran
) THEN DO:
759 RUN pclrep-line
( base-font
, SUBSTITUTE( "&1 &2 &3 &4 &5 &6 &7",
760 STRING( AcctTran.BatchCode
, ">>>>9"),
761 STRING( AcctTran.DocumentCode
, ">>>>9"),
762 STRING( AcctTran.Amount
, ">,>>>,>>>,>>9.99CR"),
763 STRING( AcctTran.EntityCode
, "99999"),
764 STRING( AcctTran.AccountCode
, "9999.99"),
765 STRING( AcctTran.Reference
, "X(14)"),
766 AcctTran.Description
) ).
772 /* _UIB-CODE-BLOCK-END
*/
776 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
777 PROCEDURE parse-parameters
:
778 /*------------------------------------------------------------------------------
780 ------------------------------------------------------------------------------*/
781 DEF VAR i
AS INT NO-UNDO.
782 DEF VAR token
AS CHAR NO-UNDO.
783 DEF VAR attrib-desc
AS CHAR NO-UNDO.
785 {inc
/showopts.i
"report-options"}
787 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
789 token
= ENTRY( i
, report-options
, "~n" ).
790 CASE( ENTRY( 1, token
) ):
792 WHEN "Action" THEN fix-action
= ENTRY( 2, token
).
793 WHEN "Preview" THEN preview
= Yes.
794 WHEN "Check-TBS" THEN check-tbs
= Yes.
795 WHEN "Check-CR" THEN check-cr
= Yes.
796 WHEN "Check-Db" THEN check-db
= Yes.
797 WHEN "Test-Sub-Bal" THEN test-sub-bal
= Yes.
798 WHEN "Test-No-GL" THEN test-no-gl
= Yes.
799 WHEN "Test-No-Sub" THEN test-no-sub
= Yes.
800 WHEN "Test-Groups" THEN test-groups
= Yes.
802 WHEN "Export" THEN ASSIGN
804 file-name
= ENTRY( 2, token
) .
806 WHEN "Check-Batches" THEN ASSIGN
808 batch-1
= INT( ENTRY( 2, token
))
809 batch-n
= INT( ENTRY( 3, token
)).
811 WHEN "Month-Range" THEN ASSIGN
812 month-1
= INT( ENTRY( 2, token
))
813 month-n
= INT( ENTRY( 3, token
)).
815 WHEN "Entity-Type" THEN
816 entity-t
= SUBSTRING( ENTRY( 2, token
), 1, 1).
818 WHEN "Entity-Range" THEN ASSIGN
819 entity-1
= INT( ENTRY( 2, token
))
820 entity-n
= INT( ENTRY( 3, token
)).
827 /* _UIB-CODE-BLOCK-END
*/
831 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-account-balance Procedure
832 PROCEDURE set-account-balance
:
833 /*------------------------------------------------------------------------------
835 ------------------------------------------------------------------------------*/
836 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
837 DEF INPUT PARAMETER ec
AS INT NO-UNDO.
838 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
839 DEF INPUT PARAMETER mc
AS INT NO-UNDO.
840 DEF INPUT PARAMETER amt
AS DEC NO-UNDO.
842 DEF BUFFER acb
FOR AccountBalance.
844 IF et
= "X" THEN RETURN.
847 FIND acb
EXCLUSIVE-LOCK WHERE acb.EntityType
= et
AND acb.EntityCode
= ec
848 AND acb.AccountCode
= ac
AND acb.MonthCode
= mc
NO-ERROR.
849 IF NOT AVAILABLE(acb
) THEN DO:
851 ASSIGN acb.EntityType
= et acb.EntityCode
= ec
852 acb.AccountCode
= ac acb.MonthCode
= mc.
859 /* _UIB-CODE-BLOCK-END
*/
863 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-account-summary Procedure
864 PROCEDURE set-account-summary
:
865 /*------------------------------------------------------------------------------
867 ------------------------------------------------------------------------------*/
868 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
869 DEF INPUT PARAMETER ec
AS INT NO-UNDO.
870 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
871 DEF INPUT PARAMETER amt
AS DEC NO-UNDO.
873 DEF BUFFER acs
FOR AccountSummary.
874 IF et
= "X" THEN RETURN.
877 FIND acs
EXCLUSIVE-LOCK WHERE acs.EntityType
= et
878 AND acs.EntityCode
= ec
AND acs.AccountCode
= ac
NO-ERROR.
879 IF NOT AVAILABLE(acs
) THEN DO:
881 ASSIGN acs.EntityType
= et acs.EntityCode
= ec acs.AccountCode
= ac.
888 /* _UIB-CODE-BLOCK-END
*/
892 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE tenant-versus-gl Procedure
893 PROCEDURE tenant-versus-gl
:
894 /*------------------------------------------------------------------------------
896 ------------------------------------------------------------------------------*/
898 FOR EACH Tenant
NO-LOCK:
899 FIND FIRST AccountBalance
WHERE AccountBalance.EntityType
= "T"
900 AND AccountBalance.EntityCode
= Tenant.TenantCode
903 IF AVAILABLE(AccountBalance
) THEN DO:
904 IF Tenant.EntityType
= "L" THEN
905 FIND Company
WHERE Company.CompanyCode
= Tenant.EntityCode
NO-LOCK.
907 FIND Property
WHERE Property.PropertyCode
= Tenant.EntityCode
NO-LOCK.
908 FIND Company
OF Property
NO-LOCK.
910 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= "T"
911 AND AccountBalance.EntityCode
= Tenant.TenantCode
913 FIND GL-Bal
WHERE GL-Bal.CompanyCode
= Company.CompanyCode
914 AND GL-Bal.AccountCode
= AccountBalance.AccountCode
915 AND GL-Bal.MonthCode
= AccountBalance.MonthCode
NO-ERROR.
916 IF NOT AVAILABLE(GL-Bal
) THEN DO:
918 GL-Bal.CompanyCode
= Company.CompanyCode.
919 GL-Bal.MonthCode
= AccountBalance.MonthCode.
920 GL-Bal.AccountCode
= AccountBalance.AccountCode.
922 GL-Bal.Balance
= GL-Bal.Balance
+ AccountBalance.Balance .
927 DEF VAR gb-tot
LIKE GL-Bal.Balance
NO-UNDO.
928 DEF VAR ab-tot
LIKE GL-Bal.Balance
NO-UNDO.
930 DEF VAR acb-Variance
LIKE GL-Bal.Balance
NO-UNDO.
931 DEF VAR acb-Balance
AS CHAR FORMAT "X(17)" NO-UNDO LABEL " GL Balance".
933 column-head
= "Company Account Month Tenant Balance GL Balance Variance".
934 RUN new-section
( "Scan for GL Sundry debtors where balance <> sum of tenants of properties of that company").
936 FOR EACH GL-Bal
WHERE GL-Bal.Balance
<> 0
937 BY GL-Bal.MonthCode
BY GL-Bal.CompanyCode
BY GL-Bal.AccountCode
:
938 FIND FIRST Month
OF GL-Bal
NO-LOCK.
939 FIND AccountBalance
WHERE AccountBalance.EntityType
= "L"
940 AND AccountBalance.EntityCode
= GL-Bal.CompanyCode
941 AND AccountBalance.AccountCode
= GL-Bal.AccountCode
942 AND AccountBalance.MonthCode
= GL-Bal.MonthCode
945 acb-Balance
= (IF AVAILABLE(AccountBalance
) THEN STRING( AccountBalance.Balance
, ">>>,>>>,>>9.99CR") ELSE "not on file").
946 acb-Variance
= (IF AVAILABLE(AccountBalance
) THEN AccountBalance.Balance
ELSE 0).
947 IF NOT AVAILABLE(AccountBalance
) OR GL-Bal.Balance
<> AccountBalance.Balance
THEN DO:
948 acb-Variance
= GL-Bal.Balance
- acb-Variance.
950 RUN pclrep-line
( base-font
, SUBSTITUTE( " &1 &2 &3 &4 &5 &6",
951 STRING( GL-Bal.CompanyCode
, "99999"),
952 STRING( GL-Bal.AccountCode
, "9999.99"),
953 SUBSTR( STRING(Month.StartDate
, "99/99/9999"), 4),
954 STRING( GL-Bal.Balance
, ">>>,>>>,>>>,>>9.99CR"),
955 STRING( acb-Balance
, "X(20)"),
956 STRING( acb-Variance
, ">>>,>>>,>>>,>>9.99CR") )).
957 gb-tot
= gb-tot
+ GL-Bal.Balance .
958 IF AVAILABLE(AccountBalance
) THEN ab-tot
= ab-tot
+ AccountBalance.Balance.
963 DEF VAR line
AS CHAR NO-UNDO.
964 DEF VAR under
AS CHAR NO-UNDO.
966 line
= FILL(" ",23) + "&1 &2 &3".
967 under
= " " + FILL("-",15) + " ".
968 RUN pclrep-line
( base-font
, SUBSTITUTE( line
, under
, under
, under
) ).
969 RUN pclrep-line
( base-font
, SUBSTITUTE( line
,
970 STRING( gb-tot
, ">>>,>>>,>>>,>>9.99CR"),
971 STRING( ab-tot
, ">>>,>>>,>>>,>>9.99CR"),
972 STRING( gb-tot
- ab-tot
, ">>>,>>>,>>>,>>9.99CR") )).
976 /* _UIB-CODE-BLOCK-END
*/
980 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE test-closed-groups Procedure
981 PROCEDURE test-closed-groups
:
982 /*------------------------------------------------------------------------------
984 ------------------------------------------------------------------------------*/
985 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
986 DEF INPUT PARAMETER ec
AS INT NO-UNDO.
987 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
989 DEF VAR group-total
LIKE AcctTran.Amount
NO-UNDO.
991 FOR EACH ClosingGroup
WHERE ClosingGroup.EntityType
= et
992 AND ClosingGroup.EntityCode
= ec
993 AND ClosingGroup.AccountCode
= ac
994 AND ClosingGroup.ClosedStatus
= "F" NO-LOCK:
996 FOR EACH AcctTran
OF ClosingGroup
NO-LOCK:
997 group-total
= group-total
+ AcctTran.Amount .
999 IF group-total
<> 0.0 THEN DO:
1001 FOR EACH AcctTran
OF ClosingGroup
NO-LOCK:
1002 RUN pclrep-line
( base-font
, SUBSTITUTE( "&1 &2 &3 &4 &5 &6 &7",
1003 STRING( AcctTran.BatchCode
, ">>>>9"),
1004 STRING( AcctTran.DocumentCode
, ">>>>9"),
1005 STRING( AcctTran.Amount
, ">,>>>,>>>,>>9.99CR"),
1006 STRING( AcctTran.EntityCode
, "99999"),
1007 STRING( AcctTran.AccountCode
, "9999.99"),
1008 STRING( AcctTran.Reference
, "X(14)"),
1009 AcctTran.Description
) ).
1011 RUN pclrep-line
( base-font
, FILL(" ",30) + "Total for group " + STRING( group-total
, ">,>>>,>>>,>>9.99CR") ).
1012 RUN pclrep-down-by
(1.2).
1013 IF fix-action
= "Fix" THEN DO:
1014 DEF BUFFER ClGroup
FOR ClosingGroup.
1015 FIND ClGroup
WHERE RECID(ClGroup
) = RECID(ClosingGroup
) EXCLUSIVE-LOCK.
1016 FOR EACH AcctTran
OF ClGroup
EXCLUSIVE-LOCK:
1017 AcctTran.ClosedState
= "O".
1018 AcctTran.ClosingGroup
= ?.
1027 /* _UIB-CODE-BLOCK-END
*/
1031 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE test-headers Procedure
1032 PROCEDURE test-headers
:
1033 /*------------------------------------------------------------------------------
1035 ------------------------------------------------------------------------------*/
1036 IF need-header
THEN DO:
1037 RUN pclrep-line
( base-font
+ ",bold", column-head
).
1043 /* _UIB-CODE-BLOCK-END
*/
1047 /* ************************ Function Implementations
***************** */
1049 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION accttran-error Procedure
1050 FUNCTION accttran-error
RETURNS CHARACTER
1051 ( INPUT error-text
AS CHAR ) :
1052 /*------------------------------------------------------------------------------
1053 Purpose
: Display an error to do with a particular transaction
1055 ------------------------------------------------------------------------------*/
1056 DEF VAR line
AS CHAR NO-UNDO.
1057 line
= STRING(AcctTran.BatchCode
,"99999") + "-"
1058 + STRING(AcctTran.DocumentCode
,"99999") + "-"
1059 + STRING(AcctTran.TransactionCode
,"99999") + " "
1060 + AcctTran.EntityType
+ " "
1061 + STRING(AcctTran.EntityCode
,"99999") + " "
1062 + STRING(AcctTran.AccountCode
,"9999.99") + " "
1064 RUN pclrep-line
( base-font
, line
).
1066 RETURN "".
/* Function return value.
*/
1070 /* _UIB-CODE-BLOCK-END
*/