Add blank column, rename column.
[capital-apms-progress.git] / process / report / pymtsum.p
blobd3fe4d1217ffa219be4bf15c7c3e16a247851637
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
6 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
8 DEF VAR bank-account-code AS CHAR NO-UNDO.
9 DEF VAR cheque-1 AS INTEGER NO-UNDO.
10 DEF VAR cheque-n AS INTEGER NO-UNDO.
11 DEF VAR date-1 AS DATE NO-UNDO.
12 DEF VAR date-n AS DATE NO-UNDO.
13 DEF VAR range-type AS CHAR NO-UNDO INITIAL "cheque".
14 DEF VAR hide-opex AS LOGICAL NO-UNDO INITIAL No.
15 DEF VAR authorisation AS LOGICAL NO-UNDO.
16 DEF VAR preview AS LOGICAL NO-UNDO INITIAL No.
17 RUN parse-parameters.
19 FIND BankAccount WHERE BankAccount.BankAccountCode = bank-account-code NO-LOCK NO-ERROR.
20 IF NOT AVAILABLE(BankAccount) THEN DO:
21 MESSAGE "Bank account '" + bank-account-code + "' is not available!"
22 VIEW-AS ALERT-BOX ERROR.
23 RETURN.
24 END.
26 /* page control */
27 DEF VAR prt-ctrl AS CHAR NO-UNDO.
28 DEF VAR cols AS INT NO-UNDO.
29 DEF VAR rows AS INT NO-UNDO.
30 DEF VAR user-name AS CHAR NO-UNDO.
31 {inc/username.i "user-name"}
32 {inc/ofc-this.i}
33 {inc/ofc-set.i "AcctGroup-Opex" "opex-list"}
34 {inc/ofc-set.i "AcctGroup-Tenex" "tenex-list"}
36 /* print control */
37 DEF VAR normal-font AS CHAR NO-UNDO INITIAL "".
38 DEF VAR big-font AS CHAR NO-UNDO INITIAL "".
39 DEF VAR bold-font AS CHAR NO-UNDO INITIAL "".
40 DEF VAR italic-font AS CHAR NO-UNDO INITIAL "".
41 IF NOT preview THEN RUN set-font-strings.
43 /* page header */
44 &SCOPED-DEFINE page-width 195
45 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT WIDTH {&page-width}
47 DEF VAR timeStamp AS CHAR FORMAT "X(54)" NO-UNDO.
48 timeStamp = "Printed " + STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
49 DEF VAR hline2 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
50 DEF VAR hline3 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
51 IF range-type = "cheque" THEN
52 hline2 = "Payment Summary for cheque numbers " + STRING( cheque-1,"999999") + " to " + STRING( cheque-n,"999999").
53 ELSE
54 hline2 = "Payment Summary for dates " + STRING( date-1,"99/99/99") + " to " + STRING( date-n,"99/99/99").
55 hline2 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
56 hline3 = "Drawn on: " + BankAccount.BankName + ", " + BankAccount.BankBranchName + " by " + BankAccount.AccountName.
57 hline3 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline3) ) / 2)) + hline3.
59 DEFINE FRAME heading-frame WITH 1 DOWN NO-LABELS {&with-clause} PAGE-TOP.
60 FORM HEADER
61 timeStamp "Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
62 hline2 FORMAT "X({&page-width})"
63 hline3 FORMAT "X({&page-width})"
64 SKIP (1) /* "column headings" */
65 WITH FRAME heading-frame.
67 DEF VAR grand-total AS DECIMAL NO-UNDO.
69 DEF VAR EntityName AS CHAR NO-UNDO.
70 DEF VAR AmountText AS CHAR NO-UNDO.
71 DEFINE FRAME listing-frame WITH DOWN {&with-clause}.
72 FORM Cheque.Date COLUMN-LABEL " Date "
73 Cheque.ChequeNo COLUMN-LABEL "Cheque"
74 Cheque.Payee COLUMN-LABEL "Payee "
75 Voucher.VoucherSeq FORMAT ">>>>>>9" COLUMN-LABEL "Voucher"
76 Voucher.ApproverCode FORMAT " X(4)" COLUMN-LABEL "Appvr"
77 EntityName FORMAT "X(40)" COLUMN-LABEL "Entity "
78 Voucher.Description COLUMN-LABEL "Description "
79 AmountText FORMAT "X(16)" COLUMN-LABEL " Value "
80 WITH FRAME listing-frame.
82 /* _UIB-CODE-BLOCK-END */
83 &ANALYZE-RESUME
86 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
88 /* ******************** Preprocessor Definitions ******************** */
90 &Scoped-define PROCEDURE-TYPE Procedure
91 &Scoped-define DB-AWARE no
95 /* _UIB-PREPROCESSOR-BLOCK-END */
96 &ANALYZE-RESUME
100 /* *********************** Procedure Settings ************************ */
102 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
103 /* Settings for THIS-PROCEDURE
104 Type: Procedure
105 Allow:
106 Frames: 0
107 Add Fields to: Neither
108 Other Settings: CODE-ONLY COMPILE
110 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
112 /* ************************* Create Window ************************** */
114 &ANALYZE-SUSPEND _CREATE-WINDOW
115 /* DESIGN Window definition (used by the UIB)
116 CREATE WINDOW Procedure ASSIGN
117 HEIGHT = 20.25
118 WIDTH = 30.14.
119 /* END WINDOW DEFINITION */
121 &ANALYZE-RESUME
123 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
124 /* ************************* Included-Libraries *********************** */
126 {inc/method/m-txtrep.i}
128 /* _UIB-CODE-BLOCK-END */
129 &ANALYZE-RESUME
135 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
138 /* *************************** Main Block *************************** */
140 RUN make-control-string ( "PCL", "reset,landscape,tm,2,a4,lm,6,courier,cpi,18.5,lpi,9",
141 OUTPUT prt-ctrl, OUTPUT rows, OUTPUT cols ).
143 RUN output-control-file ( prt-ctrl ).
144 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE VALUE(rows).
146 VIEW FRAME heading-frame.
148 IF authorisation THEN RUN authorisation-page.
150 IF range-type = "cheque" THEN DO:
151 FOR EACH Cheque WHERE BankAccount.BankAccountCode = Cheque.BankAccountCode
152 AND Cheque.ChequeNo >= cheque-1
153 AND Cheque.ChequeNo <= cheque-n NO-LOCK:
154 RUN each-cheque.
155 grand-total = grand-total + Cheque.Amount.
156 END.
157 END.
158 ELSE DO:
159 FOR EACH Cheque WHERE BankAccount.BankAccountCode = Cheque.BankAccountCode
160 AND Cheque.Date >= date-1
161 AND Cheque.Date <= date-n NO-LOCK:
162 RUN each-cheque.
163 grand-total = grand-total + Cheque.Amount.
164 END.
165 END.
167 DISPLAY "" @ EntityName WITH FRAME listing-frame.
168 DOWN WITH FRAME listing-frame.
169 DISPLAY "===============" @ AmountText WITH FRAME listing-frame.
170 DOWN WITH FRAME listing-frame.
171 DISPLAY STRING( grand-total, "->>>,>>>,>>9.99") @ AmountText WITH FRAME listing-frame.
172 DOWN WITH FRAME listing-frame.
174 OUTPUT CLOSE.
175 RUN view-output-file ( preview ).
177 /* _UIB-CODE-BLOCK-END */
178 &ANALYZE-RESUME
181 /* ********************** Internal Procedures *********************** */
183 &IF DEFINED(EXCLUDE-authorisation-page) = 0 &THEN
185 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE authorisation-page Procedure
186 PROCEDURE authorisation-page :
187 /*------------------------------------------------------------------------------
188 Purpose:
189 Parameters: <none>
190 Notes:
191 ------------------------------------------------------------------------------*/
192 PUT SKIP(1) " ".
193 PUT CONTROL big-font.
194 PUT SKIP(4) "Cheque Authorisation" SKIP "--------------------" SKIP(7).
195 PUT UNFORMATTED "Documentation correct: __________________________________________________________________ date: _____ / _____ / _____" SKIP (8).
196 PUT UNFORMATTED "Cheques approved for signature: __________________________________________________________________ date: _____ / _____ / _____" .
197 PUT CONTROL normal-font.
198 PUT SKIP(4) " ".
199 PAGE.
200 END PROCEDURE.
202 /* _UIB-CODE-BLOCK-END */
203 &ANALYZE-RESUME
205 &ENDIF
207 &IF DEFINED(EXCLUDE-each-cheque) = 0 &THEN
209 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-cheque Procedure
210 PROCEDURE each-cheque :
211 /*------------------------------------------------------------------------------
212 Purpose:
213 ------------------------------------------------------------------------------*/
214 DEF VAR vouchers-total AS DEC NO-UNDO INITIAL 0.
215 DEF VAR vouchers-count AS INT NO-UNDO INITIAL 0.
217 IF hide-opex THEN DO:
218 FOR EACH Voucher WHERE Voucher.BankAccountCode = Cheque.BankAccountCode
219 AND Voucher.ChequeNo = Cheque.ChequeNo NO-LOCK,
220 FIRST VoucherLine OF Voucher NO-LOCK,
221 FIRST ChartOfAccount WHERE ChartOfAccount.AccountCode = VoucherLine.AccountCode NO-LOCK:
222 IF VoucherLine.EntityType = "P" AND CAN-DO( opex-list, ChartOfAccount.AccountGroupCode ) THEN NEXT.
223 IF VoucherLine.EntityType = "P" AND CAN-DO( tenex-list, ChartOfAccount.AccountGroupCode ) THEN NEXT.
224 vouchers-count = vouchers-count + 1.
225 END.
226 IF vouchers-count = 0 THEN RETURN.
227 END.
229 DISPLAY Cheque.Date Cheque.ChequeNo Cheque.Payee WITH FRAME listing-frame.
230 vouchers-count = 0.
231 FOR EACH Voucher WHERE Voucher.BankAccountCode = Cheque.BankAccountCode
232 AND Voucher.ChequeNo = Cheque.ChequeNo NO-LOCK:
233 RUN each-voucher( INPUT-OUTPUT vouchers-total ).
234 vouchers-count = vouchers-count + 1.
235 END.
236 IF vouchers-count <> 1 OR vouchers-total <> Cheque.Amount THEN DO:
237 DISPLAY "---------------" @ AmountText WITH FRAME listing-frame.
238 DOWN WITH FRAME listing-frame.
240 IF vouchers-total <> Cheque.Amount THEN DO:
241 DISPLAY ("Vouchers = " + TRIM(STRING( vouchers-total, "->>>,>>>,>>9.99")) ) @ Voucher.Description WITH FRAME listing-frame.
242 END.
243 DISPLAY STRING( Cheque.Amount, "->>>,>>>,>>9.99") @ AmountText WITH FRAME listing-frame.
244 DOWN WITH FRAME listing-frame.
245 END.
246 DISPLAY "" @ AmountText WITH FRAME listing-frame.
247 DOWN WITH FRAME listing-frame.
249 END PROCEDURE.
251 /* _UIB-CODE-BLOCK-END */
252 &ANALYZE-RESUME
254 &ENDIF
256 &IF DEFINED(EXCLUDE-each-voucher) = 0 &THEN
258 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-voucher Procedure
259 PROCEDURE each-voucher :
260 /*------------------------------------------------------------------------------
261 Purpose:
262 ------------------------------------------------------------------------------*/
263 DEF INPUT-OUTPUT PARAMETER running-total AS DECIMAL NO-UNDO.
265 DEF VAR vchr-value AS DECIMAL NO-UNDO.
267 vchr-value = Voucher.GoodsValue + Voucher.TaxValue.
268 running-total = running-total + vchr-value.
270 RUN set-entity-name( Voucher.EntityType, Voucher.EntityCode).
271 DISPLAY Voucher.VoucherSeq
272 Voucher.ApproverCode
273 Voucher.Description
274 RETURN-VALUE @ EntityName
275 STRING( vchr-value, "->>>,>>>,>>9.99") @ AmountText
276 WITH FRAME listing-frame.
277 DOWN WITH FRAME listing-frame.
279 END PROCEDURE.
281 /* _UIB-CODE-BLOCK-END */
282 &ANALYZE-RESUME
284 &ENDIF
286 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
288 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
289 PROCEDURE parse-parameters :
290 /*------------------------------------------------------------------------------
291 Purpose:
292 ------------------------------------------------------------------------------*/
293 DEF VAR token AS CHAR NO-UNDO.
294 DEF VAR i AS INT NO-UNDO.
295 DEF VAR fin-year AS INT NO-UNDO.
297 {inc/showopts.i "report-options"}
299 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
300 token = ENTRY( i, report-options, "~n" ).
302 CASE ENTRY( 1, token ):
303 WHEN "Preview" THEN preview = Yes.
304 WHEN "NoOpex" THEN hide-opex = Yes.
305 WHEN "AuthorisationPage" THEN authorisation = Yes.
306 WHEN "BankAccount" THEN bank-account-code = ENTRY(2,token).
307 WHEN "ChequeRange" THEN ASSIGN
308 range-type = "cheque"
309 cheque-1 = INT( ENTRY(2,token) )
310 cheque-n = INT( ENTRY(3,token) ).
311 WHEN "DateRange" THEN ASSIGN
312 range-type = "date"
313 date-1 = DATE( ENTRY(2,token) )
314 date-n = DATE( ENTRY(3,token) ).
315 END CASE.
316 END.
318 END PROCEDURE.
320 /* _UIB-CODE-BLOCK-END */
321 &ANALYZE-RESUME
323 &ENDIF
325 &IF DEFINED(EXCLUDE-set-entity-name) = 0 &THEN
327 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-entity-name Procedure
328 PROCEDURE set-entity-name :
329 /*------------------------------------------------------------------------------
330 Purpose:
331 ------------------------------------------------------------------------------*/
332 DEF INPUT PARAMETER et AS CHAR NO-UNDO.
333 DEF INPUT PARAMETER ec AS INT NO-UNDO.
335 CASE et:
336 WHEN "L" THEN DO:
337 FIND Company WHERE Company.CompanyCode = ec NO-LOCK NO-ERROR.
338 IF AVAILABLE(Company) THEN RETURN Company.LegalName.
339 END.
340 WHEN "P" THEN DO:
341 FIND Property WHERE Property.PropertyCode = ec NO-LOCK NO-ERROR.
342 IF AVAILABLE(Property) THEN RETURN Property.Name.
343 END.
344 WHEN "J" THEN DO:
345 FIND Project WHERE Project.ProjectCode = ec NO-LOCK NO-ERROR.
346 IF AVAILABLE(Project) THEN RETURN Project.Description.
347 END.
348 WHEN "T" THEN DO:
349 FIND Tenant WHERE Tenant.TenantCode = ec NO-LOCK NO-ERROR.
350 IF AVAILABLE(Tenant) THEN RETURN Tenant.Name.
351 END.
352 WHEN "C" THEN DO:
353 FIND Creditor WHERE Creditor.CreditorCode = ec NO-LOCK NO-ERROR.
354 IF AVAILABLE(Creditor) THEN RETURN Creditor.Name.
355 END.
356 END.
357 RETURN "Entity " + et + "-" + STRING( ec, "99999") + " not on file!".
358 END PROCEDURE.
360 /* _UIB-CODE-BLOCK-END */
361 &ANALYZE-RESUME
363 &ENDIF
365 &IF DEFINED(EXCLUDE-set-font-strings) = 0 &THEN
367 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-font-strings Procedure
368 PROCEDURE set-font-strings :
369 /*------------------------------------------------------------------------------
370 Purpose: Set up the font strings
371 ------------------------------------------------------------------------------*/
372 DEF VAR r AS DEC NO-UNDO.
373 DEF VAR c AS DEC NO-UNDO.
375 RUN make-control-string ( "PCL", "courier,cpi,18.5,lpi,9", OUTPUT normal-font, OUTPUT r, OUTPUT c ).
376 RUN make-control-string ( "PCL", "courier,cpi,15,lpi,9", OUTPUT big-font, OUTPUT r, OUTPUT c ).
377 RUN make-control-string ( "PCL", "courier,cpi,18.5,lpi,9,bold", OUTPUT bold-font, OUTPUT r, OUTPUT c ).
378 RUN make-control-string ( "PCL", "courier,cpi,18.5,lpi,9,italic", OUTPUT italic-font, OUTPUT r, OUTPUT c ).
380 END PROCEDURE.
382 /* _UIB-CODE-BLOCK-END */
383 &ANALYZE-RESUME
385 &ENDIF