Add blank column, rename column.
[capital-apms-progress.git] / process / report / tr-j.p
blob4382e2b2ff9cef63a4532caa3a19aa5ec36f016d
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File : tr-j.p
6 Purpose : Transactions by Project Account report
7 Author(s) : Andrew McMillan
8 ------------------------------------------------------------------------*/
9 /* *************************** Definitions ************************** */
11 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
13 DEF VAR project-1 LIKE AcctTran.EntityCode NO-UNDO.
14 DEF VAR project-2 LIKE AcctTran.EntityCode NO-UNDO.
15 DEF VAR month-1 AS INTEGER FORMAT "9999" NO-UNDO.
16 DEF VAR month-2 AS INTEGER FORMAT "9999" 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 export-fname AS CHAR NO-UNDO.
21 DEF VAR traverse-hierarchy AS LOGICAL NO-UNDO INITIAL No.
22 DEF VAR show-relations AS LOGICAL NO-UNDO INITIAL Yes.
24 DEF VAR show-month-totals AS LOGICAL INITIAL no NO-UNDO.
25 DEF VAR base-entity-type AS CHAR INITIAL "J" NO-UNDO. /* The basic entity we deal with */
26 DEF VAR sort-entity-type AS CHAR NO-UNDO. /* The sequence for output */
27 RUN parse-parameters.
29 DEF VAR project-depth AS INT NO-UNDO INITIAL 0.
30 DEF VAR prt-ctrl AS CHAR NO-UNDO.
31 DEF VAR rows AS INT NO-UNDO.
32 DEF VAR cols AS INT NO-UNDO.
34 DEF VAR grand-total LIKE AcctTran.Amount INITIAL 0 NO-UNDO.
36 DEF VAR user-name AS CHAR NO-UNDO.
37 {inc/username.i "user-name"}
38 DEF VAR timeStamp AS CHAR FORMAT "X(54)" NO-UNDO.
39 DEF VAR dispReference AS CHARACTER COLUMN-LABEL "Reference" FORMAT "x(13)" NO-UNDO.
40 DEF VAR dispDescription AS CHARACTER NO-UNDO.
41 DEF VAR dispAmount AS CHARACTER FORMAT "X(16)" NO-UNDO.
42 DEF VAR dispName AS CHARACTER FORMAT "X(80)" NO-UNDO.
43 DEF VAR tr-this-month AS LOGICAL NO-UNDO.
44 DEF VAR tr-this-project AS LOGICAL NO-UNDO.
45 DEF VAR tr-this-account AS LOGICAL NO-UNDO.
46 DEF VAR project-total LIKE AcctTran.Amount NO-UNDO.
47 DEF VAR account-total LIKE AcctTran.Amount NO-UNDO.
48 DEF VAR money-format AS CHAR INITIAL ">>>,>>>,>>9.99CR" NO-UNDO.
50 DEF VAR m1-start AS DATE NO-UNDO.
51 DEF VAR m2-end AS DATE NO-UNDO.
53 FIND Month WHERE Month.MonthCode = month-1 NO-LOCK.
54 m1-start = Month.StartDate.
56 FIND Month WHERE Month.MonthCode = month-2 NO-LOCK.
57 m2-end = Month.EndDate.
59 &SCOPED-DEFINE page-width 126
60 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
61 DEF VAR hline2 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
62 DEF VAR hline3 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
63 hline2 = "Transactions for Project " + STRING(project-1,"99999") +
64 " to " + STRING(project-2,"99999") +
65 ", from " + STRING( m1-start, "99/99/9999") +
66 " to " + STRING( m2-end, "99/99/9999").
67 hline2 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
69 hline3 = "Accounts " + STRING(account-1, "9999.99") + " to " + STRING(account-2, "9999.99").
70 hline3 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline3) ) / 2)) + hline3.
72 /* define all the frames for the report */
73 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
75 DEFINE FRAME default-frame WITH DOWN {&with-clause}.
77 DEFINE FRAME heading-frame WITH 1 DOWN {&with-clause} PAGE-TOP.
78 FORM HEADER
79 timeStamp "Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
80 hline2 FORMAT "X({&page-width})"
81 hline3 FORMAT "X({&page-width})"
82 SKIP (2) " Date Reference Amount Description" SPACE(40) "Related records"
83 WITH FRAME heading-frame.
85 DEFINE FRAME total-frame-1 WITH DOWN {&with-clause}.
86 FORM
87 SPACE(14)
88 dispReference
89 dispAmount
90 dispName
91 WITH FRAME total-frame-1.
93 DEFINE FRAME report-frame-1 WITH DOWN {&with-clause}.
94 FORM
95 SKIP(1)
96 dispName
97 WITH FRAME report-frame-1.
100 DEFINE FRAME report-frame-2 WITH DOWN {&with-clause}.
101 FORM
103 AcctTran.Date COLUMN-LABEL "Date" FORMAT "99/99/9999"
104 dispReference
105 AcctTran.Amount COLUMN-LABEL "Amount" FORMAT ">>>,>>>,>>9.99CR"
106 dispDescription COLUMN-LABEL "Description" FORMAT "X(81)"
107 WITH FRAME report-frame-2.
109 /* _UIB-CODE-BLOCK-END */
110 &ANALYZE-RESUME
113 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
115 /* ******************** Preprocessor Definitions ******************** */
117 &Scoped-define PROCEDURE-TYPE Procedure
118 &Scoped-define DB-AWARE no
122 /* _UIB-PREPROCESSOR-BLOCK-END */
123 &ANALYZE-RESUME
127 /* *********************** Procedure Settings ************************ */
129 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
130 /* Settings for THIS-PROCEDURE
131 Type: Procedure
132 Allow:
133 Frames: 0
134 Add Fields to: Neither
135 Other Settings: CODE-ONLY COMPILE
137 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
139 /* ************************* Create Window ************************** */
141 &ANALYZE-SUSPEND _CREATE-WINDOW
142 /* DESIGN Window definition (used by the UIB)
143 CREATE WINDOW Procedure ASSIGN
144 HEIGHT = 23
145 WIDTH = 35.72.
146 /* END WINDOW DEFINITION */
148 &ANALYZE-RESUME
150 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
151 /* ************************* Included-Libraries *********************** */
153 {inc/method/m-txtrep.i}
155 /* _UIB-CODE-BLOCK-END */
156 &ANALYZE-RESUME
162 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
165 /* *************************** Main Block *************************** */
166 IF export-fname = "" THEN DO:
167 RUN make-control-string ( "PCL", "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9",
168 OUTPUT prt-ctrl, OUTPUT rows, OUTPUT cols ).
170 RUN output-control-file ( prt-ctrl ).
171 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE VALUE(rows).
173 VIEW FRAME heading-frame.
174 END.
175 ELSE DO:
176 OUTPUT TO VALUE(export-fname) KEEP-MESSAGES .
177 PUT UNFORMATTED '"Batch","Doc","Trn","Type","Entity","Account","Reference","Date","Amount","Narrative","Related records","Flag","Flagged By"' SKIP .
178 END.
180 IF traverse-hierarchy THEN DO:
181 FIND Project WHERE Project.ProjectCode = project-1 NO-LOCK.
182 RUN disp-entity-project.
183 DISPLAY dispName WITH FRAME report-frame-1.
184 DOWN WITH FRAME report-frame-1.
185 RUN project-by-hierarchy( project-1, account-1, account-2 ).
186 IF RETURN-VALUE = "Yes" THEN DO:
187 RUN disp-entity-project.
188 RUN disp-totals( project-total ).
189 grand-total = grand-total + project-total.
190 END.
191 END.
192 ELSE IF sort-entity-type <> base-entity-type THEN DO:
193 FOR EACH ProjectBudget NO-LOCK
194 WHERE ProjectBudget.AccountCode >= account-1 AND ProjectBudget.AccountCode <= account-2
195 BY ProjectBudget.AccountCode:
196 RUN each-account-by-account.
197 END.
198 END.
199 ELSE DO:
200 FOR EACH Project NO-LOCK
201 WHERE Project.ProjectCode >= project-1 AND Project.ProjectCode <= project-2
202 BY Project.ProjectCode:
203 RUN each-project-by-project.
204 END.
205 END.
208 IF export-fname = "" THEN DO:
209 PUT SKIP (2).
210 dispName = "Entire report".
211 RUN disp-totals(grand-total).
212 OUTPUT CLOSE.
213 RUN view-output-file( preview ).
214 END.
215 ELSE
216 OUTPUT CLOSE.
218 /* _UIB-CODE-BLOCK-END */
219 &ANALYZE-RESUME
222 /* ********************** Internal Procedures *********************** */
224 &IF DEFINED(EXCLUDE-check-non-zero) = 0 &THEN
226 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-non-zero Procedure
227 PROCEDURE check-non-zero :
228 /*------------------------------------------------------------------------------
229 Purpose: Check the balance of the account over the period. If it is 0, then
230 return the string "ZERO".
231 ------------------------------------------------------------------------------*/
232 DEF VAR bal-total AS DEC INITIAL 0 NO-UNDO.
234 FOR EACH AccountBalance NO-LOCK
235 WHERE AccountBalance.EntityType = base-entity-type
236 AND AccountBalance.EntityCode = Project.ProjectCode
237 AND AccountBalance.AccountCode = ProjectBudget.AccountCode
238 AND AccountBalance.MonthCode <= month-2:
239 bal-total = bal-total + AccountBalance.Balance.
240 END.
242 IF bal-total = 0 THEN RETURN "ZERO".
244 END PROCEDURE.
246 /* _UIB-CODE-BLOCK-END */
247 &ANALYZE-RESUME
249 &ENDIF
251 &IF DEFINED(EXCLUDE-disp-entity-account) = 0 &THEN
253 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-entity-account Procedure
254 PROCEDURE disp-entity-account :
255 /*------------------------------------------------------------------------------
256 Purpose: Set the dispEntityName variable to the current account.
257 ------------------------------------------------------------------------------*/
258 dispName = STRING(ProjectBudget.AccountCode, "9999.99") + ", " +
259 ProjectBudget.Description.
260 END PROCEDURE.
262 /* _UIB-CODE-BLOCK-END */
263 &ANALYZE-RESUME
265 &ENDIF
267 &IF DEFINED(EXCLUDE-disp-entity-project) = 0 &THEN
269 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-entity-project Procedure
270 PROCEDURE disp-entity-project :
271 /*------------------------------------------------------------------------------
272 Purpose: Set the dispEntityName variable to the current project.
273 ------------------------------------------------------------------------------*/
274 dispName = Project.Name
275 + " (" + STRING(Project.ProjectCode, "99999") + ") - Parent: "
276 + Project.EntityType + TRIM(STRING(Project.EntityCode,">>>>9")) .
277 END PROCEDURE.
279 /* _UIB-CODE-BLOCK-END */
280 &ANALYZE-RESUME
282 &ENDIF
284 &IF DEFINED(EXCLUDE-disp-totals) = 0 &THEN
286 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-totals Procedure
287 PROCEDURE disp-totals :
288 /*------------------------------------------------------------------------------
289 Purpose:
290 Parameters: <none>
291 Notes:
292 ------------------------------------------------------------------------------*/
293 DEF INPUT PARAMETER disp-total AS DECIMAL NO-UNDO.
295 IF export-fname <> "" THEN RETURN.
297 DISPLAY " " @ dispReference
298 " ----------" @ dispAmount
299 " " @ dispName
300 WITH FRAME total-frame-1.
301 DOWN WITH FRAME total-frame-1.
302 DISPLAY dispName
303 "Total" @ dispReference
304 STRING( disp-total, money-format) @ dispAmount
305 WITH FRAME total-frame-1.
306 DOWN WITH FRAME total-frame-1.
308 END PROCEDURE.
310 /* _UIB-CODE-BLOCK-END */
311 &ANALYZE-RESUME
313 &ENDIF
315 &IF DEFINED(EXCLUDE-display-headings-if-needed) = 0 &THEN
317 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE display-headings-if-needed Procedure
318 PROCEDURE display-headings-if-needed :
319 /*------------------------------------------------------------------------------
320 Purpose: If this is the first transaction for an account or project (or both)
321 we need to display the appropriate headings.
322 ------------------------------------------------------------------------------*/
324 IF export-fname <> "" THEN RETURN.
326 /* For the major sort sequence */
327 IF NOT tr-this-project AND sort-entity-type = base-entity-type THEN DO:
328 IF NOT traverse-hierarchy THEN DO:
329 RUN disp-entity-project.
330 DISPLAY dispName WITH FRAME report-frame-1.
331 DOWN WITH FRAME report-frame-1.
332 END.
333 tr-this-project = yes.
334 END.
335 ELSE IF NOT tr-this-account AND sort-entity-type = "A" THEN DO:
336 RUN disp-entity-account.
337 DISPLAY dispName WITH FRAME report-frame-1.
338 DOWN WITH FRAME report-frame-1.
339 tr-this-account = yes.
340 END.
342 /* For the minor sort sequence */
343 IF NOT tr-this-project THEN DO:
344 RUN disp-entity-project.
345 DISPLAY dispName WITH FRAME report-frame-1.
346 DOWN WITH FRAME report-frame-1.
347 tr-this-project = yes.
348 END.
349 ELSE IF NOT tr-this-account THEN DO:
350 IF NOT traverse-hierarchy THEN RUN disp-entity-account.
351 DISPLAY dispName WITH FRAME report-frame-1.
352 DOWN WITH FRAME report-frame-1.
353 tr-this-account = yes.
354 END.
356 END PROCEDURE.
358 /* _UIB-CODE-BLOCK-END */
359 &ANALYZE-RESUME
361 &ENDIF
363 &IF DEFINED(EXCLUDE-each-account) = 0 &THEN
365 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-account Procedure
366 PROCEDURE each-account :
367 /*------------------------------------------------------------------------------
368 Purpose: Display transactions for a single account
369 ------------------------------------------------------------------------------*/
370 DEF INPUT PARAMETER ec AS INT NO-UNDO.
371 DEF INPUT PARAMETER ac AS DEC NO-UNDO.
373 RUN show-opening-balance( ec, ac).
375 FOR EACH AccountBalance NO-LOCK
376 WHERE AccountBalance.EntityType = base-entity-type
377 AND AccountBalance.EntityCode = ec
378 AND AccountBalance.AccountCode = ac
379 AND AccountBalance.MonthCode >= month-1
380 AND AccountBalance.MonthCode <= month-2,
381 FIRST Month OF AccountBalance NO-LOCK:
383 tr-this-month = no.
384 FOR EACH AcctTran NO-LOCK OF AccountBalance,
385 FIRST Document NO-LOCK OF AcctTran WHERE
386 BY AcctTran.EntityType BY AcctTran.EntityCode BY AcctTran.AccountCode
387 BY AcctTran.MonthCode BY AcctTran.Date
388 BY AcctTran.BatchCode BY AcctTran.DocumentCode BY AcctTran.TransactionCode
390 RUN each-transaction.
391 END.
392 END.
394 END PROCEDURE.
396 /* _UIB-CODE-BLOCK-END */
397 &ANALYZE-RESUME
399 &ENDIF
401 &IF DEFINED(EXCLUDE-each-account-by-account) = 0 &THEN
403 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-account-by-account Procedure
404 PROCEDURE each-account-by-account :
405 /*------------------------------------------------------------------------------
406 Purpose: Loop for all companies within an account
407 ------------------------------------------------------------------------------*/
409 ASSIGN
410 account-total = 0
411 tr-this-account = no
413 FOR EACH Project NO-LOCK WHERE Project.ProjectCode >= project-1
414 AND Project.ProjectCode <= project-2
415 AND CAN-FIND( FIRST AcctTran
416 WHERE AcctTran.EntityType = base-entity-type
417 AND AcctTran.EntityCode = Project.ProjectCode
418 AND AcctTran.AccountCode = ProjectBudget.AccountCode
419 AND AcctTran.MonthCode <= month-2 ) :
420 ASSIGN
421 project-total = 0
422 tr-this-project = no
425 RUN each-account( ProjectBudget.ProjectCode, ProjectBudget.AccountCode).
427 IF tr-this-project THEN DO:
428 RUN disp-entity-project.
429 RUN disp-totals( project-total ).
430 END.
431 END.
433 IF tr-this-account THEN DO:
434 RUN disp-entity-account.
435 RUN disp-totals( account-total ).
436 grand-total = grand-total + account-total.
437 END.
439 END PROCEDURE.
441 /* _UIB-CODE-BLOCK-END */
442 &ANALYZE-RESUME
444 &ENDIF
446 &IF DEFINED(EXCLUDE-each-project-by-project) = 0 &THEN
448 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-project-by-project Procedure
449 PROCEDURE each-project-by-project :
450 /*------------------------------------------------------------------------------
451 Purpose: Loop for all accounts of project
452 ------------------------------------------------------------------------------*/
454 ASSIGN project-total = 0
455 tr-this-project = no .
457 FOR EACH ProjectBudget NO-LOCK OF Project
458 WHERE ProjectBudget.AccountCode >= account-1
459 AND ProjectBudget.AccountCode <= account-2
460 AND CAN-FIND( FIRST AcctTran
461 WHERE AcctTran.EntityType = base-entity-type
462 AND AcctTran.EntityCode = Project.ProjectCode
463 AND AcctTran.AccountCode = ProjectBudget.AccountCode
464 AND AcctTran.MonthCode <= month-2 ) :
466 ASSIGN account-total = 0
467 tr-this-account = no .
469 RUN each-account( ProjectBudget.ProjectCode, ProjectBudget.AccountCode).
471 IF tr-this-account THEN DO:
472 RUN disp-entity-account.
473 RUN disp-totals( account-total ).
474 END.
475 END.
477 IF tr-this-project THEN DO:
478 RUN disp-entity-project.
479 RUN disp-totals( project-total ).
480 grand-total = grand-total + project-total.
481 END.
483 END PROCEDURE.
485 /* _UIB-CODE-BLOCK-END */
486 &ANALYZE-RESUME
488 &ENDIF
490 &IF DEFINED(EXCLUDE-each-transaction) = 0 &THEN
492 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-transaction Procedure
493 PROCEDURE each-transaction :
494 /*------------------------------------------------------------------------------
495 Purpose:
496 ------------------------------------------------------------------------------*/
497 DEF VAR ChequeStr AS CHAR FORMAT "X(10)" INIT '' NO-UNDO.
499 RUN display-headings-if-needed.
501 ASSIGN
502 dispReference = STRING( (IF (AcctTran.Reference = "") THEN (Document.Reference) ELSE (AcctTran.Reference) ), "X(12)" )
503 + ( IF (AcctTran.ClosingGroup > 0) THEN "*" ELSE " " )
504 dispDescription = IF (AcctTran.Description = "") THEN (Document.Description) ELSE (AcctTran.Description)
505 tr-this-month = yes .
507 IF show-relations THEN DO:
508 IF SUBSTRING(dispReference, 1, 3) = "INV" THEN DO:
509 FIND Invoice WHERE Invoice.InvoiceNo = INT( SUBSTRING(dispReference, 4)) NO-LOCK NO-ERROR.
510 IF AVAILABLE(Invoice) THEN DO:
511 dispDescription = STRING( dispDescription, "X(51)").
512 IF Invoice.EntityType = "T" THEN DO:
513 FIND Tenant WHERE Tenant.TenantCode = Invoice.EntityCode NO-LOCK NO-ERROR.
514 dispDescription = dispDescription
515 + Invoice.EntityType + STRING(Invoice.EntityCode)
516 + (IF AVAILABLE(Tenant) THEN " " + Tenant.Name ELSE "").
517 END.
518 ELSE
519 dispDescription = dispDescription + Invoice.EntityType + STRING(Invoice.EntityCode).
520 END.
521 END.
522 ELSE IF SUBSTRING(dispReference, 1, 4) = "VCHR" THEN DO:
523 FIND Voucher WHERE Voucher.VoucherSeq = INT( SUBSTRING(dispReference, 5)) NO-LOCK NO-ERROR.
524 IF AVAILABLE(Voucher) THEN DO:
525 FIND Creditor OF Voucher NO-LOCK NO-ERROR.
526 IF Voucher.ChequeNo <> 0 AND Voucher.ChequeNo <> ?
527 THEN ChequeStr = "CHQ" + TRIM(STRING(Voucher.ChequeNo)) + ", ".
528 ELSE ChequeStr = ''.
529 dispDescription = STRING( dispDescription, "X(51)")
530 + ChequeStr
531 + "C" + STRING(Voucher.CreditorCode)
532 + (IF AVAILABLE(Creditor) THEN " " + Creditor.Name ELSE "").
533 END.
534 END.
535 END.
537 IF export-fname <> "" THEN RUN export-transaction .
538 ELSE DO:
539 DISPLAY
540 AcctTran.Date
541 dispReference
542 AcctTran.Amount
543 dispDescription
544 WITH FRAME report-frame-2.
546 DOWN WITH FRAME report-frame-2.
547 END.
549 ASSIGN account-total = account-total + AcctTran.Amount
550 project-total = project-total + AcctTran.Amount .
552 END PROCEDURE.
554 /* _UIB-CODE-BLOCK-END */
555 &ANALYZE-RESUME
557 &ENDIF
559 &IF DEFINED(EXCLUDE-each-volume-account) = 0 &THEN
561 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-volume-account Procedure
562 PROCEDURE each-volume-account :
563 /*------------------------------------------------------------------------------
564 Purpose: Display balance only for a high-volume account
565 ------------------------------------------------------------------------------*/
566 DEF VAR transaction-total AS DECIMAL NO-UNDO.
568 transaction-total = 0.
569 FOR EACH AccountBalance NO-LOCK
570 WHERE AccountBalance.EntityType = base-entity-type
571 AND AccountBalance.EntityCode = Project.ProjectCode
572 AND AccountBalance.AccountCode = ProjectBudget.AccountCode
573 AND AccountBalance.MonthCode >= month-1
574 AND AccountBalance.MonthCode <= month-2,
575 FIRST Month OF AccountBalance NO-LOCK
578 tr-this-month = no.
579 FOR EACH AcctTran NO-LOCK OF AccountBalance, FIRST Document NO-LOCK OF AcctTran
580 BY AcctTran.EntityType BY AcctTran.EntityCode BY AcctTran.AccountCode
581 BY AcctTran.MonthCode BY AcctTran.Date
582 BY AcctTran.BatchCode BY AcctTran.DocumentCode BY AcctTran.TransactionCode
584 ASSIGN
585 tr-this-month = yes
586 transaction-total = transaction-total + AcctTran.Amount
588 END.
589 END.
591 ASSIGN
592 account-total = account-total + transaction-total
593 project-total = project-total + transaction-total
596 RUN display-headings-if-needed.
598 IF export-fname = "" THEN DO:
599 DISPLAY
600 m2-end @ AcctTran.Date
601 " " @ dispReference
602 transaction-total @ AcctTran.Amount
603 "Sum of transactions in period" @ dispDescription
604 WITH FRAME report-frame-2.
606 DOWN WITH FRAME report-frame-2.
607 END.
609 END PROCEDURE.
611 /* _UIB-CODE-BLOCK-END */
612 &ANALYZE-RESUME
614 &ENDIF
616 &IF DEFINED(EXCLUDE-export-transaction) = 0 &THEN
618 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE export-transaction Procedure
619 PROCEDURE export-transaction :
620 /*------------------------------------------------------------------------------
621 Purpose:
622 Parameters: <none>
623 Notes:
624 ------------------------------------------------------------------------------*/
625 DEF VAR FlagBy AS CHAR INITIAL "" NO-UNDO.
627 FIND Person WHERE Person.PersonCode = AcctTran.FlaggedBy NO-LOCK NO-ERROR.
628 IF AVAILABLE(Person) THEN
629 FlagBy = Person.FirstName + " " + Person.LastName.
631 PUT UNFORMATTED
632 AcctTran.BatchCode ','
633 AcctTran.DocumentCode ','
634 AcctTran.TransactionCode ',"'
635 AcctTran.EntityType '",'
636 AcctTran.EntityCode ','
637 AcctTran.AccountCode ',"'
638 dispReference '","'
639 AcctTran.Date '",'
640 AcctTran.Amount ',"'
641 TRIM( SUBSTRING(dispDescription,1,50)) '","'
642 TRIM( SUBSTRING(dispDescription,51)) '","'
643 AcctTran.FlagAttention '","'
644 FlagBy '"'
645 SKIP .
646 END PROCEDURE.
648 /* _UIB-CODE-BLOCK-END */
649 &ANALYZE-RESUME
651 &ENDIF
653 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
655 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
656 PROCEDURE parse-parameters :
657 /*------------------------------------------------------------------------------
658 Purpose:
659 ------------------------------------------------------------------------------*/
660 DEF VAR some-options AS CHAR NO-UNDO.
661 DEF VAR complex-options AS CHAR NO-UNDO.
663 complex-options = SUBSTRING( report-options, INDEX( report-options, "~n") + 1).
664 report-options = ENTRY( 1, report-options, "~n").
666 traverse-hierarchy = (ENTRY( 1, report-options ) = "H").
667 sort-entity-type = ENTRY( 3, report-options ).
668 project-1 = INTEGER( ENTRY( 4, report-options )).
669 project-2 = INTEGER( ENTRY( 5, report-options )).
670 month-1 = INTEGER( ENTRY( 6, report-options )).
671 month-2 = INTEGER( ENTRY( 7, report-options )).
672 account-1 = DECIMAL( ENTRY( 8, report-options )).
673 account-2 = DECIMAL( ENTRY( 9, report-options )).
674 preview = (ENTRY(10, report-options ) = "Yes").
675 export-fname = ENTRY(11, report-options ).
677 IF traverse-hierarchy THEN DO:
678 MESSAGE "Hierarchy traversing not yet working" VIEW-AS ALERT-BOX INFORMATION.
679 traverse-hierarchy = No.
680 END.
682 /* Now detail to the complex options string */
683 DEF VAR i AS INT NO-UNDO.
684 DEF VAR token AS CHAR NO-UNDO.
686 DO i = 1 TO NUM-ENTRIES( complex-options, "~n" ):
687 token = ENTRY( i, complex-options, "~n" ).
688 CASE( ENTRY( 1, token ) ):
689 WHEN "NoRelations" THEN show-relations = No.
690 END CASE.
691 END.
693 END PROCEDURE.
695 /* _UIB-CODE-BLOCK-END */
696 &ANALYZE-RESUME
698 &ENDIF
700 &IF DEFINED(EXCLUDE-project-by-hierarchy) = 0 &THEN
702 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE project-by-hierarchy Procedure
703 PROCEDURE project-by-hierarchy :
704 /*------------------------------------------------------------------------------
705 Purpose: Loop for all accounts of project
706 ------------------------------------------------------------------------------*/
707 DEF INPUT PARAMETER top-project AS INT NO-UNDO.
708 DEF INPUT PARAMETER ac-1 AS DEC NO-UNDO.
709 DEF INPUT PARAMETER ac-2 AS DEC NO-UNDO.
711 DEF VAR tr-sub-project AS LOGICAL NO-UNDO INITIAL No.
712 DEF VAR save-total AS DECIMAL NO-UNDO.
714 DEF BUFFER PrjBud FOR ProjectBudget.
715 DEF BUFFER OtherBud FOR ProjectBudget.
717 ASSIGN project-total = 0
718 tr-this-project = no.
720 FOR EACH PrjBud NO-LOCK
721 WHERE PrjBud.AccountCode >= ac-1 AND PrjBud.AccountCode <= ac-2
722 AND CAN-FIND( FIRST AcctTran
723 WHERE AcctTran.EntityType = base-entity-type
724 AND AcctTran.EntityCode = PrjBud.ProjectCode
725 AND AcctTran.AccountCode = PrjBud.AccountCode
726 AND AcctTran.MonthCode <= month-2 ) :
727 IF CAN-FIND( FIRST OtherBud WHERE OtherBud.EntityType = "J"
728 AND OtherBud.EntityCode = PrjBud.ProjectCode
729 AND OtherBud.EntityAccount = PrjBud.AccountCode ) THEN DO:
730 FOR EACH OtherBud WHERE OtherBud.EntityType = "J"
731 AND OtherBud.EntityCode = PrjBud.ProjectCode
732 AND OtherBud.EntityAccount = PrjBud.AccountCode NO-LOCK
733 BREAK BY OtherBud.EntityType BY OtherBud.EntityCode BY OtherBud.EntityAccount:
735 project-depth = project-depth + 1.
737 IF FIRST-OF( OtherBud.EntityCode ) THEN DO:
738 FIND Project WHERE Project.ProjectCode = OtherBud.EntityCode NO-LOCK.
739 RUN disp-entity-project.
740 dispName = FILL( ' ', project-depth * 3) + dispName.
741 DISPLAY dispName WITH FRAME report-frame-1.
742 DOWN WITH FRAME report-frame-1.
743 END.
745 save-total = project-total.
746 RUN project-by-hierarchy( OtherBud.ProjectCode, OtherBud.AccountCode, OtherBud.AccountCode ).
747 IF RETURN-VALUE = "Yes" THEN tr-sub-project = Yes.
748 project-depth = project-depth - 1.
749 project-total = save-total + project-total.
751 IF LAST-OF( OtherBud.EntityCode ) AND tr-sub-project THEN DO:
752 RUN disp-entity-project.
753 RUN disp-totals( project-total ).
754 grand-total = grand-total + project-total.
755 FIND Project WHERE Project.ProjectCode = PrjBud.ProjectCode NO-LOCK.
756 END.
757 END.
758 END.
759 ELSE DO:
760 ASSIGN account-total = 0
761 tr-this-account = no
762 dispName = FILL( ' ', project-depth * 3)
763 + STRING(PrjBud.AccountCode, "9999.99") + ", "
764 + PrjBud.Description.
766 RUN each-account( PrjBud.ProjectCode, PrjBud.AccountCode).
768 IF tr-this-account THEN DO:
769 dispName = STRING(PrjBud.AccountCode, "9999.99") + ", " +
770 PrjBud.Description.
771 RUN disp-totals( account-total ).
772 END.
773 END.
774 END.
776 IF tr-this-project OR tr-sub-project THEN RETURN "Yes".
778 END PROCEDURE.
780 /* _UIB-CODE-BLOCK-END */
781 &ANALYZE-RESUME
783 &ENDIF
785 &IF DEFINED(EXCLUDE-show-opening-balance) = 0 &THEN
787 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE show-opening-balance Procedure
788 PROCEDURE show-opening-balance :
789 /*------------------------------------------------------------------------------
790 Purpose: Calculate and display the opening balance
791 ------------------------------------------------------------------------------*/
792 DEF INPUT PARAMETER ec AS INT NO-UNDO.
793 DEF INPUT PARAMETER ac AS DEC NO-UNDO.
795 DEF VAR opening-balance LIKE AcctTran.Amount NO-UNDO.
796 opening-balance = 0.
798 FOR EACH AccountBalance NO-LOCK
799 WHERE AccountBalance.EntityType = base-entity-type
800 AND AccountBalance.EntityCode = ec
801 AND AccountBalance.AccountCode = ac
802 AND AccountBalance.MonthCode < month-1:
803 opening-balance = opening-balance + AccountBalance.Balance.
804 END.
806 IF opening-balance <> 0 THEN DO:
807 RUN display-headings-if-needed.
808 FIND LAST Month WHERE Month.MonthCode < month-1 NO-LOCK.
809 ASSIGN
810 dispReference = "O/Bal"
811 dispDescription = "Opening Balance"
812 tr-this-month = yes
815 IF export-fname = "" THEN DO:
816 DISPLAY
817 Month.EndDate @ AcctTran.Date
818 dispReference
819 opening-balance @ AcctTran.Amount
820 dispDescription
821 WITH FRAME report-frame-2.
823 DOWN WITH FRAME report-frame-2.
824 IF show-month-totals THEN DOWN WITH FRAME report-frame-2.
825 END.
826 ELSE
827 PUT UNFORMATTED ',,,"'
828 base-entity-type '",' ec ',' ac ',"'
829 dispReference '","'
830 Month.EndDate '",'
831 opening-balance ',"'
832 dispDescription '"'
833 SKIP .
836 ASSIGN
837 account-total = account-total + opening-balance
838 project-total = project-total + opening-balance
840 END.
842 END PROCEDURE.
844 /* _UIB-CODE-BLOCK-END */
845 &ANALYZE-RESUME
847 &ENDIF