Add blank column, rename column.
[capital-apms-progress.git] / process / report / trnpst.p
blob0c53a9baefd2bf31c444249ad0ddd6203462fa81
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File :
6 Purpose :
8 Syntax :
10 Description :
12 Author(s) :
13 Created :
14 Notes :
15 ------------------------------------------------------------------------*/
17 DEF INPUT PARAMETER batch-no LIKE Batch.BatchCode NO-UNDO.
19 &SCOPED-DEFINE lines-per-page 112
21 /* Report counters */
22 DEF VAR ln AS DEC INIT 0.00 NO-UNDO.
24 /* Line definitions */
26 DEF VAR page-no AS INT INIT 1 NO-UNDO.
27 DEF VAR reset-page AS CHAR NO-UNDO.
28 DEF VAR half-line AS CHAR NO-UNDO. half-line = CHR(27) + "=".
30 DEF VAR title-font AS CHAR NO-UNDO.
31 DEF VAR column-font AS CHAR NO-UNDO.
32 DEF VAR line-printer AS CHAR NO-UNDO.
33 DEF VAR trn-font-1 AS CHAR NO-UNDO.
34 DEF VAR trn-font-2 AS CHAR NO-UNDO.
35 DEF VAR footer-font AS CHAR NO-UNDO.
36 DEF VAR warning-font AS CHAR NO-UNDO.
37 DEF VAR normal AS CHAR NO-UNDO.
39 DEF VAR i AS INT NO-UNDO.
41 DEF VAR ledger-total AS DEC NO-UNDO.
43 {inc/ofc-this.i}
44 {inc/ofc-set-l.i "Tenant-Accounts" "tenant-accounts"}
45 {inc/ofc-set-l.i "Period-Closed-Warnings" "Period-Closed-Warnings"}
47 /* _UIB-CODE-BLOCK-END */
48 &ANALYZE-RESUME
51 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
53 /* ******************** Preprocessor Definitions ******************** */
55 &Scoped-define PROCEDURE-TYPE Procedure
59 /* _UIB-PREPROCESSOR-BLOCK-END */
60 &ANALYZE-RESUME
64 /* *********************** Procedure Settings ************************ */
66 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
67 /* Settings for THIS-PROCEDURE
68 Type: Procedure
69 Allow:
70 Frames: 0
71 Add Fields to: Neither
72 Other Settings: CODE-ONLY COMPILE
74 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
76 /* ************************* Create Window ************************** */
78 &ANALYZE-SUSPEND _CREATE-WINDOW
79 /* DESIGN Window definition (used by the UIB)
80 CREATE WINDOW Procedure ASSIGN
81 HEIGHT = .08
82 WIDTH = 40.
83 /* END WINDOW DEFINITION */
85 &ANALYZE-RESUME
89 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
90 /* ************************* Included-Libraries *********************** */
92 {inc/method/m-txtrep.i}
93 {inc/convert.i}
95 /* _UIB-CODE-BLOCK-END */
96 &ANALYZE-RESUME
100 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
103 /* *************************** Main Block *************************** */
105 DEF VAR user-name AS CHAR NO-UNDO.
106 {inc/username.i "user-name"}
108 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
110 RUN update-report.
112 OUTPUT CLOSE.
113 RUN view-output-file ( no ).
115 /* _UIB-CODE-BLOCK-END */
116 &ANALYZE-RESUME
119 /* ********************** Internal Procedures *********************** */
121 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE carriage-return Procedure
122 PROCEDURE carriage-return :
123 /*------------------------------------------------------------------------------
124 Purpose:
125 Parameters: <none>
126 Notes:
127 ------------------------------------------------------------------------------*/
129 PUT CONTROL CHR(13).
131 END PROCEDURE.
133 /* _UIB-CODE-BLOCK-END */
134 &ANALYZE-RESUME
137 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE column-header Procedure
138 PROCEDURE column-header :
139 /*------------------------------------------------------------------------------
140 Purpose:
141 Parameters: <none>
142 Notes:
143 ------------------------------------------------------------------------------*/
145 PUT CONTROL column-font.
146 PUT UNFORMATTED SPACE(9)
147 STRING( "Co/Ppty/Proj", "X(13)" ) SPACE(5)
148 STRING( "Acct", "X(4)" ) SPACE(5)
149 STRING( "Tn/Cr", "X(5)" ) SPACE(8)
150 STRING( "Date", "X(4)" ) SPACE(4)
151 STRING( "Trans Ref", "X(9)" ) SPACE(20)
152 STRING( "Amount", "X(6)" ).
153 PUT CONTROL line-printer.
154 RUN skip-line(2).
156 END PROCEDURE.
158 /* _UIB-CODE-BLOCK-END */
159 &ANALYZE-RESUME
162 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-document Procedure
163 PROCEDURE each-document :
164 /*------------------------------------------------------------------------------
165 Purpose:
166 Parameters: <none>
167 Notes:
168 ------------------------------------------------------------------------------*/
170 PUT CONTROL trn-font-1.
171 PUT UNFORMATTED
172 STRING( Document.DocumentType, "X(4)" ) SPACE(2)
173 STRING( Document.Reference, "X(12)" ) SPACE(2)
174 STRING( Document.Description, "X(50)" ).
175 RUN skip-line(1).
177 FOR EACH AcctTran OF Document NO-LOCK.
178 RUN each-transaction.
179 END.
181 RUN skip-line(1).
183 END PROCEDURE.
185 /* _UIB-CODE-BLOCK-END */
186 &ANALYZE-RESUME
189 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-transaction Procedure
190 PROCEDURE each-transaction :
191 /*------------------------------------------------------------------------------
192 Purpose:
193 Parameters: <none>
194 Notes:
195 ------------------------------------------------------------------------------*/
197 DEF VAR entity-code AS CHAR NO-UNDO.
198 entity-code = FILL( ' ', IF AcctTran.EntityType = "P" THEN 3 ELSE
199 IF AcctTran.EntityType = "J" THEN 8 ELSE 0 ).
200 entity-code = entity-code + STRING( AcctTran.EntityCode,
201 IF AcctTran.Entitytype = "L" THEN "999" ELSE "99999" ).
202 IF LOOKUP( AcctTran.EntityType, "C,T") <> 0 THEN entity-code = "".
204 PUT CONTROL trn-font-2.
206 PUT UNFORMATTED SPACE(5)
207 STRING( entity-code, "X(13)" ) SPACE(1)
208 STRING( IF AcctTran.EntityType <> "C" AND (tenant-accounts OR AcctTran.EntityType <> "T") THEN
209 STRING( AcctTran.AccountCode, "9999.99" ) ELSE "", "X(7)" ) SPACE(1)
210 STRING( IF LOOKUP( AcctTran.EntityType, "T,C" ) <> 0 THEN AcctTran.EntityType +
211 STRING( AcctTran.EntityCode, "99999" ) ELSE "", "X(6)" ) SPACE(1)
212 STRING( AcctTran.Date, "99/99/9999" ) SPACE(1)
213 STRING( IF AcctTran.Reference <> "" THEN AcctTran.Reference
214 ELSE Document.Reference, "X(12)" ) SPACE(1)
215 STRING( AcctTran.Amount, ">>>,>>>,>>9.99CR" ) SPACE(1)
216 STRING( IF AcctTran.Description <> "" THEN AcctTran.Description ELSE Document.Description, "X(50)" ).
217 RUN skip-line(1).
219 FIND Month WHERE Month.MonthCode = AcctTran.MonthCode NO-LOCK.
221 IF Period-Closed-Warnings <> No AND (AcctTran.Date < Month.StartDate OR AcctTran.Date > Month.EndDate) THEN DO:
222 PUT CONTROL warning-font.
223 PUT UNFORMATTED SPACE(5) STRING(
224 "( Warning! Period closed - updated to " +
225 STRING( Month.StartDate, "99/99/9999" ) + " to " + STRING( Month.EndDate, "99/99/9999" ) +
226 " period instead. )" ).
227 PUT CONTROL normal.
228 RUN skip-line(1.5).
229 END.
231 ledger-total = ledger-total +
232 IF AcctTran.EntityType = "L" THEN AcctTran.Amount ELSE 0.
234 END PROCEDURE.
236 /* _UIB-CODE-BLOCK-END */
237 &ANALYZE-RESUME
240 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure
241 PROCEDURE get-control-strings :
242 /*------------------------------------------------------------------------------
243 Purpose: Get all control strings for this report
244 Parameters: <none>
245 Notes:
246 ------------------------------------------------------------------------------*/
248 DEF VAR rows AS DEC NO-UNDO.
249 DEF VAR cols AS DEC NO-UNDO.
251 RUN make-control-string ( "PCL", "reset,portrait,a4,tm,0,lm,4",
252 OUTPUT reset-page, OUTPUT rows, OUTPUT cols ).
254 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,10",
255 OUTPUT title-font, OUTPUT rows, OUTPUT cols ).
257 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,8",
258 OUTPUT column-font, OUTPUT rows, OUTPUT cols ).
260 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,10",
261 OUTPUT footer-font, OUTPUT rows, OUTPUT cols ).
263 RUN make-control-string ( "PCL", "LinePrinter,lpi,9.54",
264 OUTPUT line-printer, OUTPUT rows, OUTPUT cols ).
266 RUN make-control-string ( "PCL", "LinePrinter,lpi,9.54",
267 OUTPUT trn-font-1, OUTPUT rows, OUTPUT cols ).
269 RUN make-control-string ( "PCL", "Courier,Pitch,24",
270 OUTPUT trn-font-2, OUTPUT rows, OUTPUT cols ).
272 RUN make-control-string ( "PCL", "Courier,Bold,Pitch,24",
273 OUTPUT warning-font, OUTPUT rows, OUTPUT cols ).
275 RUN make-control-string ( "PCL", "Normal",
276 OUTPUT normal, OUTPUT rows, OUTPUT cols ).
278 END PROCEDURE.
280 /* _UIB-CODE-BLOCK-END */
281 &ANALYZE-RESUME
284 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure
285 PROCEDURE page-feed :
286 /*------------------------------------------------------------------------------
287 Purpose:
288 ------------------------------------------------------------------------------*/
290 page-no = page-no + 1.
291 PUT CONTROL CHR(12).
293 END PROCEDURE.
295 /* _UIB-CODE-BLOCK-END */
296 &ANALYZE-RESUME
299 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure
300 PROCEDURE page-header :
301 /*------------------------------------------------------------------------------
302 Purpose:
303 ------------------------------------------------------------------------------*/
305 RUN reset-page.
306 RUN print-title.
307 RUN column-header.
309 END PROCEDURE.
311 /* _UIB-CODE-BLOCK-END */
312 &ANALYZE-RESUME
315 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-ledger-total Procedure
316 PROCEDURE print-ledger-total :
317 /*------------------------------------------------------------------------------
318 Purpose:
319 Parameters: <none>
320 Notes:
321 ------------------------------------------------------------------------------*/
323 PUT CONTROL footer-font.
324 PUT UNFORMATTED SPACE(10)
325 STRING( "Control Total of Ledger Transactions for Batch = " +
326 TRIM( STRING( ledger-total, ">>,>>>,>>>,>>9.99CR" ) ), "X(80)" ).
328 END PROCEDURE.
330 /* _UIB-CODE-BLOCK-END */
331 &ANALYZE-RESUME
334 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure
335 PROCEDURE print-title :
336 /*------------------------------------------------------------------------------
337 Purpose:
338 Parameters: <none>
339 Notes:
340 ------------------------------------------------------------------------------*/
342 PUT CONTROL line-printer.
343 RUN skip-line(3).
344 PUT CONTROL column-font.
345 PUT UNFORMATTED STRING( TODAY, "99/99/9999" )
346 STRING( ",", "X" ) SPACE
347 STRING( TIME, "HH:MM:SS" ) + " for " + user-name
348 CHR(13) SPACE(180) "Page " page-no.
349 PUT CONTROL line-printer.
350 RUN skip-line( 2 ).
351 PUT CONTROL title-font.
352 PUT UNFORMATTED STRING(
353 "Posted Transactions for batch " + STRING( Batch.BatchCode, "99999" ) + " - " +
354 Batch.Description,
355 "X(80)" ).
356 PUT CONTROL line-printer.
357 RUN skip-line(3).
359 END PROCEDURE.
361 /* _UIB-CODE-BLOCK-END */
362 &ANALYZE-RESUME
365 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure
366 PROCEDURE reset-page :
367 /*------------------------------------------------------------------------------
368 Purpose:
369 Parameters: <none>
370 Notes:
371 ------------------------------------------------------------------------------*/
373 PUT CONTROL reset-page.
374 ln = 0.
376 END PROCEDURE.
378 /* _UIB-CODE-BLOCK-END */
379 &ANALYZE-RESUME
382 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
383 PROCEDURE skip-line :
384 /*------------------------------------------------------------------------------
385 Purpose:
386 Parameters: <none>
387 Notes:
388 ------------------------------------------------------------------------------*/
390 DEF INPUT PARAMETER n AS DEC NO-UNDO.
392 IF ln + n >= {&lines-per-page} THEN
394 RUN page-feed.
395 RUN page-header.
396 RETURN.
397 END.
399 DEF VAR int-part AS INT NO-UNDO.
400 DEF VAR dec-part AS DEC NO-UNDO.
402 int-part = TRUNCATE( n, 0 ).
403 IF int-part < 0 THEN RETURN.
404 dec-part = n - int-part.
405 IF int-part = 0 AND dec-part = 0 THEN RETURN.
407 /* Need to have this like the following - do not touch */
408 IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ).
409 IF dec-part <> 0 THEN PUT CONTROL half-line.
411 ln = ln + n.
413 RUN carriage-return.
415 END PROCEDURE.
417 /* _UIB-CODE-BLOCK-END */
418 &ANALYZE-RESUME
421 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-to-line Procedure
422 PROCEDURE skip-to-line :
423 /*------------------------------------------------------------------------------
424 Purpose:
425 Parameters: <none>
426 Notes:
427 ------------------------------------------------------------------------------*/
429 DEF INPUT PARAMETER line-no AS DEC NO-UNDO.
431 DEF VAR int-part AS INT NO-UNDO.
432 DEF VAR dec-part AS DEC NO-UNDO.
434 int-part = TRUNCATE( line-no - ln, 0 ).
435 IF int-part < 0 THEN RETURN.
436 dec-part = ( line-no - ln ) - int-part.
437 IF int-part = 0 AND dec-part = 0 THEN RETURN.
439 IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ).
440 IF dec-part <> 0 THEN PUT CONTROL half-line.
442 ln = line-no.
444 RUN carriage-return.
446 END PROCEDURE.
448 /* _UIB-CODE-BLOCK-END */
449 &ANALYZE-RESUME
452 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-report Procedure
453 PROCEDURE update-report :
454 /*------------------------------------------------------------------------------
455 Purpose:
456 Parameters: <none>
457 Notes:
458 ------------------------------------------------------------------------------*/
460 FIND Batch WHERE Batch.BatchCode = batch-no NO-LOCK NO-ERROR.
461 IF NOT AVAILABLE Batch THEN RETURN.
463 RUN get-control-strings.
464 RUN page-header.
466 FOR EACH Document OF Batch NO-LOCK:
467 RUN each-document.
468 END.
470 RUN skip-line(1).
471 RUN print-ledger-total.
472 RUN page-feed.
474 END PROCEDURE.
476 /* _UIB-CODE-BLOCK-END */
477 &ANALYZE-RESUME