Add blank column, rename column.
[capital-apms-progress.git] / process / report / property-tb.p
blobc7bdb2f2fdde18267ed0df1fad5cdc4a786ef519
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File : process/report/property-tb.p
6 Purpose : Produce Property Trial Balance by Group reports
8 Author(s) : Andrew McMillan
9 Created : 14/11/96
10 ------------------------------------------------------------------------*/
11 /* Parameter list */
12 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
14 DEF VAR regenerate AS LOGI NO-UNDO.
15 DEF VAR entity-type AS CHAR NO-UNDO.
16 DEF VAR entity-1 AS INT NO-UNDO.
17 DEF VAR entity-2 AS INT NO-UNDO.
18 DEF VAR month-1 AS INT NO-UNDO.
19 DEF VAR month-2 AS INT NO-UNDO.
20 DEF VAR csv-file-name AS CHAR NO-UNDO.
21 DEF VAR list-name AS CHAR NO-UNDO.
22 DEF VAR column-style AS CHAR NO-UNDO.
23 DEF VAR r-type AS CHAR NO-UNDO.
24 DEF VAR range AS CHAR NO-UNDO.
25 DEF VAR out-to AS CHAR NO-UNDO.
26 DEF VAR pedantic-listing AS LOGICAL NO-UNDO INITIAL No.
27 DEF VAR consolidate-together AS LOGI NO-UNDO INITIAL No.
28 DEF VAR month-range AS LOGICAL NO-UNDO INITIAL No.
29 DEF VAR exclude-year-end AS LOGICAL NO-UNDO INITIAL No.
30 DEF VAR debug-mode AS LOGICAL NO-UNDO INITIAL Yes.
31 RUN parse-parameters.
33 /* global variables used by create-tb-record */
34 DEF VAR last-account-code AS DECIMAL INITIAL -1 NO-UNDO.
35 DEF VAR account-name AS CHAR NO-UNDO.
36 DEF VAR last-account-group AS CHAR INITIAL "none-as-yet" NO-UNDO.
37 DEF VAR account-seq AS INT NO-UNDO.
38 DEF VAR acgroup-name AS CHAR NO-UNDO.
39 DEF VAR account-comments AS CHAR NO-UNDO.
40 DEF VAR consol-accounts AS CHAR NO-UNDO.
42 /* accountgroup totals, entity totals and grand totals */
43 DEF VAR total-name AS CHAR FORMAT "X(50)" NO-UNDO.
44 DEF VAR ag-balance AS DECIMAL NO-UNDO.
45 DEF VAR ag-budget AS DECIMAL NO-UNDO.
46 DEF VAR ag-mtdbal AS DECIMAL NO-UNDO.
47 DEF VAR ag-mtdbud AS DECIMAL NO-UNDO.
49 DEF VAR et-balance AS DECIMAL NO-UNDO.
50 DEF VAR et-budget AS DECIMAL NO-UNDO.
51 DEF VAR et-mtdbal AS DECIMAL NO-UNDO.
52 DEF VAR et-mtdbud AS DECIMAL NO-UNDO.
54 DEF VAR pl-balance AS DECIMAL NO-UNDO.
55 DEF VAR pl-budget AS DECIMAL NO-UNDO.
56 DEF VAR pl-mtdbal AS DECIMAL NO-UNDO.
57 DEF VAR pl-mtdbud AS DECIMAL NO-UNDO.
59 DEF VAR remaining-comments AS CHAR NO-UNDO.
62 DEFINE TEMP-TABLE tb NO-UNDO /* LIKE TrialBalance */
63 FIELD EntityType AS CHAR
64 FIELD EntityCode AS INTEGER
65 FIELD SequenceCode AS INTEGER
66 FIELD AccountCode AS DECIMAL
67 FIELD SequenceName AS CHAR
68 FIELD AccountName AS CHAR
69 FIELD Balance AS DECIMAL
70 FIELD Budget AS DECIMAL
71 FIELD mtd-Balance AS DECIMAL
72 FIELD mtd-Budget AS DECIMAL
73 FIELD Comment AS CHAR
75 INDEX e-code IS UNIQUE PRIMARY EntityType EntityCode SequenceCode AccountCode .
77 /* Printer setup string and page size */
78 DEF VAR prt-ctrl AS CHAR NO-UNDO.
79 DEF VAR rows AS INT NO-UNDO.
80 DEF VAR cols AS INT NO-UNDO.
81 RUN make-control-string ( "PCL", "reset,landscape,tm,2,a4,lm,6,courier,cpi,18,lpi,9",
82 OUTPUT prt-ctrl, OUTPUT rows, OUTPUT cols ).
83 /* MESSAGE "rows =" rows " cols =" cols. */
85 /* Frame & form definitions */
86 &SCOP page-width 180
87 &SCOP WITH-DEFAULT NO-BOX USE-TEXT WIDTH {&page-width}
89 FIND Month WHERE Month.MonthCode = month-2 NO-LOCK.
90 DEFINE FRAME heading-frame WITH 1 DOWN {&WITH-DEFAULT} NO-LABELS PAGE-TOP.
91 DEF VAR user-name AS CHAR NO-UNDO.
92 DEF VAR timeStamp AS CHAR FORMAT "X(54)" NO-UNDO.
93 DEF VAR rtypeString AS CHAR FORMAT "X(12)" INITIAL "Detailed" NO-UNDO.
94 rtypeString = IF r-type = "S" THEN "Summary" ELSE (IF r-type = "C" THEN "Consolidated" ELSE "Detailed" ) .
95 DEF VAR hline2 AS CHAR NO-UNDO.
96 DEF VAR hline3 AS CHAR NO-UNDO.
97 DEF VAR col-heads AS CHAR NO-UNDO.
98 col-heads = FILL(" ", 8) + STRING("Account", "X(51)").
99 IF column-style = "Std" THEN
100 col-heads = col-heads + " YTD Actual YTD Budget YTD Variance Month Actual Month Budget Month Variance Comments".
101 ELSE
102 col-heads = col-heads + " Current YTD Last Mth YTD Month Actual Month Budget Month Variance Comments".
104 FORM HEADER
105 timeStamp "Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
106 hline2 FORMAT "X({&page-width})"
107 hline3 FORMAT "X({&page-width})"
108 SKIP (1)
109 col-heads FORMAT "X({&page-width})"
110 WITH FRAME heading-frame.
112 DEF VAR money-format AS CHAR INITIAL ">,>>>,>>>,>>9.99CR" NO-UNDO.
113 DEF VAR minus-line AS CHAR FORMAT "X(120)" NO-UNDO.
114 minus-line = " " + FILL("-", 18).
115 minus-line = FILL(" ", 58) + minus-line + minus-line + minus-line
116 + minus-line + minus-line
117 + (IF column-style = "Std" THEN minus-line ELSE "").
119 DEF VAR col-width AS INT NO-UNDO.
120 IF column-style = "Std" THEN
121 col-width = 64 + LENGTH(STRING(0,money-format)) * 6.
122 ELSE
123 col-width = 63 + LENGTH(STRING(0,money-format)) * 5.
125 DEFINE STREAM debug-stream.
127 {inc/ofc-this.i}
128 {inc/ofc-acct.i "IC-BASE" "ic-base"}
130 /* _UIB-CODE-BLOCK-END */
131 &ANALYZE-RESUME
134 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
136 /* ******************** Preprocessor Definitions ******************** */
138 &Scoped-define PROCEDURE-TYPE Procedure
139 &Scoped-define DB-AWARE no
143 /* _UIB-PREPROCESSOR-BLOCK-END */
144 &ANALYZE-RESUME
147 /* ************************ Function Prototypes ********************** */
149 &IF DEFINED(EXCLUDE-balance-from-balances) = 0 &THEN
151 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD balance-from-balances Procedure
152 FUNCTION balance-from-balances RETURNS DECIMAL
153 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT m-1 AS INT, INPUT m-n AS INT ) FORWARD.
155 /* _UIB-CODE-BLOCK-END */
156 &ANALYZE-RESUME
158 &ENDIF
160 &IF DEFINED(EXCLUDE-balance-from-summary) = 0 &THEN
162 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD balance-from-summary Procedure
163 FUNCTION balance-from-summary RETURNS DECIMAL
164 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT mnth AS INT ) FORWARD.
166 /* _UIB-CODE-BLOCK-END */
167 &ANALYZE-RESUME
169 &ENDIF
171 &IF DEFINED(EXCLUDE-debug-event) = 0 &THEN
173 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD debug-event Procedure
174 FUNCTION debug-event RETURNS CHARACTER
175 ( INPUT event-text AS CHAR ) FORWARD.
177 /* _UIB-CODE-BLOCK-END */
178 &ANALYZE-RESUME
180 &ENDIF
182 &IF DEFINED(EXCLUDE-get-balance) = 0 &THEN
184 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-balance Procedure
185 FUNCTION get-balance RETURNS DECIMAL
186 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT month-n AS INT ) FORWARD.
188 /* _UIB-CODE-BLOCK-END */
189 &ANALYZE-RESUME
191 &ENDIF
193 &IF DEFINED(EXCLUDE-get-property-desc) = 0 &THEN
195 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-property-desc Procedure
196 FUNCTION get-property-desc RETURNS CHARACTER
197 ( INPUT ec AS INT ) FORWARD.
199 /* _UIB-CODE-BLOCK-END */
200 &ANALYZE-RESUME
202 &ENDIF
205 /* *********************** Procedure Settings ************************ */
207 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
208 /* Settings for THIS-PROCEDURE
209 Type: Procedure
210 Allow:
211 Frames: 0
212 Add Fields to: Neither
213 Other Settings: CODE-ONLY COMPILE
215 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
217 /* ************************* Create Window ************************** */
219 &ANALYZE-SUSPEND _CREATE-WINDOW
220 /* DESIGN Window definition (used by the UIB)
221 CREATE WINDOW Procedure ASSIGN
222 HEIGHT = 17
223 WIDTH = 37.86.
224 /* END WINDOW DEFINITION */
226 &ANALYZE-RESUME
228 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
229 /* ************************* Included-Libraries *********************** */
231 {inc/method/m-txtrep.i}
233 /* _UIB-CODE-BLOCK-END */
234 &ANALYZE-RESUME
240 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
243 /* *************************** Main Block *************************** */
244 {inc/username.i "user-name"}
245 timeStamp = "Printed " + STRING( TIME, "HH:MM:SS") + ", " + STRING( TODAY, "99/99/9999") + " for " + user-name.
247 IF debug-mode THEN
248 OUTPUT STREAM debug-stream TO debug.log PAGE-SIZE 0.
250 debug-event("Start building temp table for >>" + list-name + "<<" ).
251 IF range = "E" THEN DO: /* list of entities */
252 FIND EntityList WHERE EntityList.ListCode = list-name NO-LOCK.
253 debug-event("Processing members of list " + list-name ).
254 FOR EACH EntityListMember WHERE EntityListMember.ListCode = EntityList.ListCode NO-LOCK:
255 debug-event("Adding to temp file for " + EntityListMember.EntityType + STRING(EntityListMember.EntityCode,"99999") ).
256 RUN build-temp-file-range( EntityListMember.EntityType, EntityListMember.EntityCode, EntityListMember.EntityCode, month-1, month-2 ).
257 END.
258 entity-type = EntityList.ListType.
259 END.
260 ELSE
261 RUN build-temp-file-range( "P", entity-1, entity-2, month-1, month-2 ).
263 debug-event("Finished building temp table").
265 IF r-type = "DS" THEN DO:
266 IF out-to = "S" THEN DO:
267 RUN normal-to-csv-file( Yes ).
268 RUN normal-to-csv-file( No ).
269 END.
270 ELSE IF out-to = "0" THEN
271 . /* Don't report */
272 ELSE DO:
273 RUN normal-to-printer( Yes, (out-to = "V") ).
274 RUN normal-to-printer( No, (out-to = "V") ).
275 END.
276 END.
277 ELSE IF r-type = "D" OR r-type = "S" THEN DO:
278 IF out-to = "S" THEN
279 RUN normal-to-csv-file( (r-type = "D") ).
280 ELSE IF out-to = "0" THEN
281 . /* Don't report */
282 ELSE
283 RUN normal-to-printer( (r-type = "D"), (out-to = "V") ).
284 END.
285 ELSE IF r-type = "E" THEN DO:
286 IF out-to = "S" THEN
287 RUN exhaustive-to-csv.
288 ELSE
289 MESSAGE "Consolidated Report only available to Spreadsheet".
290 /* to be continued ... */
291 END.
292 ELSE DO:
293 IF out-to = "S" THEN
294 RUN consolidated-to-csv.
295 ELSE
296 MESSAGE "Consolidated Report only available to Spreadsheet".
297 /* to be continued ... */
298 END.
300 debug-event("Finished").
302 IF debug-mode THEN
303 OUTPUT STREAM debug-stream CLOSE.
305 /* _UIB-CODE-BLOCK-END */
306 &ANALYZE-RESUME
309 /* ********************** Internal Procedures *********************** */
311 &IF DEFINED(EXCLUDE-build-temp-file-range) = 0 &THEN
313 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-temp-file-range Procedure
314 PROCEDURE build-temp-file-range :
315 /*------------------------------------------------------------------------------
316 Purpose:
317 ------------------------------------------------------------------------------*/
318 DEF INPUT PARAMETER et AS CHAR NO-UNDO.
319 DEF INPUT PARAMETER e1 AS INT NO-UNDO.
320 DEF INPUT PARAMETER e2 AS INT NO-UNDO.
321 DEF INPUT PARAMETER m1 AS INT NO-UNDO.
322 DEF INPUT PARAMETER m2 AS INT NO-UNDO.
324 DEF VAR prev-co AS INT INITIAL -1 NO-UNDO.
325 DEF VAR prev-acc AS DECIMAL INITIAL -1 NO-UNDO.
327 DEF VAR bal AS DEC NO-UNDO.
328 DEF VAR bud AS DEC NO-UNDO.
329 DEF VAR m-bal AS DEC NO-UNDO.
330 DEF VAR m-bud AS DEC NO-UNDO.
332 FOR EACH AccountBalance WHERE EntityType = et
333 AND EntityCode >= e1 AND EntityCode <= e2
334 AND AccountBalance.MonthCode >= m1
335 AND AccountBalance.MonthCode <= m2 NO-LOCK:
336 IF AccountBalance.EntityCode <> prev-co OR AccountBalance.AccountCode <> prev-acc THEN DO:
337 IF prev-co <> -1 THEN DO:
338 IF NOT(month-range) THEN
339 bal = get-balance( et, prev-co, prev-acc, m2 ).
340 RUN create-tb-record ( et, prev-co, prev-acc, bal, bud, m-bal, m-bud, "", "" ).
341 END.
342 ASSIGN bal = 0 bud = 0 m-bal = 0 m-bud = 0
343 prev-co = AccountBalance.EntityCode prev-acc = AccountBalance.AccountCode.
344 END.
345 bal = bal + AccountBalance.Balance.
346 bud = bud + AccountBalance.Budget.
347 IF AccountBalance.MonthCode = m2 THEN DO:
348 m-bal = AccountBalance.Balance.
349 m-bud = AccountBalance.Budget.
350 END.
351 END.
353 IF prev-co <> -1 THEN DO:
354 IF NOT(month-range) THEN
355 bal = get-balance( et, prev-co, prev-acc, m2 ).
356 RUN create-tb-record ( et, prev-co, prev-acc, bal, bud, m-bal, m-bud, "", "" ).
357 END.
359 IF month-range THEN RETURN.
361 /* for those accounts with no balance in the period, but which do have a balance */
362 FOR EACH AccountSummary NO-LOCK WHERE AccountSummary.EntityType = et
363 AND AccountSummary.EntityCode >= e1 AND AccountSummary.EntityCode <= e2
364 AND NOT CAN-FIND( FIRST AccountBalance OF AccountSummary
365 WHERE AccountBalance.MonthCode >= m1
366 AND AccountBalance.MonthCode <= m2):
367 bal = get-balance( et, AccountSummary.EntityCode, AccountSummary.AccountCode, m2 ).
368 IF bal <> 0 THEN
369 RUN create-tb-record ( et, AccountSummary.EntityCode, AccountSummary.AccountCode, bal, 0.0, 0.0, 0.0, "", "" ).
370 END.
372 /* for those accounts with no balance now, but which did have a balance at the end of the period */
373 prev-co = -1.
374 prev-acc = -1.
375 DEF BUFFER OtherBalance FOR AccountBalance.
376 FOR EACH AccountBalance NO-LOCK WHERE AccountBalance.EntityType = et
377 AND AccountBalance.EntityCode >= e1 AND AccountBalance.EntityCode <= e2
378 AND NOT CAN-FIND( FIRST OtherBalance WHERE OtherBalance.EntityType = et
379 AND OtherBalance.EntityCode = AccountBalance.EntityCode
380 AND OtherBalance.AccountCode = AccountBalance.AccountCode
381 AND OtherBalance.MonthCode >= m1
382 AND OtherBalance.MonthCode <= m2)
383 AND NOT CAN-FIND( AccountSummary OF AccountBalance ):
384 IF AccountBalance.EntityCode <> prev-co OR AccountBalance.AccountCode <> prev-acc THEN DO:
385 IF prev-co <> -1 THEN DO:
386 bal = get-balance( et, prev-co, prev-acc, m2 ).
387 IF bal <> 0 THEN
388 RUN create-tb-record ( et, prev-co, prev-acc, bal, 0, 0, 0, "", "" ).
389 END.
390 ASSIGN prev-co = AccountBalance.EntityCode
391 prev-acc = AccountBalance.AccountCode.
392 END.
393 END.
395 IF prev-co <> -1 THEN DO:
396 bal = get-balance( et, prev-co, prev-acc, m2 ).
397 IF bal <> 0 THEN
398 RUN create-tb-record ( et, prev-co, prev-acc, bal, bud, m-bal, m-bud, "", "" ).
399 END.
401 END PROCEDURE.
403 /* _UIB-CODE-BLOCK-END */
404 &ANALYZE-RESUME
406 &ENDIF
408 &IF DEFINED(EXCLUDE-consolidated-to-csv) = 0 &THEN
410 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE consolidated-to-csv Procedure
411 PROCEDURE consolidated-to-csv :
412 /*------------------------------------------------------------------------------
413 Purpose: Consolidated report to a CSV file.
414 ------------------------------------------------------------------------------*/
415 DEF VAR last-sequence AS INT INITIAL -1 NO-UNDO.
416 DEF VAR total LIKE tb.Balance NO-UNDO.
418 OUTPUT TO VALUE(csv-file-name) KEEP-MESSAGES PAGE-SIZE 0.
419 PUT UNFORMATTED ','.
420 FOR EACH Property NO-LOCK WHERE CAN-FIND( FIRST tb WHERE tb.EntityType = entity-type
421 AND tb.EntityCode = Property.PropertyCode )
422 BY Property.PropertyCode:
423 PUT UNFORMATTED ',' + STRING(Property.PropertyCode).
424 END.
425 PUT SKIP.
426 PUT UNFORMATTED ',"Description"'.
427 FOR EACH Property NO-LOCK WHERE CAN-FIND( FIRST tb
428 WHERE tb.EntityType = entity-type
429 AND tb.EntityCode = Property.PropertyCode )
430 BY Property.PropertyCode:
431 PUT UNFORMATTED ',"' + Property.ShortName + '"'.
432 END.
433 PUT SKIP.
435 FOR EACH AccountGroup NO-LOCK WHERE CAN-FIND( FIRST tb
436 WHERE tb.SequenceCode = AccountGroup.SequenceCode )
437 BY AccountGroup.SequenceCode:
438 PUT UNFORMATTED '"' + AccountGroup.AccountGroupCode
439 + '","' + AccountGroup.Name + '"'.
440 FOR EACH Property NO-LOCK WHERE CAN-FIND( FIRST tb
441 WHERE tb.EntityType = entity-type
442 AND tb.EntityCode = Property.PropertyCode )
443 BY Property.PropertyCode:
445 total = 0.
446 FOR EACH tb WHERE tb.EntityType = entity-type
447 AND tb.EntityCode = Property.PropertyCode
448 AND tb.SequenceCode = AccountGroup.SequenceCode
449 NO-LOCK:
450 total = total + tb.Balance.
451 END.
453 PUT UNFORMATTED ",".
454 PUT UNFORMATTED total.
455 END.
456 PUT SKIP.
457 END.
458 OUTPUT CLOSE.
459 END PROCEDURE.
461 /* _UIB-CODE-BLOCK-END */
462 &ANALYZE-RESUME
464 &ENDIF
466 &IF DEFINED(EXCLUDE-create-tb-record) = 0 &THEN
468 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-tb-record Procedure
469 PROCEDURE create-tb-record :
470 /*------------------------------------------------------------------------------
471 Purpose: Create a trial balance record
472 ------------------------------------------------------------------------------*/
473 DEF INPUT PARAMETER entity-type AS CHAR NO-UNDO.
474 DEF INPUT PARAMETER entity-code AS INTEGER NO-UNDO.
475 DEF INPUT PARAMETER account-code AS DECIMAL NO-UNDO.
476 DEF INPUT PARAMETER bal AS DECIMAL NO-UNDO.
477 DEF INPUT PARAMETER bud AS DECIMAL NO-UNDO.
478 DEF INPUT PARAMETER mtd-bal AS DECIMAL NO-UNDO.
479 DEF INPUT PARAMETER mtd-bud AS DECIMAL NO-UNDO.
480 DEF INPUT PARAMETER c1 AS CHAR NO-UNDO.
481 DEF INPUT PARAMETER c2 AS CHAR NO-UNDO.
483 /* all variables are defined globally so their values are held */
485 &SCOP BAD-SEQ 9999
486 &SCOP BAD-NAME "Unknown"
488 IF account-code <> last-account-code THEN DO:
489 FIND ChartOfAccount WHERE ChartOfAccount.AccountCode = account-code NO-LOCK NO-ERROR.
490 IF AVAILABLE(ChartOfAccount) THEN DO:
491 ASSIGN account-name = ChartOfAccount.Name
492 last-account-group = ChartOfAccount.AccountGroupCode .
493 FIND AccountGroup OF ChartOfAccount NO-LOCK NO-ERROR.
494 IF AVAILABLE(AccountGroup) THEN
495 ASSIGN account-seq = AccountGroup.SequenceCode acgroup-name = AccountGroup.Name.
496 ELSE
497 ASSIGN account-seq = {&BAD-SEQ} acgroup-name = {&BAD-NAME}.
498 END.
499 ELSE
500 ASSIGN account-name = {&BAD-NAME} + " - " + STRING(account-code, "9999.99")
501 account-seq = {&BAD-SEQ}
502 acgroup-name = {&BAD-NAME}.
503 last-account-code = account-code.
504 END.
506 IF exclude-year-end THEN DO:
507 FIND LAST AcctTran WHERE AcctTran.EntityType = entity-type
508 AND AcctTran.EntityCode = entity-code
509 AND AcctTran.AccountCode = account-code
510 AND AcctTran.MonthCode = month-2
511 AND (AcctTran.Description BEGINS "Y/E Transfer to Ret"
512 OR AcctTran.Description BEGINS "Y/E Accumulated P&L"
513 OR CAN-FIND( FIRST Document OF AcctTran WHERE Document.Description BEGINS "Y/E Transfer to Ret")
514 OR CAN-FIND( FIRST Document OF AcctTran WHERE Document.Description BEGINS "Y/E Accumulated P&L"))
515 NO-LOCK NO-ERROR.
516 IF AVAILABLE(AcctTran) THEN DO:
517 ASSIGN bal = bal - AcctTran.Amount
518 mtd-bal = mtd-bal - AcctTran.Amount .
519 END.
520 END.
522 IF c1 = ? THEN c1 = "".
523 IF c2 = ? THEN c2 = "".
524 IF consolidate-together THEN DO:
525 entity-code = 0.
526 FIND tb WHERE tb.EntityType = entity-type
527 AND tb.EntityCode = entity-code
528 AND tb.SequenceCode = account-seq
529 AND tb.AccountCode = account-code NO-ERROR.
530 IF AVAILABLE(tb) THEN DO:
531 bal = tb.Balance + bal.
532 bud = tb.Budget + bud.
533 mtd-bal = tb.mtd-Balance + mtd-bal.
534 mtd-bud = tb.mtd-Budget + mtd-bud.
535 END.
536 ELSE
537 CREATE tb.
538 END.
539 ELSE
540 CREATE tb.
542 ASSIGN tb.EntityType = entity-type
543 tb.EntityCode = entity-code
544 tb.AccountCode = account-code
545 tb.AccountName = account-name
546 tb.SequenceCode = account-seq
547 tb.SequenceName = acgroup-name
548 tb.Balance = bal
549 tb.Budget = bud
550 tb.mtd-Balance = mtd-bal
551 tb.mtd-Budget = mtd-bud
552 tb.Comment = TRIM(c1)
553 + (IF TRIM(c1) <> "" AND TRIM(c2) <> "" THEN "~n" ELSE "")
554 + TRIM(c2) .
557 END PROCEDURE.
559 /* _UIB-CODE-BLOCK-END */
560 &ANALYZE-RESUME
562 &ENDIF
564 &IF DEFINED(EXCLUDE-exhaustive-to-csv) = 0 &THEN
566 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE exhaustive-to-csv Procedure
567 PROCEDURE exhaustive-to-csv :
568 /*------------------------------------------------------------------------------
569 Purpose: Exhaustive report to a CSV file.
570 ------------------------------------------------------------------------------*/
571 DEF VAR last-sequence AS INT INITIAL -1 NO-UNDO.
572 DEF VAR total LIKE tb.Balance NO-UNDO.
574 OUTPUT TO VALUE(csv-file-name) KEEP-MESSAGES PAGE-SIZE 0.
575 PUT UNFORMATTED '"Account","Description"' .
576 FOR EACH Property NO-LOCK WHERE CAN-FIND( FIRST tb
577 WHERE tb.EntityType = entity-type
578 AND tb.EntityCode = Property.PropertyCode )
579 BY Property.PropertyCode:
580 PUT UNFORMATTED ',"' + Property.ShortName + '"'.
581 END.
582 PUT SKIP.
584 FOR EACH AccountGroup NO-LOCK, EACH ChartOfAccount OF AccountGroup NO-LOCK
585 WHERE (pedantic-listing AND ChartOfAccount.UpdateTo <> "")
586 OR CAN-FIND( FIRST tb WHERE tb.AccountCode = ChartOfAccount.AccountCode )
587 BY AccountGroup.SequenceCode BY ChartOfAccount.AccountCode:
588 PUT UNFORMATTED STRING( ChartOfAccount.AccountCode, "9999.99") + ',"' + ChartOfAccount.Name + '"'.
589 FOR EACH Property NO-LOCK WHERE CAN-FIND( FIRST tb
590 WHERE tb.EntityType = entity-type
591 AND tb.EntityCode = Property.PropertyCode )
592 BY Property.PropertyCode:
594 total = 0.
595 FIND FIRST tb WHERE tb.EntityType = entity-type
596 AND tb.EntityCode = Property.PropertyCode
597 AND tb.AccountCode = ChartOfAccount.AccountCode
598 NO-LOCK NO-ERROR.
599 IF AVAILABLE(tb) THEN total = tb.Balance.
601 PUT UNFORMATTED ",".
602 PUT UNFORMATTED total.
603 END.
604 PUT SKIP.
605 END.
606 OUTPUT CLOSE.
607 END PROCEDURE.
609 /* _UIB-CODE-BLOCK-END */
610 &ANALYZE-RESUME
612 &ENDIF
614 &IF DEFINED(EXCLUDE-normal-pedantic-each) = 0 &THEN
616 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE normal-pedantic-each Procedure
617 PROCEDURE normal-pedantic-each :
618 /*------------------------------------------------------------------------------
619 Purpose:
620 ------------------------------------------------------------------------------*/
621 DEF INPUT PARAMETER detail AS LOGI NO-UNDO.
622 DEF INPUT PARAMETER property-code AS INT NO-UNDO.
624 DEF VAR last-sequence AS INT INITIAL -1 NO-UNDO.
625 DEF VAR sequence-name AS CHAR NO-UNDO.
626 DEF VAR new-property AS LOGI NO-UNDO INITIAL Yes.
627 DEF VAR property-desc AS CHAR NO-UNDO.
629 FOR EACH AccountGroup NO-LOCK, EACH ChartOfAccount OF AccountGroup NO-LOCK
630 WHERE (pedantic-listing AND ChartOfAccount.UpdateTo <> "")
631 OR CAN-FIND( tb WHERE tb.EntityType = entity-type
632 AND tb.EntityCode = property-code
633 AND tb.AccountCode = ChartOfAccount.AccountCode )
634 BY AccountGroup.SequenceCode BY ChartOfAccount.AccountCode:
636 IF new-property OR AccountGroup.SequenceCode <> last-sequence THEN DO:
637 IF NOT detail AND last-sequence >= 0 THEN DO:
638 PUT UNFORMATTED '"","","'
639 last-sequence '","'
640 sequence-name '","'
641 ag-balance '","'
642 ag-budget '","'
643 ag-mtdbal '","'
644 ag-mtdbud '"'
645 SKIP.
646 END.
647 ELSE
648 PUT UNFORMATTED SKIP.
650 ASSIGN last-sequence = AccountGroup.SequenceCode
651 sequence-name = AccountGroup.Name
652 ag-balance = 0 ag-budget = 0
653 ag-mtdbal = 0 ag-mtdbud = 0.
655 IF new-property THEN DO:
656 property-desc = get-property-desc(property-code).
657 PUT UNFORMATTED '"' property-code '","' property-desc '"' SKIP.
658 new-property = No.
659 END.
660 END.
662 FIND tb WHERE tb.EntityType = entity-type
663 AND tb.EntityCode = property-code
664 AND tb.AccountCode = ChartOfAccount.AccountCode NO-LOCK NO-ERROR.
666 IF detail THEN DO:
667 IF new-property THEN DO:
668 PUT UNFORMATTED '"' property-code '"'.
669 property-desc = get-property-desc(property-code).
670 PUT UNFORMATTED ',"' property-desc '"' SKIP.
671 new-property = No.
672 END.
673 PUT UNFORMATTED '"","","' ChartOfAccount.AccountCode '","' ChartOfAccount.Name '","'.
674 IF AVAILABLE(tb) THEN DO:
675 PUT UNFORMATTED
676 tb.Balance '","'
677 tb.Budget '","'
678 tb.mtd-Balance '","'
679 tb.mtd-Budget '","'
680 tb.Comment '"'
681 SKIP.
682 END.
683 ELSE
684 PUT UNFORMATTED '0","0","0","0",""' SKIP.
685 END.
686 ELSE IF AVAILABLE(tb) THEN DO:
687 ag-balance = ag-balance + tb.Balance.
688 ag-budget = ag-budget + tb.Budget.
689 ag-mtdbal = ag-mtdbal + tb.mtd-Balance.
690 ag-mtdbud = ag-mtdbud + tb.mtd-Budget .
691 END.
693 PUT SKIP.
694 END.
696 IF NOT detail AND last-sequence >= 0 THEN DO:
697 PUT UNFORMATTED '"","","'
698 last-sequence '","'
699 sequence-name '","'
700 ag-balance '","'
701 ag-budget '","'
702 ag-mtdbal '","'
703 ag-mtdbud '"'
704 SKIP.
705 END.
707 END PROCEDURE.
709 /* _UIB-CODE-BLOCK-END */
710 &ANALYZE-RESUME
712 &ENDIF
714 &IF DEFINED(EXCLUDE-normal-pedantic-to-csv) = 0 &THEN
716 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE normal-pedantic-to-csv Procedure
717 PROCEDURE normal-pedantic-to-csv :
718 /*------------------------------------------------------------------------------
719 Purpose: Generate TB output to a CSV file
720 ------------------------------------------------------------------------------*/
721 DEF INPUT PARAMETER detail AS LOGI NO-UNDO.
724 OUTPUT TO VALUE(csv-file-name) KEEP-MESSAGES PAGE-SIZE 0.
725 PUT UNFORMATTED '"Property Code","Property Name","AccountCode","AccountName",'
726 '"Balance","Budget","mtd-Balance","mtd-Budget","Comment"' SKIP.
728 IF consolidate-together THEN DO:
729 RUN normal-pedantic-each( detail, 0 ).
730 END.
731 ELSE DO:
732 FOR EACH Property NO-LOCK WHERE CAN-FIND( FIRST tb WHERE tb.EntityType = entity-type
733 AND tb.EntityCode = Property.PropertyCode ) BY Property.PropertyCode:
734 RUN normal-pedantic-each( detail, Property.PropertyCode ).
735 END.
736 END.
740 OUTPUT CLOSE.
742 MESSAGE 'File "' + csv-file-name + '" generated successfully.'
743 VIEW-AS ALERT-BOX INFORMATION TITLE "Property TB".
744 END PROCEDURE.
746 /* _UIB-CODE-BLOCK-END */
747 &ANALYZE-RESUME
749 &ENDIF
751 &IF DEFINED(EXCLUDE-normal-to-csv-file) = 0 &THEN
753 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE normal-to-csv-file Procedure
754 PROCEDURE normal-to-csv-file :
755 /*------------------------------------------------------------------------------
756 Purpose: Generate TB output to a CSV file
757 ------------------------------------------------------------------------------*/
758 DEF INPUT PARAMETER detail AS LOGI NO-UNDO.
760 IF pedantic-listing THEN DO:
761 RUN normal-pedantic-to-csv( detail ).
762 RETURN.
763 END.
765 DEF VAR last-sequence AS INT INITIAL -1 NO-UNDO.
766 DEF VAR sequence-name AS CHAR NO-UNDO.
767 DEF VAR last-property AS INT INITIAL -1 NO-UNDO.
768 DEF VAR property-desc AS CHAR NO-UNDO.
770 OUTPUT TO VALUE(csv-file-name) KEEP-MESSAGES PAGE-SIZE 0.
771 PUT UNFORMATTED '"Property Code","Property Name","AccountCode","AccountName",'
772 '"Balance","Budget","mtd-Balance","mtd-Budget","Comment"' SKIP.
774 FOR EACH tb
775 BY EntityType BY EntityCode BY SequenceCode BY AccountCode:
776 IF EntityCode <> last-property OR SequenceCode <> last-sequence THEN DO:
777 IF NOT detail AND last-sequence >= 0 THEN DO:
778 PUT UNFORMATTED '"","","'
779 last-sequence '","'
780 sequence-name '","'
781 ag-balance '","'
782 ag-budget '","'
783 ag-mtdbal '","'
784 ag-mtdbud '"'
785 SKIP.
786 END.
787 ELSE
788 PUT UNFORMATTED SKIP.
790 ASSIGN last-sequence = tb.SequenceCode
791 sequence-name = tb.SequenceName
792 ag-balance = 0 ag-budget = 0
793 ag-mtdbal = 0 ag-mtdbud = 0.
795 IF EntityCode <> last-property THEN DO:
796 property-desc = get-property-desc(EntityCode).
797 PUT UNFORMATTED '"' EntityCode '","' property-desc '"' SKIP.
798 last-property = EntityCode.
799 END.
800 END.
801 IF detail THEN DO:
802 IF EntityCode <> last-property THEN DO:
803 property-desc = get-property-desc(EntityCode).
804 PUT UNFORMATTED '"' EntityCode '","' property-desc '"' SKIP.
805 last-property = EntityCode.
806 END.
807 PUT UNFORMATTED '"","","'
808 tb.AccountCode '","'
809 tb.AccountName '","'
810 tb.Balance '","'
811 tb.Budget '","'
812 tb.mtd-Balance '","'
813 tb.mtd-Budget '","'
814 tb.Comment '"'
815 SKIP.
816 END.
817 ELSE ASSIGN
818 ag-balance = ag-balance + tb.Balance
819 ag-budget = ag-budget + tb.Budget
820 ag-mtdbal = ag-mtdbal + tb.mtd-Balance
821 ag-mtdbud = ag-mtdbud + tb.mtd-Budget .
822 END.
824 IF NOT detail AND last-sequence >= 0 THEN DO:
825 PUT UNFORMATTED '"","","'
826 last-sequence '","'
827 sequence-name '","'
828 ag-balance '","'
829 ag-budget '","'
830 ag-mtdbal '","'
831 ag-mtdbud '"'
832 SKIP.
833 END.
835 OUTPUT CLOSE.
837 MESSAGE 'File "' + csv-file-name + '" generated successfully.'
838 VIEW-AS ALERT-BOX INFORMATION TITLE "Property Trial Balance".
839 END PROCEDURE.
841 /* _UIB-CODE-BLOCK-END */
842 &ANALYZE-RESUME
844 &ENDIF
846 &IF DEFINED(EXCLUDE-normal-to-printer) = 0 &THEN
848 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE normal-to-printer Procedure
849 PROCEDURE normal-to-printer :
850 /*------------------------------------------------------------------------------
851 Purpose: Generate TB output to a print file
852 ------------------------------------------------------------------------------*/
853 DEF INPUT PARAMETER detail-report AS LOGICAL NO-UNDO.
854 DEF INPUT PARAMETER preview AS LOGICAL NO-UNDO.
856 DEF VAR last-sequence AS INT INITIAL -1 NO-UNDO.
857 DEF VAR sequence-name AS CHAR NO-UNDO.
858 DEF VAR last-property AS INT INITIAL -1 NO-UNDO.
860 DEF VAR bs-start-sequence LIKE AccountGroup.SequenceCode NO-UNDO.
861 FIND AccountGroup WHERE AccountGroup.AccountGroupCode = "SHCAP" NO-LOCK NO-ERROR.
862 IF NOT AVAILABLE(AccountGroup) THEN
863 FIND FIRST AccountGroup WHERE AccountGroup.GroupType = "B" NO-LOCK NO-ERROR.
864 IF NOT AVAILABLE(AccountGroup) THEN DO:
865 MESSAGE "Cannot locate first accountgroup with type" SKIP
866 "'B' as start of balance sheet accounts."
867 VIEW-AS ALERT-BOX ERROR TITLE "Account Groups not set up!".
868 RETURN.
869 END.
870 bs-start-sequence = AccountGroup.SequenceCode.
872 RUN output-control-file ( prt-ctrl ).
873 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE VALUE(rows).
875 FOR EACH tb BY EntityType BY EntityCode BY tb.SequenceCode BY AccountCode:
876 IF EntityCode <> last-property OR tb.SequenceCode <> last-sequence THEN DO:
877 IF last-sequence >= 0 THEN DO:
878 RUN print-a-line( detail-report, "", sequence-name, ag-balance, ag-budget, ag-mtdbal, ag-mtdbud, "" ).
879 END.
880 IF last-sequence < bs-start-sequence THEN DO:
881 ASSIGN
882 pl-balance = pl-balance + ag-balance
883 pl-budget = pl-budget + ag-budget
884 pl-mtdbal = pl-mtdbal + ag-mtdbal
885 pl-mtdbud = pl-mtdbud + ag-mtdbud
887 END.
888 ASSIGN last-sequence = tb.SequenceCode
889 sequence-name = tb.SequenceName
890 et-balance = et-balance + ag-balance
891 et-budget = et-budget + ag-budget
892 et-mtdbal = et-mtdbal + ag-mtdbal
893 et-mtdbud = et-mtdbud + ag-mtdbud
894 ag-balance = 0 ag-budget = 0
895 ag-mtdbal = 0 ag-mtdbud = 0.
896 END. /* IF new sequence */
898 IF EntityCode <> last-property THEN DO:
899 IF last-property > 0 THEN DO:
900 RUN print-a-line( Yes, "", get-property-desc(last-property), et-balance, et-budget, et-mtdbal, et-mtdbud, "" ).
901 IF detail-report THEN PUT SKIP (1).
902 RUN print-a-line( detail-report, "", " Profit or Loss", - pl-balance, - pl-budget, - pl-mtdbal, - pl-mtdbud, "" ).
903 END.
904 hline2 = rtypeString + " Property Trial Balance - "
905 + get-property-desc(EntityCode) + " - "
906 + Month.MonthName + ", " + STRING( YEAR(Month.StartDate), "9999").
907 hline2 = FILL(" ", INTEGER(({&page-width} - LENGTH(hline2)) / 2)) + hline2.
908 IF last-property > 0 THEN
909 PAGE.
910 ELSE
911 VIEW FRAME heading-frame.
913 IF NOT detail-report THEN VIEW FRAME account-line.
914 ASSIGN last-property = EntityCode
915 et-balance = 0 et-budget = 0
916 et-mtdbal = 0 et-mtdbud = 0
917 pl-balance = 0 pl-budget = 0
918 pl-mtdbal = 0 pl-mtdbud = 0.
919 END. /* if new property */
920 ASSIGN
921 ag-balance = ag-balance + tb.Balance
922 ag-budget = ag-budget + tb.Budget
923 ag-mtdbal = ag-mtdbal + tb.mtd-Balance
924 ag-mtdbud = ag-mtdbud + tb.mtd-Budget
926 IF detail-report AND
927 ( tb.Balance <> 0 OR tb.Budget <> 0
928 OR tb.mtd-Balance <> 0 OR tb.mtd-Budget <> 0 )
929 THEN DO:
930 RUN print-a-line( No, STRING( tb.AccountCode, "9999.99"), tb.AccountName,
931 tb.Balance, tb.Budget, tb.mtd-Balance, tb.mtd-Budget, tb.Comment).
932 END. /* detail-report */
933 END. /* each trial balance */
935 IF last-property > 0 OR consolidate-together THEN DO:
936 RUN print-a-line ( detail-report, "", sequence-name, ag-balance, ag-budget, ag-mtdbal, ag-mtdbud, "" ).
937 ASSIGN et-balance = et-balance + ag-balance
938 et-budget = et-budget + ag-budget
939 et-mtdbal = et-mtdbal + ag-mtdbal
940 et-mtdbud = et-mtdbud + ag-mtdbud.
941 IF last-sequence < bs-start-sequence THEN DO:
942 ASSIGN
943 pl-balance = pl-balance + ag-balance
944 pl-budget = pl-budget + ag-budget
945 pl-mtdbal = pl-mtdbal + ag-mtdbal
946 pl-mtdbud = pl-mtdbud + ag-mtdbud
948 END.
950 RUN print-a-line ( Yes, "", get-property-desc(last-property), et-balance, et-budget, et-mtdbal, et-mtdbud, "" ).
951 IF detail-report THEN PUT SKIP (1).
952 RUN print-a-line ( detail-report, "", " Profit or Loss", - pl-balance, - pl-budget, - pl-mtdbal, - pl-mtdbud, "" ).
953 END.
955 OUTPUT CLOSE.
956 debug-event("Finished").
957 RUN view-output-file( preview ).
959 END PROCEDURE.
961 /* _UIB-CODE-BLOCK-END */
962 &ANALYZE-RESUME
964 &ENDIF
966 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
968 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
969 PROCEDURE parse-parameters :
970 /*------------------------------------------------------------------------------
971 Purpose: Decode the command-line parameters
972 ------------------------------------------------------------------------------*/
973 DEF VAR i AS INT NO-UNDO.
974 DEF VAR token AS CHAR NO-UNDO.
976 {inc/showopts.i "report-options"}
978 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
979 token = ENTRY( i, report-options, "~n" ).
980 CASE( ENTRY( 1, token ) ):
981 WHEN "Debug" THEN debug-mode = Yes.
982 WHEN "ExcludeYearEnd" THEN exclude-year-end = Yes.
983 WHEN "Consolidated" THEN consolidate-together = Yes.
984 WHEN "Pedantic" THEN pedantic-listing = Yes.
985 WHEN "ColumnStyle" THEN column-style = ENTRY(2,token).
986 WHEN "ReportType" THEN r-type = ENTRY(2,token).
987 WHEN "SelectionType" THEN range = ENTRY(2,token).
988 WHEN "OutputType" THEN out-to = ENTRY(2,token).
989 WHEN "EntityList" THEN list-name = ENTRY(2,token).
990 WHEN "EndMonth" THEN month-2 = INT( ENTRY(2,token) ).
991 WHEN "FileName" THEN csv-file-name = TRIM( SUBSTRING(token, LENGTH(ENTRY(1,token)) + 2) ).
992 WHEN "StartMonth" THEN ASSIGN
993 month-range = Yes
994 month-1 = INT( ENTRY(2,token) ).
995 WHEN "EntityRange" THEN ASSIGN
996 entity-1 = INT(ENTRY(2,token))
997 entity-2 = INT(ENTRY(3,token)) .
998 END CASE.
999 END.
1001 IF NOT( month-range ) THEN DO:
1002 FIND Month WHERE Month.MonthCode = month-2 NO-LOCK.
1003 month-1 = Month.FinancialYearCode.
1004 FIND FIRST Month WHERE month-1 = Month.FinancialYearCode NO-LOCK.
1005 month-1 = Month.MonthCode.
1006 END.
1008 END PROCEDURE.
1010 /* _UIB-CODE-BLOCK-END */
1011 &ANALYZE-RESUME
1013 &ENDIF
1015 &IF DEFINED(EXCLUDE-print-a-line) = 0 &THEN
1017 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-a-line Procedure
1018 PROCEDURE print-a-line :
1019 /*------------------------------------------------------------------------------
1020 Purpose: Display a line with preceding dashes if required.
1021 ------------------------------------------------------------------------------*/
1022 DEF INPUT PARAMETER display-minuses AS LOGICAL NO-UNDO.
1023 DEF INPUT PARAMETER account AS CHAR NO-UNDO.
1024 DEF INPUT PARAMETER name AS CHAR NO-UNDO.
1025 DEF INPUT PARAMETER bal AS DECIMAL NO-UNDO.
1026 DEF INPUT PARAMETER bud AS DECIMAL NO-UNDO.
1027 DEF INPUT PARAMETER mbl AS DECIMAL NO-UNDO.
1028 DEF INPUT PARAMETER mbd AS DECIMAL NO-UNDO.
1029 DEF INPUT PARAMETER comment AS CHAR NO-UNDO.
1031 DEF VAR line AS CHAR NO-UNDO.
1032 DEF VAR pre-comment AS CHAR NO-UNDO INITIAL " ".
1034 IF display-minuses THEN DO:
1035 PUT UNFORMATTED minus-line + pre-comment + ENTRY( 1, remaining-comments, "~n") SKIP.
1036 IF INDEX( remaining-comments, "~n") > 0 THEN
1037 remaining-comments = SUBSTRING( remaining-comments, INDEX( remaining-comments, "~n") + 1).
1038 ELSE
1039 remaining-comments = "".
1040 END.
1042 IF TRIM(comment) <> "" AND comment <> ? THEN DO:
1043 DO WHILE TRIM(remaining-comments) <> "":
1044 line = FILL( " ", col-width) + pre-comment + ENTRY( 1, remaining-comments, "~n").
1045 PUT UNFORMATTED line SKIP.
1046 IF INDEX( remaining-comments, "~n") > 0 THEN
1047 remaining-comments = SUBSTRING( remaining-comments, INDEX( remaining-comments, "~n") + 1).
1048 ELSE
1049 remaining-comments = "".
1050 END.
1051 remaining-comments = WRAP( comment, 205 - col-width).
1052 pre-comment = " ".
1053 END.
1055 IF column-style = "Std" THEN
1056 line = STRING( account, "X(8)") + STRING( name, "X(51)")
1057 + STRING( bal, money-format ) + " " + STRING( bud, money-format ) + " "
1058 + STRING( bal - bud, money-format ) + " "
1059 + STRING( mbl, money-format ) + " " + STRING( mbd, money-format ) + " "
1060 + STRING( mbl - mbd, money-format )
1061 + pre-comment + ENTRY( 1, remaining-comments, "~n").
1062 ELSE
1063 line = STRING( account, "X(8)") + STRING( name, "X(51)")
1064 + STRING( bal, money-format ) + " "
1065 + STRING( bal - mbl, money-format ) + " "
1066 + STRING( mbl, money-format ) + " " + STRING( mbd, money-format ) + " "
1067 + STRING( mbl - mbd, money-format )
1068 + pre-comment + ENTRY( 1, remaining-comments, "~n").
1069 PUT UNFORMATTED line SKIP.
1071 IF INDEX( remaining-comments, "~n") > 0 THEN
1072 remaining-comments = SUBSTRING( remaining-comments, INDEX( remaining-comments, "~n") + 1).
1073 ELSE
1074 remaining-comments = "".
1076 IF display-minuses THEN DO:
1077 pre-comment = " ".
1078 PUT UNFORMATTED FILL( " ", col-width) + pre-comment + ENTRY( 1, remaining-comments, "~n") SKIP.
1079 IF INDEX( remaining-comments, "~n") > 0 THEN
1080 remaining-comments = SUBSTRING( remaining-comments, INDEX( remaining-comments, "~n") + 1).
1081 ELSE
1082 remaining-comments = "".
1083 END.
1085 END PROCEDURE.
1087 /* _UIB-CODE-BLOCK-END */
1088 &ANALYZE-RESUME
1090 &ENDIF
1092 /* ************************ Function Implementations ***************** */
1094 &IF DEFINED(EXCLUDE-balance-from-balances) = 0 &THEN
1096 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION balance-from-balances Procedure
1097 FUNCTION balance-from-balances RETURNS DECIMAL
1098 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT m-1 AS INT, INPUT m-n AS INT ) :
1099 /*------------------------------------------------------------------------------
1100 Purpose: Calculate balance at a particular date by adding a range of months
1101 Notes: Applies to I&E (P&L) accounts
1102 ------------------------------------------------------------------------------*/
1103 DEF VAR bal AS DEC NO-UNDO INITIAL 0.00 .
1105 DEF BUFFER MyBalance FOR AccountBalance.
1106 FOR EACH MyBalance WHERE MyBalance.EntityType = et
1107 AND MyBalance.EntityCode = ec
1108 AND MyBalance.AccountCode = ac
1109 AND MyBalance.MonthCode >= m-1
1110 AND MyBalance.MonthCode <= m-n NO-LOCK:
1111 bal = bal + MyBalance.Balance.
1112 END.
1114 RETURN bal.
1116 END FUNCTION.
1118 /* _UIB-CODE-BLOCK-END */
1119 &ANALYZE-RESUME
1121 &ENDIF
1123 &IF DEFINED(EXCLUDE-balance-from-summary) = 0 &THEN
1125 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION balance-from-summary Procedure
1126 FUNCTION balance-from-summary RETURNS DECIMAL
1127 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT mnth AS INT ) :
1128 /*------------------------------------------------------------------------------
1129 Purpose: Calculate balance at a particular date by subtracting backwards
1130 Notes: Applies to balance sheet accounts
1131 ------------------------------------------------------------------------------*/
1132 DEF VAR bal AS DEC NO-UNDO INITIAL 0.00 .
1134 DEF BUFFER MySummary FOR AccountSummary.
1135 FIND MySummary WHERE MySummary.EntityType = et
1136 AND MySummary.EntityCode = ec
1137 AND MySummary.AccountCode = ac NO-LOCK NO-ERROR.
1138 IF AVAILABLE(MySummary) THEN bal = MySummary.Balance.
1140 DEF BUFFER MyBalance FOR AccountBalance.
1141 FOR EACH MyBalance WHERE MyBalance.EntityType = et
1142 AND MyBalance.EntityCode = ec
1143 AND MyBalance.AccountCode = ac
1144 AND MyBalance.MonthCode > mnth NO-LOCK:
1145 bal = bal - MyBalance.Balance.
1146 END.
1148 RETURN bal.
1150 END FUNCTION.
1152 /* _UIB-CODE-BLOCK-END */
1153 &ANALYZE-RESUME
1155 &ENDIF
1157 &IF DEFINED(EXCLUDE-debug-event) = 0 &THEN
1159 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION debug-event Procedure
1160 FUNCTION debug-event RETURNS CHARACTER
1161 ( INPUT event-text AS CHAR ) :
1162 /*------------------------------------------------------------------------------
1163 Purpose:
1164 Notes:
1165 ------------------------------------------------------------------------------*/
1166 IF NOT debug-mode THEN RETURN event-text.
1168 DEF VAR time-text AS CHAR NO-UNDO.
1170 time-text = STRING( TODAY, "99/99/9999") + " " + STRING( TIME, "HH:MM:SS") + ": ".
1171 PUT STREAM debug-stream UNFORMATTED time-text event-text SKIP.
1172 RETURN time-text + event-text.
1174 END FUNCTION.
1176 /* _UIB-CODE-BLOCK-END */
1177 &ANALYZE-RESUME
1179 &ENDIF
1181 &IF DEFINED(EXCLUDE-get-balance) = 0 &THEN
1183 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-balance Procedure
1184 FUNCTION get-balance RETURNS DECIMAL
1185 ( INPUT et AS CHAR, INPUT ec AS INT, INPUT ac AS DEC, INPUT month-n AS INT ) :
1186 /*------------------------------------------------------------------------------
1187 Purpose:
1188 Notes:
1189 ------------------------------------------------------------------------------*/
1190 DEF BUFFER MyChart FOR ChartOfAccount.
1192 DEF VAR type AS CHAR INITIAL "B" NO-UNDO.
1194 FIND MyChart WHERE MyChart.AccountCode = ac NO-LOCK NO-ERROR.
1195 IF AVAILABLE(MyChart) THEN FIND AccountGroup OF MyChart NO-LOCK NO-ERROR.
1196 IF AVAILABLE(AccountGroup) THEN type = AccountGroup.GroupType.
1198 IF type = "B" THEN
1199 RETURN balance-from-summary( et, ec, ac, month-n ).
1200 ELSE
1201 RETURN balance-from-balances( et, ec, ac, month-1, month-n ).
1203 END FUNCTION.
1205 /* _UIB-CODE-BLOCK-END */
1206 &ANALYZE-RESUME
1208 &ENDIF
1210 &IF DEFINED(EXCLUDE-get-property-desc) = 0 &THEN
1212 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-property-desc Procedure
1213 FUNCTION get-property-desc RETURNS CHARACTER
1214 ( INPUT ec AS INT ) :
1215 /*------------------------------------------------------------------------------
1216 Purpose:
1217 Notes:
1218 ------------------------------------------------------------------------------*/
1219 DEF BUFFER AltP FOR Property.
1221 IF consolidate-together THEN DO:
1222 RETURN "Consolidation of " + (IF range = entity-type THEN list-name ELSE STRING(entity-1) + " to " + STRING(entity-2)).
1223 END.
1224 FIND FIRST AltP WHERE AltP.PropertyCode = ec NO-LOCK.
1225 RETURN AltP.Name + " ("+ STRING(AltP.PropertyCode) + ")".
1227 END FUNCTION.
1229 /* _UIB-CODE-BLOCK-END */
1230 &ANALYZE-RESUME
1232 &ENDIF