Make date field wider to accommodate 10 digits properly.
[capital-apms-progress.git] / process / bknzasb.p
blobaf33bc9612c5de1b591b4d302218b8c3740ffbd9
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 {inc/ofc-this.i}
9 {inc/ofc-set.i "Bank-File-Format" "file-format"}
11 DEF VAR preview AS LOGICAL NO-UNDO.
12 DEF VAR in-file AS CHAR NO-UNDO.
13 DEF VAR create-receipts AS LOGICAL NO-UNDO.
14 RUN parse-parameters.
16 DEF VAR base-font AS CHAR NO-UNDO INITIAL "courier,fixed,cpi,22,lpi,10,normal".
17 DEF VAR header-font AS CHAR NO-UNDO INITIAL "helvetica,proportional,point,11,lpi,7,bold".
18 DEF VAR time-font AS CHAR NO-UNDO INITIAL "helvetica,proportional,point,6,lpi,9,normal".
19 DEF VAR line AS CHAR NO-UNDO.
21 DEF VAR bank-amount AS DEC NO-UNDO INITIAL 0.0 .
22 DEF VAR bank-ec AS INT NO-UNDO INITIAL ?.
23 DEF VAR bank-ac AS DEC NO-UNDO INITIAL ?.
24 DEF VAR last-prdate AS DATE NO-UNDO INITIAL ?.
26 DEF VAR user-name AS CHAR FORMAT "X(20)" NO-UNDO.
27 {inc/username.i "user-name"}
28 DEF VAR timeStamp AS CHAR FORMAT "X(54)" NO-UNDO.
29 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
31 DEF VAR hline2 AS CHAR NO-UNDO.
32 DEF VAR hline3 AS CHAR NO-UNDO.
33 hline2 = "Bank Transactions Download Processing".
34 hline3 = "Presented Cheques" + (IF create-receipts THEN " and Receipts Batch Creation" ELSE "").
36 /* ensure NewBatch & NewDocument are scoped to entire program */
37 FIND FIRST NewBatch NO-LOCK NO-ERROR.
38 FIND PREV NewBatch NO-LOCK NO-ERROR.
40 {inc/ofc-acct.i "DEBTORS" "sundry-debtors" "ERROR"}
41 {inc/ofc-acct.i "SUSPENSE-TENANT" "suspense-tenant-ac" "ERROR"}
42 DEF VAR suspense-tenant-ec AS INT NO-UNDO.
43 suspense-tenant-ec = OfficeControlAccount.EntityCode.
45 {inc/ofc-set.i "Receipts-Description" "receipts-description"}
47 /* _UIB-CODE-BLOCK-END */
48 &ANALYZE-RESUME
51 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
53 /* ******************** Preprocessor Definitions ******************** */
55 &Scoped-define PROCEDURE-TYPE Procedure
56 &Scoped-define DB-AWARE no
60 /* _UIB-PREPROCESSOR-BLOCK-END */
61 &ANALYZE-RESUME
64 /* ************************ Function Prototypes ********************** */
66 &IF DEFINED(EXCLUDE-find-bank-account) = 0 &THEN
68 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD find-bank-account Procedure
69 FUNCTION find-bank-account RETURNS CHARACTER
70 ( INPUT bkacct AS CHAR ) FORWARD.
72 /* _UIB-CODE-BLOCK-END */
73 &ANALYZE-RESUME
75 &ENDIF
77 &IF DEFINED(EXCLUDE-find-tenant-code) = 0 &THEN
79 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD find-tenant-code Procedure
80 FUNCTION find-tenant-code RETURNS INTEGER
81 ( INPUT t1 AS CHAR, INPUT t2 AS CHAR ) FORWARD.
83 /* _UIB-CODE-BLOCK-END */
84 &ANALYZE-RESUME
86 &ENDIF
89 /* *********************** Procedure Settings ************************ */
91 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
92 /* Settings for THIS-PROCEDURE
93 Type: Procedure
94 Allow:
95 Frames: 0
96 Add Fields to: Neither
97 Other Settings: CODE-ONLY COMPILE
99 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
101 /* ************************* Create Window ************************** */
103 &ANALYZE-SUSPEND _CREATE-WINDOW
104 /* DESIGN Window definition (used by the UIB)
105 CREATE WINDOW Procedure ASSIGN
106 HEIGHT = 21.55
107 WIDTH = 40.14.
108 /* END WINDOW DEFINITION */
110 &ANALYZE-RESUME
112 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
113 /* ************************* Included-Libraries *********************** */
115 {inc/method/m-impcsv.i}
116 {inc/method/m-txtrep.i}
118 /* _UIB-CODE-BLOCK-END */
119 &ANALYZE-RESUME
125 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
128 /* *************************** Main Block *************************** */
130 RUN pclrep-start( preview, "reset,landscape,tm,2,a4,lm,6," + base-font).
131 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
133 RUN present-cheques.
134 IF create-receipts THEN RUN create-bank-transaction.
136 OUTPUT CLOSE.
138 RUN pclrep-finish.
140 /* _UIB-CODE-BLOCK-END */
141 &ANALYZE-RESUME
144 /* ********************** Internal Procedures *********************** */
146 &IF DEFINED(EXCLUDE-convert-bank-date) = 0 &THEN
148 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE convert-bank-date Procedure
149 PROCEDURE convert-bank-date :
150 /*------------------------------------------------------------------------------
151 Purpose:
152 ------------------------------------------------------------------------------*/
153 DEF INPUT PARAMETER v-date AS CHAR NO-UNDO.
154 DEF OUTPUT PARAMETER i-date AS DATE NO-UNDO.
156 DEF VAR dd AS INT NO-UNDO.
157 DEF VAR mm AS INT NO-UNDO.
158 DEF VAR yy AS INT NO-UNDO.
160 ASSIGN i-date = DATE( v-date ) NO-ERROR.
161 IF i-date > (TODAY - 1000) THEN RETURN.
163 /* otherwise make sure there aren't going to be problems with the year 2000 */
164 dd = INT( ENTRY( 3, v-date, "/")).
165 mm = INT( ENTRY( 2, v-date, "/")).
166 yy = INT( ENTRY( 1, v-date, "/")).
167 IF yy < 100 THEN DO:
168 yy = yy + 1900.
169 DO WHILE yy < SESSION:YEAR-OFFSET:
170 yy = yy + 100.
171 END.
172 END.
174 ASSIGN i-date = DATE( mm, dd, yy) NO-ERROR.
175 IF i-date = ? THEN DO:
176 RUN pclrep-line( base-font, "Couldn't understand date of >>" + v-date + "<< in transaction").
177 END.
179 END PROCEDURE.
181 /* _UIB-CODE-BLOCK-END */
182 &ANALYZE-RESUME
184 &ENDIF
186 &IF DEFINED(EXCLUDE-create-bank-transaction) = 0 &THEN
188 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-bank-transaction Procedure
189 PROCEDURE create-bank-transaction :
190 /*------------------------------------------------------------------------------
191 Purpose:
192 ------------------------------------------------------------------------------*/
194 IF NOT AVAILABLE(NewBatch) THEN RETURN.
195 IF bank-ec = ? THEN RETURN.
196 IF bank-amount = ? THEN RETURN.
197 IF bank-ac = ? THEN RETURN.
198 IF last-prdate = ? THEN RETURN.
200 IF NOT create-receipts THEN RETURN.
202 CREATE NewDocument.
203 NewDocument.BatchCode = NewBatch.BatchCode.
204 NewDocument.DocumentType = "RCBK".
205 NewDocument.Reference = STRING(NewBatch.BatchCode) + "/" + STRING(NewDocument.DocumentCode).
206 NewDocument.Description = "Banking Summary " + STRING(last-prdate, "99/99/9999").
208 CREATE NewAcctTrans.
209 NewAcctTrans.BatchCode = NewBatch.BatchCode.
210 NewAcctTrans.DocumentCode = NewDocument.DocumentCode.
211 NewAcctTrans.EntityType = "L".
212 NewAcctTrans.EntityCode = bank-ec.
213 NewAcctTrans.AccountCode = bank-ac.
214 NewAcctTrans.Date = last-prdate.
215 NewAcctTrans.Amount = bank-amount.
217 bank-amount = 0.
218 END PROCEDURE.
220 /* _UIB-CODE-BLOCK-END */
221 &ANALYZE-RESUME
223 &ENDIF
225 &IF DEFINED(EXCLUDE-create-receipt-transaction) = 0 &THEN
227 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-receipt-transaction Procedure
228 PROCEDURE create-receipt-transaction :
229 /*------------------------------------------------------------------------------
230 Purpose:
231 ------------------------------------------------------------------------------*/
232 DEF INPUT PARAMETER in-bkacct AS CHAR NO-UNDO.
233 DEF INPUT PARAMETER tr-type AS CHAR NO-UNDO.
234 DEF INPUT PARAMETER indate AS CHAR NO-UNDO.
235 DEF INPUT PARAMETER text1 AS CHAR NO-UNDO.
236 DEF INPUT PARAMETER text2 AS CHAR NO-UNDO.
237 DEF INPUT PARAMETER amount AS DEC NO-UNDO.
238 DEF OUTPUT PARAMETER result AS CHAR NO-UNDO INITIAL "".
240 DEF VAR bkacct AS CHAR NO-UNDO.
241 DEF VAR prdate AS DATE NO-UNDO.
242 DEF VAR tenant-code AS INT NO-UNDO.
243 DEF VAR tr-description AS CHAR NO-UNDO.
244 DEF VAR tr-reference AS CHAR NO-UNDO.
246 RUN convert-bank-date( indate, OUTPUT prdate ).
248 bkacct = REPLACE( in-bkacct, "-", "").
249 FIND FIRST BankAccount WHERE BankAccount.BankAccount = bkacct NO-LOCK NO-ERROR.
250 IF NOT AVAILABLE(BankAccount) THEN DO:
251 bkacct = SUBSTRING( bkacct, 1, 13) + "0" + SUBSTRING( bkacct, 14, 2).
252 FIND FIRST BankAccount WHERE BankAccount.BankAccount BEGINS bkacct NO-LOCK NO-ERROR.
253 IF NOT AVAILABLE(BankAccount) THEN DO:
254 result = "-->No bank account available with account code '" + in-bkacct + "'".
255 RETURN.
256 END.
257 END.
259 tenant-code = find-tenant-code( text1, text2).
260 IF tenant-code = ? THEN DO:
261 tr-description = TRIM(text2) + " " + TRIM(text1).
262 tenant-code = suspense-tenant-ec.
263 END.
264 ELSE
265 tr-description = receipts-description.
267 FIND Tenant WHERE Tenant.TenantCode = tenant-code NO-LOCK NO-ERROR.
268 IF NOT AVAILABLE(Tenant) THEN DO:
269 /* should only occur if the suspense tenant doesn't exist */
270 result = "-->Tenant " + STRING(tenant-code,"99999") + " not on file.".
271 RETURN.
272 END.
274 DO TRANSACTION:
275 IF create-receipts THEN DO:
276 IF bank-ec <> BankAccount.CompanyCode OR bank-ac <> BankAccount.AccountCode THEN DO:
277 RUN create-bank-transaction.
279 CREATE NewBatch.
280 NewBatch.BatchType = "NORM".
281 NewBatch.Description = "Automatic receipts " + STRING( TODAY, "99/99/9999") + ", " + in-bkacct.
283 CREATE NewDocument.
284 NewDocument.BatchCode = NewBatch.BatchCode.
285 NewDocument.DocumentType = "RCPT".
286 NewDocument.Reference = STRING(NewBatch.BatchCode) + "/" + STRING(NewDocument.DocumentCode).
287 NewDocument.Description = NewBatch.Description.
288 END.
290 CREATE NewAcctTrans.
291 NewAcctTrans.BatchCode = NewBatch.BatchCode.
292 NewAcctTrans.DocumentCode = NewDocument.DocumentCode.
293 NewAcctTrans.EntityType = "T".
294 NewAcctTrans.EntityCode = tenant-code.
295 NewAcctTrans.AccountCode = sundry-debtors.
296 NewAcctTrans.Date = prdate.
297 NewAcctTrans.Amount = amount.
298 NewAcctTrans.Reference = STRING(NewBatch.BatchCode) + "/" + STRING(NewDocument.DocumentCode) + "/" + STRING(NewAcctTrans.TransactionCode).
299 NewAcctTrans.Description = tr-description.
300 END.
302 RUN match-exception(tr-type, text2, text1, OUTPUT result).
303 END.
305 last-prdate = prdate.
306 bank-ec = BankAccount.CompanyCode.
307 bank-ac = BankAccount.AccountCode.
308 bank-amount = bank-amount + amount.
310 IF result = "" THEN
311 result = "Receipt from " + STRING( Tenant.Name, "X(30)") + " "
312 + "T" + STRING( Tenant.TenantCode, "99999") + "/" + Tenant.EntityType + STRING( Tenant.EntityCode, "99999").
314 RETURN.
316 END PROCEDURE.
318 /* _UIB-CODE-BLOCK-END */
319 &ANALYZE-RESUME
321 &ENDIF
323 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
325 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
326 PROCEDURE inst-page-header :
327 /*------------------------------------------------------------------------------
328 Purpose:
329 ------------------------------------------------------------------------------*/
330 RUN pclrep-line( time-font, timeStamp + CHR(13) + FILL(" ",350) + "Page " + STRING(pclrep-page-number)).
331 RUN pclrep-down-by(1).
332 RUN pclrep-line( header-font, hline2).
333 RUN pclrep-line( header-font, hline3).
334 RUN pclrep-down-by(0.5).
335 RUN pclrep-line( base-font + ",bold", " Date Account Number Bank Type Cheque Other Party Reference Amount || Import Program Action taken").
336 RUN pclrep-line( base-font + ",bold", " (TT) (Match1) (Match2)").
337 RUN pclrep-down-by(0.3).
339 END PROCEDURE.
341 /* _UIB-CODE-BLOCK-END */
342 &ANALYZE-RESUME
344 &ENDIF
346 &IF DEFINED(EXCLUDE-mark-as-presented) = 0 &THEN
348 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE mark-as-presented Procedure
349 PROCEDURE mark-as-presented :
350 /*------------------------------------------------------------------------------
351 Purpose:
352 ------------------------------------------------------------------------------*/
353 DEF INPUT PARAMETER bkacct AS CHAR NO-UNDO.
354 DEF INPUT PARAMETER chqnum AS INT NO-UNDO.
355 DEF INPUT PARAMETER indate AS CHAR NO-UNDO.
356 DEF INPUT PARAMETER amount AS DEC NO-UNDO.
357 DEF OUTPUT PARAMETER result AS CHAR NO-UNDO INITIAL "".
359 DEF VAR cheque-no AS INT NO-UNDO.
360 DEF VAR prdate AS DATE NO-UNDO.
362 RUN convert-bank-date( indate, OUTPUT prdate ).
364 bkacct = REPLACE( bkacct, "-", "").
365 FIND FIRST BankAccount WHERE BankAccount.BankAccount = bkacct NO-LOCK NO-ERROR.
366 IF NOT AVAILABLE(BankAccount) THEN DO:
367 bkacct = SUBSTRING( bkacct, 1, 13) + "0" + SUBSTRING( bkacct, 14, 2).
368 FIND FIRST BankAccount WHERE BankAccount.BankAccount BEGINS bkacct NO-LOCK NO-ERROR.
369 IF NOT AVAILABLE(BankAccount) THEN DO:
370 result = "-->No bank account available with account code "
371 + STRING( bkacct, "XX-XXXX-XXXXXXX-XXX") .
372 RETURN.
373 END.
374 END.
376 cheque-no = INTEGER( chqnum ).
377 FIND Cheque WHERE Cheque.BankAccountCode = BankAccount.BankAccountCode
378 AND Cheque.ChequeNo = cheque-no EXCLUSIVE-LOCK NO-ERROR.
379 IF NOT AVAILABLE(Cheque) THEN DO:
380 result = "-->Cheque" + STRING(cheque-no,">999999")
381 + " presented for " + TRIM(STRING( amount, ">>>,>>>,>>9.99"))
382 + " but no record of issue - ignored!".
383 RETURN.
384 END.
386 IF amount <> Cheque.Amount THEN DO:
387 result = "-->Cheque" + STRING(cheque-no,">999999") + " issued for " + TRIM(STRING( Cheque.Amount, ">>>,>>>,>>9.99"))
388 + " but presented for " + TRIM(STRING( amount, ">>>,>>>,>>9.99")).
389 MESSAGE result SKIP(1)
390 "Cheque not marked as presented!"
391 VIEW-AS ALERT-BOX WARNING TITLE "Error in presented amount!".
392 RETURN.
393 END.
395 ASSIGN Cheque.DatePresented = prdate
396 Cheque.PresentedAmount = amount.
398 result = "Cheque record updated".
400 END PROCEDURE.
402 /* _UIB-CODE-BLOCK-END */
403 &ANALYZE-RESUME
405 &ENDIF
407 &IF DEFINED(EXCLUDE-match-exception) = 0 &THEN
409 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE match-exception Procedure
410 PROCEDURE match-exception :
411 /*------------------------------------------------------------------------------
412 Purpose:
413 ------------------------------------------------------------------------------*/
414 DEF INPUT PARAMETER trn-type AS CHAR NO-UNDO.
415 DEF INPUT PARAMETER other-party AS CHAR NO-UNDO.
416 DEF INPUT PARAMETER ref-text AS CHAR NO-UNDO.
417 DEF OUTPUT PARAMETER result AS CHAR NO-UNDO.
419 FOR EACH BankImportException WHERE BankAccount.BankAccountCode = BankImportException.BankAccountCode NO-LOCK:
420 IF trn-type MATCHES BankImportException.TrnType
421 AND other-party MATCHES BankImportException.Match1
422 AND ref-text MATCHES BankImportException.Match2
423 THEN DO:
424 IF BankImport.EntityType = ? OR BankImportException.EntityCode = ?
425 OR BankImportException.AccountCode = ? THEN DO:
426 IF create-receipts THEN DELETE NewAcctTrans.
427 result = "skipped - no transaction created - " + BankImportException.Description.
428 RETURN.
429 END.
430 IF create-receipts THEN DO:
431 NewAcctTrans.EntityType = BankImportException.EntityType .
432 NewAcctTrans.EntityCode = BankImportException.EntityCode .
433 NewAcctTrans.AccountCode = BankImportException.AccountCode .
434 NewAcctTrans.Description = BankImportException.Description.
435 IF NewAcctTrans.Description = ? OR TRIM(NewAcctTrans.Description) = "" THEN
436 NewAcctTrans.Description = receipts-description.
437 END.
438 result = "Matched exception to " + BankImportException.EntityType + STRING(BankImportException.EntityCode, "99999")
439 + "/" + STRING(BankImportException.AccountCode,"9999.99")
440 + " - " + BankImportException.Description.
441 RETURN.
442 END.
443 END.
445 END PROCEDURE.
447 /* _UIB-CODE-BLOCK-END */
448 &ANALYZE-RESUME
450 &ENDIF
452 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
454 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
455 PROCEDURE parse-parameters :
456 /*------------------------------------------------------------------------------
457 Purpose:
458 ------------------------------------------------------------------------------*/
459 DEF VAR token AS CHAR NO-UNDO.
460 DEF VAR i AS INT NO-UNDO.
462 {inc/showopts.i "report-options"}
464 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
465 token = ENTRY( i, report-options, "~n" ).
467 CASE ENTRY( 1, token ):
468 WHEN "Preview" THEN preview = Yes.
469 WHEN "CreateReceipts" THEN create-receipts = Yes.
470 WHEN "FileName" THEN in-file = SUBSTRING( token, INDEX(token,",") + 1).
471 END CASE.
473 END.
475 END PROCEDURE.
477 /* _UIB-CODE-BLOCK-END */
478 &ANALYZE-RESUME
480 &ENDIF
482 &IF DEFINED(EXCLUDE-present-cheques) = 0 &THEN
484 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE present-cheques Procedure
485 PROCEDURE present-cheques :
486 /*------------------------------------------------------------------------------
487 Purpose: Mark cheques in BNZ export file as presented.
488 ------------------------------------------------------------------------------*/
489 DEF VAR bk-acct AS CHAR NO-UNDO.
490 DEF VAR bk-code AS CHAR NO-UNDO.
491 DEF VAR tr-amnt AS DEC NO-UNDO. /* amount */
492 DEF VAR tr-cheque AS DEC NO-UNDO. /* cheque no */
493 DEF VAR tr-type AS INT NO-UNDO.
494 DEF VAR tr-type2 AS CHAR NO-UNDO.
495 DEF VAR tr-date AS CHAR NO-UNDO. /* date presented */
497 DEF VAR tr-text AS CHAR NO-UNDO.
498 DEF VAR tr-payee AS CHAR NO-UNDO.
499 DEF VAR in-line AS CHAR NO-UNDO.
500 DEF VAR i AS INT NO-UNDO.
501 DEF VAR pos AS INT NO-UNDO.
502 DEF VAR result AS CHAR NO-UNDO.
504 INPUT FROM VALUE( in-file ).
505 REPEAT:
506 csv-clear-fields().
507 IF csv-import-line() = ? THEN LEAVE. /* file processed */
508 IF LENGTH( csv-get-field(9) ) > 9 THEN NEXT.
509 IF LENGTH( csv-get-field(9) ) < 1 THEN NEXT.
511 tr-type = to-number( csv-get-field(9) ).
512 IF tr-type < 10 OR tr-type > 99 THEN NEXT.
514 bk-acct = csv-get-field(1).
515 bk-code = find-bank-account( bk-acct ).
516 tr-amnt = to-number( csv-get-field(4)).
517 tr-cheque = 0.
518 IF tr-type = 41 THEN DO:
519 ASSIGN tr-cheque = to-number( csv-get-field(7) ) NO-ERROR.
520 END.
521 tr-text = STRING( csv-get-field(5), "X(12)") + STRING( csv-get-field(6), "X(12)") + csv-get-field(7).
522 tr-payee = csv-get-field(8).
523 tr-date = csv-get-field(3).
524 tr-text = TRIM(tr-text).
525 tr-payee = TRIM(tr-payee).
527 line = STRING( tr-date, "X(11)")
528 + STRING( bk-acct, "X(20)")
529 + (IF bk-code = ? THEN "****" ELSE STRING( bk-code, "XXXX")) + " "
530 + STRING( tr-type, ">>9") + " "
531 + (IF tr-cheque > 0 AND tr-cheque <= 9999999.0 THEN STRING( tr-cheque, ">999999") ELSE FILL(" ",7)) + " "
532 + STRING( tr-payee, "X(21)")
533 + STRING( tr-text, "X(37)")
534 + STRING( tr-amnt, ">>>,>>>,>>9.99CR")
535 + " || ".
537 IF bk-code = ? THEN
538 result = "Unknown bank account '" + (IF bk-acct = ? THEN "???????????" ELSE bk-acct) + "'".
539 ELSE IF tr-type <> 41 THEN
540 RUN create-receipt-transaction( bk-acct, tr-type, tr-date, tr-text, tr-payee, tr-amnt, OUTPUT result ).
541 ELSE IF tr-cheque > 0 AND tr-cheque <= 9999999 AND tr-amnt < 0 THEN
542 RUN mark-as-presented( bk-acct, tr-cheque, tr-date, - tr-amnt, OUTPUT result ) .
543 /* ELSE /* treat as if receipt anyway */
544 RUN create-receipt-transaction( bk-acct, tr-type, tr-date, tr-text, tr-payee, tr-amnt, OUTPUT result ).
547 RUN pclrep-line( base-font, line + result).
548 END.
549 INPUT CLOSE.
551 END PROCEDURE.
553 /* _UIB-CODE-BLOCK-END */
554 &ANALYZE-RESUME
556 &ENDIF
558 /* ************************ Function Implementations ***************** */
560 &IF DEFINED(EXCLUDE-find-bank-account) = 0 &THEN
562 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION find-bank-account Procedure
563 FUNCTION find-bank-account RETURNS CHARACTER
564 ( INPUT bkacct AS CHAR ) :
565 /*------------------------------------------------------------------------------
566 Purpose:
567 Notes:
568 ------------------------------------------------------------------------------*/
570 DEF BUFFER BankAcct FOR BankAccount.
572 bkacct = REPLACE( bkacct, "-", "").
573 FIND FIRST BankAcct WHERE BankAcct.BankAccount = bkacct NO-LOCK NO-ERROR.
574 IF NOT AVAILABLE(BankAcct) THEN DO:
575 bkacct = SUBSTRING( bkacct, 1, 13) + "0" + SUBSTRING( bkacct, 14, 2).
576 FIND FIRST BankAcct WHERE BankAcct.BankAccount BEGINS bkacct NO-LOCK NO-ERROR.
577 IF NOT AVAILABLE(BankAcct) THEN RETURN ?.
578 END.
580 RETURN BankAcct.BankAccountCode. /* Function return value. */
582 END FUNCTION.
584 /* _UIB-CODE-BLOCK-END */
585 &ANALYZE-RESUME
587 &ENDIF
589 &IF DEFINED(EXCLUDE-find-tenant-code) = 0 &THEN
591 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION find-tenant-code Procedure
592 FUNCTION find-tenant-code RETURNS INTEGER
593 ( INPUT t1 AS CHAR, INPUT t2 AS CHAR ) :
594 /*------------------------------------------------------------------------------
595 Purpose: Figure the tenant code from bank statement references
596 ------------------------------------------------------------------------------*/
597 DEF VAR pos AS INT NO-UNDO.
598 DEF VAR tc AS INT NO-UNDO INITIAL ?.
600 t1 = TRIM(t1).
601 pos = R-INDEX( t1, "T").
602 IF pos > (LENGTH(t1) - 7) THEN tc = to-number( SUBSTRING(t1, pos + 1) ).
603 FIND Tenant WHERE Tenant.TenantCode = tc NO-LOCK NO-ERROR.
604 IF NOT AVAILABLE(Tenant) THEN tc = ?.
605 IF tc <> ? THEN RETURN tc.
607 pos = R-INDEX( t1, " ").
608 IF pos > (LENGTH(t1) - 6) AND pos < (LENGTH(t1) - 4) THEN
609 tc = to-number( SUBSTRING(t1, pos + 1) ).
610 ELSE IF pos = 24 AND SUBSTRING(t1, pos + 1, 7) = "0000000" THEN
611 tc = to-number( SUBSTRING(t1, pos + 8) ).
613 FIND Tenant WHERE Tenant.TenantCode = tc NO-LOCK NO-ERROR.
614 IF NOT AVAILABLE(Tenant) THEN tc = ?.
616 RETURN tc.
618 END FUNCTION.
620 /* _UIB-CODE-BLOCK-END */
621 &ANALYZE-RESUME
623 &ENDIF