Add missing brackets.
[capital-apms-progress.git] / process / bksyanz.p
blob68289b89972ea381de680d754b68a2b1774b0add
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File :
6 Purpose :
7 Author(s) :
8 Created :
9 Notes :
10 ------------------------------------------------------------------------*/
11 /* *************************** Definitions ************************** */
12 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
14 DEF VAR preview AS LOGICAL NO-UNDO.
15 DEF VAR in-file AS CHAR NO-UNDO.
16 DEF VAR create-receipts AS LOGICAL NO-UNDO.
17 preview = (ENTRY( 1, report-options) = "Yes").
18 in-file = ENTRY( 2, report-options).
19 create-receipts = (ENTRY( 3, report-options) = "Yes").
21 /* MESSAGE preview in-file create-receipts. */
23 /* page control */
24 DEF VAR prt-ctrl AS CHAR NO-UNDO.
25 DEF VAR cols AS INT NO-UNDO.
26 DEF VAR rows AS INT NO-UNDO.
27 DEF VAR user-name AS CHAR FORMAT "X(20)" NO-UNDO.
28 {inc/username.i "user-name"}
30 /* page header */
31 &SCOPED-DEFINE page-width 180
32 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
34 DEF VAR timeStamp AS CHAR FORMAT "X(54)" NO-UNDO.
35 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
36 DEF VAR hline2 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
37 DEF VAR hline3 AS CHAR FORMAT "X({&page-width})" NO-UNDO.
38 hline2 = "Statement Processing for ANZ Online".
39 hline2 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
40 hline3 = "Presented Cheques" + (IF create-receipts THEN " and Receipts Batch Creation" ELSE "").
41 hline3 = SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline3) ) / 2)) + hline3.
43 DEFINE FRAME heading-frame WITH 1 DOWN {&with-clause} PAGE-TOP.
44 FORM HEADER
45 timeStamp "Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
46 hline2 FORMAT "X({&page-width})"
47 hline3 FORMAT "X({&page-width})"
48 SKIP (2) " Date Bank Account Number Type Reference Amount || Import Program Action taken"
49 WITH FRAME heading-frame.
51 /* _UIB-CODE-BLOCK-END */
52 &ANALYZE-RESUME
55 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
57 /* ******************** Preprocessor Definitions ******************** */
59 &Scoped-define PROCEDURE-TYPE Procedure
63 /* _UIB-PREPROCESSOR-BLOCK-END */
64 &ANALYZE-RESUME
68 /* *********************** Procedure Settings ************************ */
70 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
71 /* Settings for THIS-PROCEDURE
72 Type: Procedure
73 Allow:
74 Frames: 0
75 Add Fields to: Neither
76 Other Settings: CODE-ONLY COMPILE
78 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
80 /* ************************* Create Window ************************** */
82 &ANALYZE-SUSPEND _CREATE-WINDOW
83 /* DESIGN Window definition (used by the UIB)
84 CREATE WINDOW Procedure ASSIGN
85 HEIGHT = .66
86 WIDTH = 30.14.
87 /* END WINDOW DEFINITION */
89 &ANALYZE-RESUME
93 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
94 /* ************************* Included-Libraries *********************** */
96 {inc/method/m-txtrep.i}
98 /* _UIB-CODE-BLOCK-END */
99 &ANALYZE-RESUME
103 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
106 /* *************************** Main Block *************************** */
108 RUN make-control-string ( "PCL", "reset,landscape,tm,2,a4,lm,6,courier,cpi,18,lpi,9",
109 OUTPUT prt-ctrl, OUTPUT rows, OUTPUT cols ).
111 RUN output-control-file ( prt-ctrl ).
112 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE VALUE(rows).
114 VIEW FRAME heading-frame.
116 RUN present-cheques.
118 OUTPUT CLOSE.
119 RUN view-output-file ( preview ).
121 /* _UIB-CODE-BLOCK-END */
122 &ANALYZE-RESUME
125 /* ********************** Internal Procedures *********************** */
127 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convert-verbose-date Procedure
128 PROCEDURE convert-verbose-date :
129 /*------------------------------------------------------------------------------
130 Purpose:
131 ------------------------------------------------------------------------------*/
132 DEF INPUT PARAMETER v-date AS CHAR NO-UNDO.
133 DEF OUTPUT PARAMETER i-date AS DATE NO-UNDO.
135 DEF VAR dd AS INT NO-UNDO.
136 DEF VAR mm AS INT INITIAL 1 NO-UNDO.
137 DEF VAR yy AS INT NO-UNDO.
138 DEF VAR mth AS CHAR NO-UNDO.
139 DEF VAR mth-list AS CHAR INITIAL "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec" NO-UNDO.
141 dd = INTEGER( SUBSTRING( v-date, 1, INDEX( v-date, "-") - 1)).
142 yy = INTEGER( SUBSTRING( v-date, R-INDEX( v-date, "-") + 1)).
143 mth = SUBSTRING( v-date, INDEX( v-date, "-") + 1, 3).
144 DO WHILE mm < 12 AND ENTRY( mm, mth-list) <> mth:
145 mm = mm + 1.
146 END.
148 i-date = DATE( mm, dd, yy).
150 END PROCEDURE.
152 /* _UIB-CODE-BLOCK-END */
153 &ANALYZE-RESUME
156 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-payment-transaction Procedure
157 PROCEDURE create-payment-transaction :
158 /*------------------------------------------------------------------------------
159 Purpose:
160 ------------------------------------------------------------------------------*/
161 MESSAGE "Payment transaction creation not yet written!"
162 VIEW-AS ALERT-BOX ERROR.
163 RETURN.
164 END PROCEDURE.
166 /* _UIB-CODE-BLOCK-END */
167 &ANALYZE-RESUME
170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE mark-as-presented Procedure
171 PROCEDURE mark-as-presented :
172 /*------------------------------------------------------------------------------
173 Purpose:
174 ------------------------------------------------------------------------------*/
175 DEF INPUT PARAMETER bkacct AS CHAR NO-UNDO.
176 DEF INPUT PARAMETER chqnum AS CHAR NO-UNDO.
177 DEF INPUT PARAMETER indate AS CHAR NO-UNDO.
178 DEF INPUT PARAMETER amount AS DEC NO-UNDO.
180 DEF VAR cheque-no AS INT NO-UNDO.
181 DEF VAR prdate AS DATE NO-UNDO.
183 RUN convert-verbose-date( indate, OUTPUT prdate ).
185 FIND BankAccount WHERE BankAccount.BankAccount = bkacct NO-LOCK NO-ERROR.
186 IF NOT AVAILABLE(BankAccount) THEN DO:
187 PUT UNFORMATTED "No bank account available with account code " bkacct "!".
188 RETURN.
189 END.
191 cheque-no = INTEGER( chqnum ).
192 FIND Cheque WHERE Cheque.BankAccountCode = BankAccount.BankAccountCode
193 AND Cheque.ChequeNo = cheque-no EXCLUSIVE-LOCK NO-ERROR.
194 IF NOT AVAILABLE(Cheque) THEN DO:
195 PUT UNFORMATTED "Cheque " cheque-no " presented for " TRIM(STRING( amount, ">>>,>>>,>>9.99")) " but no record of issue - ignored!".
196 RETURN.
197 END.
199 IF amount <> Cheque.Amount THEN DO:
200 PUT UNFORMATTED "Cheque " cheque-no " issued for " TRIM(STRING( Cheque.Amount, ">>>,>>>,>>9.99")) "but presented for" TRIM(STRING( amount, ">>>,>>>,>>9.99")).
201 MESSAGE "Cheque" STRING( cheque-no, "999999") "issued for" STRING( Cheque.Amount, ">>>,>>>,>>9.99")
202 " but presented for" STRING( amount, ">>>,>>>,>>9.99") SKIP(1)
203 "Cheque not marked as presented!"
204 VIEW-AS ALERT-BOX WARNING TITLE "Error in presented amount!".
205 RETURN.
206 END.
208 PUT UNFORMATTED "Cheque record updated".
210 ASSIGN Cheque.DatePresented = prdate
211 Cheque.PresentedAmount = amount.
213 END PROCEDURE.
215 /* _UIB-CODE-BLOCK-END */
216 &ANALYZE-RESUME
219 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE present-cheques Procedure
220 PROCEDURE present-cheques :
221 /*------------------------------------------------------------------------------
222 Purpose: Mark cheques in ANZ on-line report as presented.
223 ------------------------------------------------------------------------------*/
224 DEF VAR tr-date AS CHAR NO-UNDO. /* date presented */
225 DEF VAR bk-acct AS CHAR NO-UNDO.
226 DEF VAR tr-type AS CHAR NO-UNDO.
227 DEF VAR tr-ref1 AS CHAR NO-UNDO. /* cheque no */
228 DEF VAR tr-amnt AS DEC NO-UNDO. /* amount */
230 DEF VAR in-line AS CHAR NO-UNDO.
232 INPUT FROM VALUE( in-file + "T.CSV").
233 REPEAT:
234 IMPORT UNFORMATTED in-line .
235 tr-date = ENTRY( 2, ENTRY( 1, in-line), '"').
236 bk-acct = ENTRY( 2, ENTRY( 2, in-line), '"').
237 tr-type = ENTRY( 2, ENTRY( 8, in-line), '"').
238 tr-ref1 = ENTRY( 2, ENTRY( 9, in-line), '"').
239 tr-amnt = DECIMAL( ENTRY( 2, ENTRY( 10, in-line), '"')).
241 PUT UNFORMATTED STRING( tr-date, "X(12)") " "
242 STRING( bk-acct, "X(20)") " "
243 STRING( tr-type, "X(10)") " "
244 STRING( tr-ref1, "X(18)") " "
245 STRING( tr-amnt, ">>>,>>>,>>9.99CR") " || ".
247 IF tr-type = "CHEQUE" THEN DO:
248 RUN mark-as-presented( bk-acct, tr-ref1, tr-date, - tr-amnt ).
249 END.
250 ELSE IF tr-type = "TRANSFER" AND create-receipts THEN DO:
251 RUN create-payment-transaction.
252 END.
253 PUT UNFORMATTED " " SKIP.
254 END.
255 INPUT CLOSE.
257 END PROCEDURE.
259 /* _UIB-CODE-BLOCK-END */
260 &ANALYZE-RESUME