1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
6 NOTE
: this is written for a PCL5 compatible printer
7 ------------------------------------------------------------------------*/
9 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
10 DEF VAR bank-account
LIKE Cheque.BankAccountCode
NO-UNDO.
11 DEF VAR cheque-from
LIKE Cheque.ChequeNo
NO-UNDO.
12 DEF VAR cheque-to
LIKE Cheque.ChequeNo
NO-UNDO.
13 DEF VAR msg-text
AS CHAR NO-UNDO.
14 DEF VAR preview
AS LOGI
INIT No
NO-UNDO.
17 /* Line definitions
*/
19 DEF VAR date-in-words
AS CHAR NO-UNDO.
20 DEF VAR creditor-address
AS CHAR NO-UNDO.
21 DEF VAR is-manual-feed
AS LOGI
NO-UNDO INITIAL No.
22 DEF VAR this-cheque-printed
AS LOGI
NO-UNDO INITIAL No.
23 DEF VAR logo-codes
AS CHAR NO-UNDO.
25 DEF VAR address-font
AS CHAR NO-UNDO INITIAL "proportional,times,point,12,lpi,5.7,normal".
26 DEF VAR big-font
AS CHAR NO-UNDO INITIAL "proportional,times,point,18,lpi,3.9,bold".
27 DEF VAR lptr-font
AS CHAR NO-UNDO INITIAL "fixed,lineprinter,pitch,16.66,lpi,8,normal".
29 DEF VAR in-usage-summary
AS LOGI
NO-UNDO INITIAL No.
30 DEF VAR n-vouchers
AS INT NO-UNDO.
32 DEF VAR gst-applies
AS LOGI
NO-UNDO.
34 gst-applies
= Office.GST
<> ?.
35 {inc
/ofc-set-l.i
"BNZ-cheque-layout" "bnz-cheque-layout"}
37 DEF VAR user-name
AS CHAR NO-UNDO.
38 {inc
/username.i
"user-name"}
41 DEFINE TEMP-TABLE PaidVoucher
NO-UNDO
42 FIELD Date
LIKE Voucher.Date
43 FIELD VoucherSeq
LIKE Voucher.VoucherSeq
44 FIELD InvoiceReference
LIKE Voucher.InvoiceReference
45 FIELD TotalValue
LIKE Voucher.GoodsValue
46 INDEX XPKDate
IS UNIQUE PRIMARY Date VoucherSeq.
48 /* HP Printer Bin Assignments
*/
50 &SCOPED-DEFINE PRIORITY 0 /* Priority - Manual Feed, Tray2, Tray3 */
51 &SCOPED-DEFINE TRAY_2 1 /* Tray 2 only */
52 &SCOPED-DEFINE MANUAL_FEED_A4 2 /* Manual Feed A$ Tray 1 */
53 &SCOPED-DEFINE MANUAL_FEED_ENV 3 /* Maunal Feed Envelope Tray 1 */
54 &SCOPED-DEFINE PRIORITY_2 4 /* Priority - Tray2, Tray3 */
55 &SCOPED-DEFINE TRAY_3 5 /* Tray 3 only */
57 /* _UIB-CODE-BLOCK-END
*/
61 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
63 /* ******************** Preprocessor Definitions
******************** */
65 &Scoped-define PROCEDURE-TYPE Procedure
66 &Scoped-define DB-AWARE no
70 /* _UIB-PREPROCESSOR-BLOCK-END
*/
75 /* *********************** Procedure Settings
************************ */
77 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
78 /* Settings for
THIS-PROCEDURE
82 Add Fields to
: Neither
83 Other Settings
: CODE-ONLY
COMPILE
85 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
87 /* ************************* Create Window
************************** */
89 &ANALYZE-SUSPEND _CREATE-WINDOW
90 /* DESIGN Window definition
(used by the UIB
)
91 CREATE WINDOW Procedure
ASSIGN
94 /* END WINDOW DEFINITION
*/
98 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
99 /* ************************* Included-Libraries
*********************** */
101 {inc
/method
/m-hpgl.i
}
102 {inc
/method
/m-txtrep.i
}
106 /* _UIB-CODE-BLOCK-END
*/
113 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
116 /* *************************** Main Block
*************************** */
118 RUN pclrep-start
( preview
, "portrait,lm,8,tm,2," + lptr-font
).
119 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
122 /* RUN print-usage-summary.
*/
128 RUN print-summary-pages.
130 /* _UIB-CODE-BLOCK-END
*/
134 /* ********************** Internal Procedures
*********************** */
136 &IF DEFINED(EXCLUDE-get-bank-account) = 0 &THEN
138 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-bank-account Procedure
139 PROCEDURE get-bank-account
:
140 /*------------------------------------------------------------------------------
144 ------------------------------------------------------------------------------*/
146 FIND FIRST BankAccount
WHERE BankAccount.BankAccountCode
= bank-account
148 IF NOT AVAILABLE BankAccount
THEN RETURN "FAIL".
150 DEF VAR client-code
AS CHAR NO-UNDO.
151 client-code
= get-entity-client
( "L", BankAccount.CompanyCode
).
152 RUN client-logo
( "L", BankAccount.CompanyCode
, client-code
).
153 RUN client-address
( "L", BankAccount.CompanyCode
, client-code
).
154 RUN hpgl-get-codes
( yes
, yes
, OUTPUT logo-codes
).
158 /* _UIB-CODE-BLOCK-END
*/
163 &IF DEFINED(EXCLUDE-get-voucher-details) = 0 &THEN
165 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-voucher-details Procedure
166 PROCEDURE get-voucher-details
:
167 /*------------------------------------------------------------------------------
169 ------------------------------------------------------------------------------*/
171 FOR EACH PaidVoucher
: DELETE PaidVoucher.
END.
174 FOR EACH Voucher
NO-LOCK WHERE Voucher.BankAccountCode
= Cheque.BankAccountCode
175 AND Voucher.ChequeNo
= Cheque.ChequeNo
:
177 BUFFER-COPY Voucher
TO PaidVoucher
ASSIGN
178 PaidVoucher.TotalValue
= Voucher.GoodsValue
+ Voucher.TaxValue.
179 n-vouchers
= n-vouchers
+ 1.
184 /* _UIB-CODE-BLOCK-END
*/
189 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
191 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
192 PROCEDURE inst-page-footer
:
193 /*------------------------------------------------------------------------------
195 ------------------------------------------------------------------------------*/
199 /* _UIB-CODE-BLOCK-END
*/
204 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
206 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
207 PROCEDURE inst-page-header
:
208 /*------------------------------------------------------------------------------
210 ------------------------------------------------------------------------------*/
212 IF NOT( in-usage-summary
) THEN DO:
213 IF pclrep-page-number
> 1 THEN DO:
214 PUT UNFORMATTED pclrep-page-number
SKIP.
215 RUN print-remittance-header.
220 DEF VAR date-font
AS CHAR NO-UNDO INITIAL "Proportional,Times,Bold,Point,8".
221 DEF VAR head-font
AS CHAR NO-UNDO INITIAL "Proportional,Times,Bold,Point,18".
222 DEF VAR bank-font
AS CHAR NO-UNDO INITIAL "Proportional,Times,Bold,Point,8".
224 RUN pclrep-line
( date-font
, "~rPrinted at " + STRING( TIME, "HH:MM:SS" ) + ", " + STRING( TODAY, "99/99/9999" ) + " for " + user-name
225 + "~r" + FILL(" ",180) + "Page " + STRING(pclrep-page-number
) ).
226 RUN pclrep-down-by
(3).
228 RUN pclrep-line
( head-font
, FILL(" ",26) + "Cheque Usage Summary" ).
229 RUN pclrep-down-by
(3).
231 IF AVAILABLE BankAccount
THEN DO:
232 RUN pclrep-line
( bank-font
, "(L" + STRING( BankAccount.CompanyCode
, "9999" ) + " - " +
233 STRING( BankAccount.AccountCode
, "9999.99" ) + ") " +
234 BankAccount.BankName
+ ", " +
235 BankAccount.BankBranchName
+ ", " +
236 BankAccount.AccountName
+ " " +
237 "(" + STRING( BankAccount.BankAccount
) + ")" ).
238 RUN pclrep-down-by
(2).
241 RUN pclrep-line
( lptr-font
, "Cheque # Creditor Name" + FILL(" ",65) + "Amount").
242 RUN pclrep-down-by
(2).
246 /* _UIB-CODE-BLOCK-END
*/
251 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
253 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
254 PROCEDURE parse-parameters
:
255 /*------------------------------------------------------------------------------
259 ------------------------------------------------------------------------------*/
260 DEF VAR i
AS INT NO-UNDO.
261 DEF VAR token
AS CHAR NO-UNDO.
263 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
264 token
= ENTRY( i
, report-options
, "~n" ).
265 CASE( ENTRY( 1, token
) ):
266 WHEN "BankAccount" THEN bank-account
= TRIM(ENTRY(2,token
)).
267 WHEN "Message" THEN msg-text
= REPLACE( SUBSTRING(token
,9), CHR(7), "~n").
269 WHEN "ChequeRange" THEN ASSIGN
270 cheque-from
= INT(ENTRY(2,token
))
271 cheque-to
= INT(ENTRY(3,token
)).
277 /* _UIB-CODE-BLOCK-END
*/
282 &IF DEFINED(EXCLUDE-print-address) = 0 &THEN
284 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-address Procedure
285 PROCEDURE print-address
:
286 /*------------------------------------------------------------------------------
288 ------------------------------------------------------------------------------*/
289 DEF VAR i
AS INT NO-UNDO.
290 DEF VAR n
AS INT NO-UNDO.
291 DEF VAR skip-to
AS DEC NO-UNDO.
292 DEF VAR out-line
AS CHAR NO-UNDO.
294 creditor-address
= "".
295 FIND Creditor
OF Cheque
NO-LOCK.
296 RUN process
/getaddr.p
( "C", Creditor.CreditorCode
, "PYMT,POST,COUR", OUTPUT creditor-address
).
298 skip-to
= (IF preview
THEN 11.0 ELSE 41.0).
299 RUN pclrep-skip-to
( skip-to
).
301 n
= NUM-ENTRIES( creditor-address
, "~n" ).
304 IF i
<= n
THEN out-line
= ENTRY( i
, creditor-address
, "~n" ).
307 WHEN 3 THEN out-line
= out-line
+ CHR(13) + FILL(" ", 105) + STRING( Cheque.Date
, "99/99/9999" ).
308 WHEN 4 THEN out-line
= out-line
+ CHR(13) + FILL(" ", 108) + STRING( Cheque.ChequeNo
, "999999" ).
311 RUN pclrep-line
( address-font
, out-line
).
315 skip-to
= (IF preview
THEN 11.0 ELSE 65.0).
316 RUN pclrep-skip-to
( skip-to
).
318 RUN pclrep-line
( big-font
, FILL(" ",25) + "PAYMENT ADVICE").
319 RUN pclrep-line
( address-font
, "" ).
323 /* _UIB-CODE-BLOCK-END
*/
328 &IF DEFINED(EXCLUDE-print-advice-and-cheque) = 0 &THEN
330 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-advice-and-cheque Procedure
331 PROCEDURE print-advice-and-cheque
:
332 /*------------------------------------------------------------------------------
334 ------------------------------------------------------------------------------*/
335 DEF VAR i
AS INT NO-UNDO.
336 DEF VAR voucher-line
AS CHAR NO-UNDO.
337 DEF VAR voucher-base
AS DEC NO-UNDO.
339 this-cheque-printed
= No.
341 /* Print the vouchers
*/
342 FOR EACH PaidVoucher
:
343 IF pclrep-page-position
> 170 THEN DO:
344 RUN print-cheque-details.
345 RUN pclrep-page-break.
346 RUN set-automatic-feed.
348 RUN pclrep-line
( lptr-font
, FILL(" ", 10)
349 + STRING( PaidVoucher.Date
, "99/99/9999") + FILL(" ",17)
350 + STRING( PaidVoucher.VoucherSeq
, ">>99999" ) + FILL(" ",14)
351 + STRING( PaidVoucher.InvoiceReference
, "X(14)" ) + FILL(" ",11)
352 + STRING( PaidVoucher.TotalValue
, ">>,>>>,>>9.99CR" ) ).
355 /* Print the total
*/
356 RUN pclrep-line
( lptr-font
, FILL(" ",81) + FILL( "=", 15 ) ).
357 RUN pclrep-line
( lptr-font
, FILL(" ",83) + STRING( Cheque.Amount
, ">>,>>>,>>9.99CR" ) ).
359 /* Print the message
*/
360 IF msg-text
<> "" THEN DO:
362 RUN pclrep-line
( ?
, "").
364 RUN pclrep-skip-to
( (IF this-cheque-printed
THEN 240 ELSE 170.0) ).
366 DO i
= 1 TO NUM-ENTRIES( msg-text
, "~n" ):
367 RUN pclrep-line
( lptr-font
, ENTRY( i
, msg-text
, "~n" ) ).
371 IF NOT this-cheque-printed
THEN RUN print-cheque-details.
375 /* _UIB-CODE-BLOCK-END
*/
380 &IF DEFINED(EXCLUDE-print-cheque-details) = 0 &THEN
382 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-cheque-details Procedure
383 PROCEDURE print-cheque-details
:
384 /*------------------------------------------------------------------------------
385 Purpose
: We interrupt this broadcast to print a cheque...
386 ------------------------------------------------------------------------------*/
387 DEF VAR date-in-words
AS CHAR NO-UNDO.
388 DEF VAR sum-in-words
AS CHAR NO-UNDO.
389 DEF VAR i
AS INT NO-UNDO.
390 DEF VAR hpgl-cheque
AS CHAR NO-UNDO.
392 RUN date-to-word
( Cheque.Date
, OUTPUT date-in-words
).
393 RUN amount-to-word
( Cheque.Amount
, OUTPUT sum-in-words
).
394 RUN word-wrap
( sum-in-words
, 65, OUTPUT sum-in-words
).
395 SUBSTR( sum-in-words
, 1, 1 ) = CAPS( SUBSTR( sum-in-words
, 1, 1 ) ).
398 RUN hpgl-moveto
( 160, 71 ).
399 RUN hpgl-text
( "Times,Proportional,Point,14,Normal", date-in-words
).
400 RUN hpgl-moveto
( 20, 56 ).
401 RUN hpgl-text
( "Times,Proportional,Point,15,Normal", Cheque.PayeeName
).
403 DO i
= 1 TO NUM-ENTRIES( sum-in-words
, "~n" ):
404 RUN hpgl-moveto
( 20, 46 - (i
* 5) ).
405 RUN hpgl-text
( "Times,Proportional,Point,12,Normal", ENTRY( i
, sum-in-words
, "~n" ) ).
408 RUN hpgl-moveto
( 162, 41.5 ).
409 RUN hpgl-text
( "Times,Proportional,Point,14,Bold", TRIM( STRING( Cheque.Amount
, ">,>>>,>>>,>>9.99" )) ).
411 RUN hpgl-get-codes
( no
, no
, OUTPUT hpgl-cheque
).
412 PUT CONTROL hpgl-cheque.
414 /* trick the system into resetting the font
*/
415 RUN pclrep-line
( lptr-font
+ ",Bold", "").
416 RUN pclrep-line
( lptr-font
, "").
418 this-cheque-printed
= Yes.
422 /* _UIB-CODE-BLOCK-END
*/
427 &IF DEFINED(EXCLUDE-print-cheques) = 0 &THEN
429 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-cheques Procedure
430 PROCEDURE print-cheques
:
431 /*------------------------------------------------------------------------------
435 ------------------------------------------------------------------------------*/
436 RUN get-bank-account.
437 IF RETURN-VALUE = "FAIL" THEN RETURN.
439 FOR EACH Cheque
WHERE Cheque.BankAccountCode
= BankAccount.BankAccountCode
440 AND Cheque.ChequeNo
>= cheque-from
441 AND Cheque.ChequeNo
<= cheque-to
NO-LOCK:
442 /* start a new page which should be page
1.
*/
443 pclrep-page-number
= 1.
446 RUN print-logo-header.
448 RUN get-voucher-details.
449 RUN print-remittance-header.
450 RUN print-advice-and-cheque.
452 RUN pclrep-page-break.
455 RUN set-automatic-feed.
459 /* _UIB-CODE-BLOCK-END
*/
464 &IF DEFINED(EXCLUDE-print-logo-header) = 0 &THEN
466 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-logo-header Procedure
467 PROCEDURE print-logo-header
:
468 /*------------------------------------------------------------------------------
470 ------------------------------------------------------------------------------*/
473 RUN pclrep-line
( ?
, FILL("-",150) ).
475 /* PUT CONTROL logo-codes.
*/
476 RUN pcl-moveto
( 5, 0 ).
482 /* _UIB-CODE-BLOCK-END
*/
487 &IF DEFINED(EXCLUDE-print-remittance-header) = 0 &THEN
489 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-remittance-header Procedure
490 PROCEDURE print-remittance-header
:
491 /*------------------------------------------------------------------------------
493 ------------------------------------------------------------------------------*/
495 RUN pclrep-line
( lptr-font
+ ",Bold",
496 " Date Our Reference Your Invoice No. Invoiced Amount" ).
500 /* _UIB-CODE-BLOCK-END
*/
505 &IF DEFINED(EXCLUDE-print-summary-pages) = 0 &THEN
507 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-summary-pages Procedure
508 PROCEDURE print-summary-pages
:
509 /*------------------------------------------------------------------------------
511 ------------------------------------------------------------------------------*/
512 RUN process
/report
/cheque-whites.p
( "ChequeRange," + bank-account
+ "," + STRING(cheque-from
) + "," + STRING(cheque-to
)
516 /* _UIB-CODE-BLOCK-END
*/
521 &IF DEFINED(EXCLUDE-print-usage-summary) = 0 &THEN
523 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-usage-summary Procedure
524 PROCEDURE print-usage-summary
:
525 /*------------------------------------------------------------------------------
527 ------------------------------------------------------------------------------*/
528 DEF VAR s-ln
AS INT NO-UNDO.
529 DEF VAR s-pn
AS INT INIT 1 NO-UNDO.
530 DEF VAR summary-total
AS DEC NO-UNDO.
531 DEF VAR page-lines
AS INT NO-UNDO.
533 in-usage-summary
= Yes.
534 pclrep-page-number
= 0.
535 RUN pclrep-page-break.
537 FOR EACH Cheque
NO-LOCK WHERE
538 Cheque.BankAccountCode
= bank-account
AND
539 Cheque.ChequeNo
>= cheque-from
AND
540 Cheque.ChequeNo
<= cheque-to
,
541 FIRST Creditor
OF Cheque
NO-LOCK:
543 RUN pclrep-line
( lptr-font
, STRING( Cheque.ChequeNo
, "999999" ) + FILL(" ",5)
544 + STRING( Cheque.CreditorCode
, ">>>>>9" ) + FILL(" ",3)
545 + STRING( Creditor.Name
, "X(50)" ) + FILL(" ",9)
546 + STRING( Cheque.Amount
, ">,>>>,>>>,>>9.99" ) ).
548 summary-total
= summary-total
+ Cheque.Amount.
552 RUN pclrep-line
( lptr-font
, FILL(" ",80) + FILL("-", 15) ).
553 RUN pclrep-line
( lptr-font
, FILL(" ",79) + STRING( summary-total
, ">,>>>,>>>,>>9.99" ) ).
554 RUN pclrep-line
( lptr-font
, FILL(" ",80) + FILL("=", 15) ).
558 /* _UIB-CODE-BLOCK-END
*/
563 &IF DEFINED(EXCLUDE-set-automatic-feed) = 0 &THEN
565 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-automatic-feed Procedure
566 PROCEDURE set-automatic-feed
:
567 /*------------------------------------------------------------------------------
569 ------------------------------------------------------------------------------*/
570 IF is-manual-feed
= No
THEN RETURN.
572 DEF VAR bin-ctrl
AS CHAR NO-UNDO.
573 DEF VAR rows
AS DEC NO-UNDO.
574 DEF VAR cols
AS DEC NO-UNDO.
576 RUN make-control-string
( "PCL", "bin,{&TRAY_2}", OUTPUT bin-ctrl
,
577 OUTPUT rows
, OUTPUT cols
).
578 PUT CONTROL bin-ctrl.
584 /* _UIB-CODE-BLOCK-END
*/
589 &IF DEFINED(EXCLUDE-set-manual-feed) = 0 &THEN
591 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-manual-feed Procedure
592 PROCEDURE set-manual-feed
:
593 /*------------------------------------------------------------------------------
595 ------------------------------------------------------------------------------*/
596 IF is-manual-feed
THEN RETURN.
598 DEF VAR bin-ctrl
AS CHAR NO-UNDO.
599 DEF VAR rows
AS DEC NO-UNDO.
600 DEF VAR cols
AS DEC NO-UNDO.
602 RUN make-control-string
( "PCL", "bin,{&MANUAL_FEED_A4}", OUTPUT bin-ctrl
,
603 OUTPUT rows
, OUTPUT cols
).
604 PUT CONTROL bin-ctrl.
606 is-manual-feed
= Yes.
610 /* _UIB-CODE-BLOCK-END
*/