Really, this should be it, for the passing income.
[capital-apms-progress.git] / process / bknzbnz.p
blob3dbd0acf0381606482c2bc663d0f117af59071c1
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( 1, v-date, "/")).
165 mm = INT( ENTRY( 2, v-date, "/")).
166 yy = INT( ENTRY( 3, 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.
173 i-date = DATE( mm, dd, yy).
175 END PROCEDURE.
177 /* _UIB-CODE-BLOCK-END */
178 &ANALYZE-RESUME
180 &ENDIF
182 &IF DEFINED(EXCLUDE-create-bank-transaction) = 0 &THEN
184 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-bank-transaction Procedure
185 PROCEDURE create-bank-transaction :
186 /*------------------------------------------------------------------------------
187 Purpose:
188 ------------------------------------------------------------------------------*/
190 IF NOT AVAILABLE(NewBatch) THEN RETURN.
191 IF bank-ec = ? THEN RETURN.
192 IF bank-amount = ? THEN RETURN.
193 IF bank-ac = ? THEN RETURN.
194 IF last-prdate = ? THEN RETURN.
196 IF NOT create-receipts THEN RETURN.
198 CREATE NewDocument.
199 NewDocument.BatchCode = NewBatch.BatchCode.
200 NewDocument.DocumentType = "RCBK".
201 NewDocument.Reference = STRING(NewBatch.BatchCode) + "/" + STRING(NewDocument.DocumentCode).
202 NewDocument.Description = "Banking Summary " + STRING(last-prdate, "99/99/9999").
204 CREATE NewAcctTrans.
205 NewAcctTrans.BatchCode = NewBatch.BatchCode.
206 NewAcctTrans.DocumentCode = NewDocument.DocumentCode.
207 NewAcctTrans.EntityType = "L".
208 NewAcctTrans.EntityCode = bank-ec.
209 NewAcctTrans.AccountCode = bank-ac.
210 NewAcctTrans.Date = last-prdate.
211 NewAcctTrans.Amount = bank-amount.
213 bank-amount = 0.
214 END PROCEDURE.
216 /* _UIB-CODE-BLOCK-END */
217 &ANALYZE-RESUME
219 &ENDIF
221 &IF DEFINED(EXCLUDE-create-receipt-transaction) = 0 &THEN
223 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-receipt-transaction Procedure
224 PROCEDURE create-receipt-transaction :
225 /*------------------------------------------------------------------------------
226 Purpose:
227 ------------------------------------------------------------------------------*/
228 DEF INPUT PARAMETER in-bkacct AS CHAR NO-UNDO.
229 DEF INPUT PARAMETER tr-type AS CHAR NO-UNDO.
230 DEF INPUT PARAMETER indate AS CHAR NO-UNDO.
231 DEF INPUT PARAMETER text1 AS CHAR NO-UNDO.
232 DEF INPUT PARAMETER text2 AS CHAR NO-UNDO.
233 DEF INPUT PARAMETER amount AS DEC NO-UNDO.
234 DEF OUTPUT PARAMETER result AS CHAR NO-UNDO INITIAL "".
236 DEF VAR bkacct AS CHAR NO-UNDO.
237 DEF VAR prdate AS DATE NO-UNDO.
238 DEF VAR tenant-code AS INT NO-UNDO.
239 DEF VAR tr-description AS CHAR NO-UNDO.
240 DEF VAR tr-reference AS CHAR NO-UNDO.
242 RUN convert-bank-date( indate, OUTPUT prdate ).
244 bkacct = REPLACE( in-bkacct, "-", "").
245 FIND FIRST BankAccount WHERE BankAccount.BankAccount = bkacct NO-LOCK NO-ERROR.
246 IF NOT AVAILABLE(BankAccount) THEN DO:
247 bkacct = SUBSTRING( bkacct, 1, 13) + "0" + SUBSTRING( bkacct, 14, 2).
248 FIND FIRST BankAccount WHERE BankAccount.BankAccount BEGINS bkacct NO-LOCK NO-ERROR.
249 IF NOT AVAILABLE(BankAccount) THEN DO:
250 result = "-->No bank account available with account code '" + in-bkacct + "'".
251 RETURN.
252 END.
253 END.
255 tenant-code = find-tenant-code( text1, text2).
256 IF tenant-code = ? THEN DO:
257 tr-description = TRIM(text2) + " " + TRIM(text1).
258 tenant-code = suspense-tenant-ec.
259 END.
260 ELSE
261 tr-description = receipts-description.
263 FIND Tenant WHERE Tenant.TenantCode = tenant-code NO-LOCK NO-ERROR.
264 IF NOT AVAILABLE(Tenant) THEN DO:
265 /* should only occur if the suspense tenant doesn't exist */
266 result = "-->Tenant " + STRING(tenant-code,"99999") + " not on file.".
267 RETURN.
268 END.
270 DO TRANSACTION:
271 IF create-receipts THEN DO:
272 IF bank-ec <> BankAccount.CompanyCode OR bank-ac <> BankAccount.AccountCode THEN DO:
273 RUN create-bank-transaction.
275 CREATE NewBatch.
276 NewBatch.BatchType = "NORM".
277 NewBatch.Description = "Automatic receipts " + STRING( TODAY, "99/99/9999") + ", " + in-bkacct.
279 CREATE NewDocument.
280 NewDocument.BatchCode = NewBatch.BatchCode.
281 NewDocument.DocumentType = "RCPT".
282 NewDocument.Reference = STRING(NewBatch.BatchCode) + "/" + STRING(NewDocument.DocumentCode).
283 NewDocument.Description = NewBatch.Description.
284 END.
286 CREATE NewAcctTrans.
287 NewAcctTrans.BatchCode = NewBatch.BatchCode.
288 NewAcctTrans.DocumentCode = NewDocument.DocumentCode.
289 NewAcctTrans.EntityType = "T".
290 NewAcctTrans.EntityCode = tenant-code.
291 NewAcctTrans.AccountCode = sundry-debtors.
292 NewAcctTrans.Date = prdate.
293 NewAcctTrans.Amount = amount.
294 NewAcctTrans.Reference = STRING(NewBatch.BatchCode) + "/" + STRING(NewDocument.DocumentCode) + "/" + STRING(NewAcctTrans.TransactionCode).
295 NewAcctTrans.Description = tr-description.
296 END.
298 RUN match-exception(tr-type, text2, text1, OUTPUT result).
299 END.
301 last-prdate = prdate.
302 bank-ec = BankAccount.CompanyCode.
303 bank-ac = BankAccount.AccountCode.
304 bank-amount = bank-amount + amount.
306 IF result = "" THEN
307 result = "Receipt from " + STRING( Tenant.Name, "X(30)") + " "
308 + "T" + STRING( Tenant.TenantCode, "99999") + "/" + Tenant.EntityType + STRING( Tenant.EntityCode, "99999").
310 RETURN.
312 END PROCEDURE.
314 /* _UIB-CODE-BLOCK-END */
315 &ANALYZE-RESUME
317 &ENDIF
319 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
321 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
322 PROCEDURE inst-page-header :
323 /*------------------------------------------------------------------------------
324 Purpose:
325 ------------------------------------------------------------------------------*/
326 RUN pclrep-line( time-font, timeStamp + CHR(13) + FILL(" ",350) + "Page " + STRING(pclrep-page-number)).
327 RUN pclrep-down-by(1).
328 RUN pclrep-line( header-font, hline2).
329 RUN pclrep-line( header-font, hline3).
330 RUN pclrep-down-by(0.5).
331 RUN pclrep-line( base-font + ",bold", " Date Account Number Bank Type Cheque Other Party Reference Amount || Import Program Action taken").
332 RUN pclrep-line( base-font + ",bold", " (TT) (Match1) (Match2)").
333 RUN pclrep-down-by(0.3).
335 END PROCEDURE.
337 /* _UIB-CODE-BLOCK-END */
338 &ANALYZE-RESUME
340 &ENDIF
342 &IF DEFINED(EXCLUDE-mark-as-presented) = 0 &THEN
344 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE mark-as-presented Procedure
345 PROCEDURE mark-as-presented :
346 /*------------------------------------------------------------------------------
347 Purpose:
348 ------------------------------------------------------------------------------*/
349 DEF INPUT PARAMETER bkacct AS CHAR NO-UNDO.
350 DEF INPUT PARAMETER chqnum AS INT NO-UNDO.
351 DEF INPUT PARAMETER indate AS CHAR NO-UNDO.
352 DEF INPUT PARAMETER amount AS DEC NO-UNDO.
353 DEF OUTPUT PARAMETER result AS CHAR NO-UNDO INITIAL "".
355 DEF VAR cheque-no AS INT NO-UNDO.
356 DEF VAR prdate AS DATE NO-UNDO.
358 RUN convert-bank-date( indate, OUTPUT prdate ).
360 bkacct = REPLACE( bkacct, "-", "").
361 FIND FIRST BankAccount WHERE BankAccount.BankAccount = bkacct NO-LOCK NO-ERROR.
362 IF NOT AVAILABLE(BankAccount) THEN DO:
363 bkacct = SUBSTRING( bkacct, 1, 13) + "0" + SUBSTRING( bkacct, 14, 2).
364 FIND FIRST BankAccount WHERE BankAccount.BankAccount BEGINS bkacct NO-LOCK NO-ERROR.
365 IF NOT AVAILABLE(BankAccount) THEN DO:
366 result = "-->No bank account available with account code "
367 + STRING( bkacct, "XX-XXXX-XXXXXXX-XXX") .
368 RETURN.
369 END.
370 END.
372 cheque-no = INTEGER( chqnum ).
373 FIND Cheque WHERE Cheque.BankAccountCode = BankAccount.BankAccountCode
374 AND Cheque.ChequeNo = cheque-no EXCLUSIVE-LOCK NO-ERROR.
375 IF NOT AVAILABLE(Cheque) THEN DO:
376 result = "-->Cheque" + STRING(cheque-no,">999999")
377 + " presented for " + TRIM(STRING( amount, ">>>,>>>,>>9.99"))
378 + " but no record of issue - ignored!".
379 RETURN.
380 END.
382 IF amount <> Cheque.Amount THEN DO:
383 result = "-->Cheque" + STRING(cheque-no,">999999") + " issued for " + TRIM(STRING( Cheque.Amount, ">>>,>>>,>>9.99"))
384 + " but presented for " + TRIM(STRING( amount, ">>>,>>>,>>9.99")).
385 MESSAGE result SKIP(1)
386 "Cheque not marked as presented!"
387 VIEW-AS ALERT-BOX WARNING TITLE "Error in presented amount!".
388 RETURN.
389 END.
391 ASSIGN Cheque.DatePresented = prdate
392 Cheque.PresentedAmount = amount.
394 result = "Cheque record updated".
396 END PROCEDURE.
398 /* _UIB-CODE-BLOCK-END */
399 &ANALYZE-RESUME
401 &ENDIF
403 &IF DEFINED(EXCLUDE-match-exception) = 0 &THEN
405 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE match-exception Procedure
406 PROCEDURE match-exception :
407 /*------------------------------------------------------------------------------
408 Purpose:
409 ------------------------------------------------------------------------------*/
410 DEF INPUT PARAMETER trn-type AS CHAR NO-UNDO.
411 DEF INPUT PARAMETER other-party AS CHAR NO-UNDO.
412 DEF INPUT PARAMETER ref-text AS CHAR NO-UNDO.
413 DEF OUTPUT PARAMETER result AS CHAR NO-UNDO.
415 FOR EACH BankImportException WHERE BankAccount.BankAccountCode = BankImportException.BankAccountCode NO-LOCK:
416 IF trn-type MATCHES BankImportException.TrnType
417 AND other-party MATCHES BankImportException.Match1
418 AND ref-text MATCHES BankImportException.Match2
419 THEN DO:
420 IF BankImport.EntityType = ? OR BankImportException.EntityCode = ?
421 OR BankImportException.AccountCode = ? THEN DO:
422 IF create-receipts THEN DELETE NewAcctTrans.
423 result = "skipped - no transaction created - " + BankImportException.Description.
424 RETURN.
425 END.
426 IF create-receipts THEN DO:
427 NewAcctTrans.EntityType = BankImportException.EntityType .
428 NewAcctTrans.EntityCode = BankImportException.EntityCode .
429 NewAcctTrans.AccountCode = BankImportException.AccountCode .
430 NewAcctTrans.Description = BankImportException.Description.
431 IF NewAcctTrans.Description = ? OR TRIM(NewAcctTrans.Description) = "" THEN
432 NewAcctTrans.Description = receipts-description.
433 END.
434 result = "Matched exception to " + BankImportException.EntityType + STRING(BankImportException.EntityCode, "99999")
435 + "/" + STRING(BankImportException.AccountCode,"9999.99")
436 + " - " + BankImportException.Description.
437 RETURN.
438 END.
439 END.
441 END PROCEDURE.
443 /* _UIB-CODE-BLOCK-END */
444 &ANALYZE-RESUME
446 &ENDIF
448 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
450 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
451 PROCEDURE parse-parameters :
452 /*------------------------------------------------------------------------------
453 Purpose:
454 ------------------------------------------------------------------------------*/
455 DEF VAR token AS CHAR NO-UNDO.
456 DEF VAR i AS INT NO-UNDO.
458 {inc/showopts.i "report-options"}
460 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
461 token = ENTRY( i, report-options, "~n" ).
463 CASE ENTRY( 1, token ):
464 WHEN "Preview" THEN preview = Yes.
465 WHEN "CreateReceipts" THEN create-receipts = Yes.
466 WHEN "FileName" THEN in-file = SUBSTRING( token, INDEX(token,",") + 1).
467 END CASE.
469 END.
471 END PROCEDURE.
473 /* _UIB-CODE-BLOCK-END */
474 &ANALYZE-RESUME
476 &ENDIF
478 &IF DEFINED(EXCLUDE-present-cheques) = 0 &THEN
480 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE present-cheques Procedure
481 PROCEDURE present-cheques :
482 /*------------------------------------------------------------------------------
483 Purpose: Mark cheques in BNZ export file as presented.
484 ------------------------------------------------------------------------------*/
485 DEF VAR bk-acct AS CHAR NO-UNDO.
486 DEF VAR bk-code AS CHAR NO-UNDO.
487 DEF VAR tr-amnt AS DEC NO-UNDO. /* amount */
488 DEF VAR tr-cheque AS DEC NO-UNDO. /* cheque no */
489 DEF VAR tr-type AS INT NO-UNDO.
490 DEF VAR tr-type2 AS CHAR NO-UNDO.
491 DEF VAR tr-date AS CHAR NO-UNDO. /* date presented */
493 DEF VAR tr-text AS CHAR NO-UNDO.
494 DEF VAR tr-payee AS CHAR NO-UNDO.
495 DEF VAR in-line AS CHAR NO-UNDO.
496 DEF VAR i AS INT NO-UNDO.
497 DEF VAR pos AS INT NO-UNDO.
498 DEF VAR result AS CHAR NO-UNDO.
500 INPUT FROM VALUE( in-file ).
501 REPEAT:
502 csv-clear-fields().
503 IF csv-import-line() = ? THEN LEAVE. /* file processed */
504 IF LENGTH( csv-get-field(1) ) > 3 THEN NEXT.
506 tr-type = to-number( csv-get-field(1) ).
507 IF tr-type <> 3 THEN NEXT.
509 /* We ignore field 2 (corporate ID) */
510 bk-acct = csv-get-field(3).
511 bk-code = find-bank-account( bk-acct ).
512 tr-amnt = to-number( csv-get-field(4)).
513 ASSIGN tr-cheque = to-number( csv-get-field(5) ) NO-ERROR.
514 IF file-format = "ANZ" THEN DO:
515 tr-type = to-number( csv-get-field(6) ).
516 tr-type2 = csv-get-field(7).
517 tr-text = STRING( csv-get-field(8), "X(12)") + STRING( csv-get-field(9), "X(12)") + csv-get-field(10).
518 tr-payee = csv-get-field(11).
519 tr-date = csv-get-field(12).
520 END.
521 ELSE IF file-format = "BNZ" THEN DO:
522 tr-type = to-number( csv-get-field(6) ).
523 tr-text = TRIM(STRING( csv-get-field(7), "X(12)") + STRING( csv-get-field(8), "X(12)") + csv-get-field(9)).
524 tr-payee = csv-get-field(10).
525 tr-date = csv-get-field(11).
526 tr-type2 = csv-get-field(13).
527 END.
528 ELSE DO:
529 MESSAGE file-format "is an unknown file format".
530 RETURN "FAIL".
531 END.
532 tr-text = TRIM(tr-text).
533 tr-payee = TRIM(tr-payee).
535 line = STRING( tr-date, "X(11)")
536 + STRING( bk-acct, "X(20)")
537 + (IF bk-code = ? THEN "****" ELSE STRING( bk-code, "XXXX")) + " "
538 + STRING( tr-type, ">>9") + " "
539 + STRING( tr-type2, "X(3)")
540 + (IF tr-cheque > 0 AND tr-cheque <= 9999999.0 THEN STRING( tr-cheque, ">999999") ELSE FILL(" ",7)) + " "
541 + STRING( tr-payee, "X(21)")
542 + STRING( tr-text, "X(37)")
543 + STRING( tr-amnt, ">>>,>>>,>>9.99CR")
544 + " || ".
546 IF bk-code = ? THEN
547 result = "Unknown bank account '" + (IF bk-acct = ? THEN "???????????" ELSE bk-acct) + "'".
548 ELSE IF LOOKUP( tr-type2, "AP,DC,DD,MM") > 0 THEN
549 RUN create-receipt-transaction( bk-acct, tr-type2, tr-date, tr-text, tr-payee, tr-amnt, OUTPUT result ).
550 ELSE IF tr-cheque > 0 AND tr-cheque <= 9999999 AND tr-amnt < 0 THEN
551 RUN mark-as-presented( bk-acct, tr-cheque, tr-date, - tr-amnt, OUTPUT result ) .
552 ELSE /* treat as if receipt anyway */
553 RUN create-receipt-transaction( bk-acct, tr-type2, tr-date, tr-text, tr-payee, tr-amnt, OUTPUT result ).
555 RUN pclrep-line( base-font, line + result).
556 END.
557 INPUT CLOSE.
559 END PROCEDURE.
561 /* _UIB-CODE-BLOCK-END */
562 &ANALYZE-RESUME
564 &ENDIF
566 /* ************************ Function Implementations ***************** */
568 &IF DEFINED(EXCLUDE-find-bank-account) = 0 &THEN
570 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION find-bank-account Procedure
571 FUNCTION find-bank-account RETURNS CHARACTER
572 ( INPUT bkacct AS CHAR ) :
573 /*------------------------------------------------------------------------------
574 Purpose:
575 Notes:
576 ------------------------------------------------------------------------------*/
578 DEF BUFFER BankAcct FOR BankAccount.
580 bkacct = REPLACE( bkacct, "-", "").
581 FIND FIRST BankAcct WHERE BankAcct.BankAccount = bkacct NO-LOCK NO-ERROR.
582 IF NOT AVAILABLE(BankAcct) THEN DO:
583 bkacct = SUBSTRING( bkacct, 1, 13) + "0" + SUBSTRING( bkacct, 14, 2).
584 FIND FIRST BankAcct WHERE BankAcct.BankAccount BEGINS bkacct NO-LOCK NO-ERROR.
585 IF NOT AVAILABLE(BankAcct) THEN RETURN ?.
586 END.
588 RETURN BankAcct.BankAccountCode. /* Function return value. */
590 END FUNCTION.
592 /* _UIB-CODE-BLOCK-END */
593 &ANALYZE-RESUME
595 &ENDIF
597 &IF DEFINED(EXCLUDE-find-tenant-code) = 0 &THEN
599 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION find-tenant-code Procedure
600 FUNCTION find-tenant-code RETURNS INTEGER
601 ( INPUT t1 AS CHAR, INPUT t2 AS CHAR ) :
602 /*------------------------------------------------------------------------------
603 Purpose: Figure the tenant code from bank statement references
604 ------------------------------------------------------------------------------*/
605 DEF VAR pos AS INT NO-UNDO.
606 DEF VAR tc AS INT NO-UNDO INITIAL ?.
608 t1 = TRIM(t1).
609 pos = R-INDEX( t1, "T").
610 IF pos > (LENGTH(t1) - 7) THEN tc = to-number( SUBSTRING(t1, pos + 1) ).
611 FIND Tenant WHERE Tenant.TenantCode = tc NO-LOCK NO-ERROR.
612 IF NOT AVAILABLE(Tenant) THEN tc = ?.
613 IF tc <> ? THEN RETURN tc.
615 pos = R-INDEX( t1, " ").
616 IF pos > (LENGTH(t1) - 6) AND pos < (LENGTH(t1) - 4) THEN
617 tc = to-number( SUBSTRING(t1, pos + 1) ).
618 ELSE IF pos = 24 AND SUBSTRING(t1, pos + 1, 7) = "0000000" THEN
619 tc = to-number( SUBSTRING(t1, pos + 8) ).
621 FIND Tenant WHERE Tenant.TenantCode = tc NO-LOCK NO-ERROR.
622 IF NOT AVAILABLE(Tenant) THEN tc = ?.
624 RETURN tc.
626 END FUNCTION.
628 /* _UIB-CODE-BLOCK-END */
629 &ANALYZE-RESUME
631 &ENDIF