1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Approved Vouchers Report
6 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
9 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
10 DEF VAR bank-account
AS CHAR NO-UNDO INIT "".
11 DEF VAR exporting
AS LOGI
NO-UNDO INIT No.
12 DEF VAR one-per-page
AS LOGI
NO-UNDO INIT No.
13 DEF VAR file-name
AS CHAR NO-UNDO INIT "".
14 DEF VAR first-cheque-no
AS INT NO-UNDO INIT ?.
15 DEF VAR last-cheque-no
AS INT NO-UNDO INIT ?.
16 DEF VAR pdf-support
AS LOGICAL INIT YES NO-UNDO.
17 DEF VAR output-to-pdf
AS LOGICAL INIT NO NO-UNDO.
18 DEF VAR rows
AS DEC NO-UNDO.
19 DEF VAR cols
AS DEC NO-UNDO.
20 DEF VAR reset-page
AS CHARACTER NO-UNDO.
24 DEF VAR user-name
AS CHAR NO-UNDO.
25 {inc
/username.i
"user-name"}
26 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
27 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
29 DEF VAR pr-line
AS CHAR INIT "" NO-UNDO.
/* used everywhere to hold print line
*/
31 DEF VAR title-font
AS CHAR NO-UNDO INITIAL "proportional,helvetica,point,12,bold".
32 DEF VAR time-font
AS CHAR NO-UNDO INITIAL "proportional,helvetica,point,6,normal".
33 DEF VAR break1-font
AS CHAR NO-UNDO INITIAL "proportional,helvetica,point,12,lpi,7,bold".
34 DEF VAR break2-font
AS CHAR NO-UNDO INITIAL "proportional,helvetica,point,8,bold".
35 DEF VAR line1-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,point,8,bold".
36 DEF VAR line2-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,9,point,8,normal".
37 DEF VAR amt-fmt
AS CHAR INIT "(>>,>>>,>>9.99)" NO-UNDO.
38 DEF VAR i
AS INT NO-UNDO.
40 /* ensure bank account is scoped to entire program
*/
41 FIND FIRST BankAccount
WHERE BankAccount.BankAccountCode
= bank-account
NO-LOCK NO-ERROR.
43 /* _UIB-CODE-BLOCK-END
*/
47 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
49 /* ******************** Preprocessor Definitions
******************** */
51 &Scoped-define PROCEDURE-TYPE Procedure
55 /* _UIB-PREPROCESSOR-BLOCK-END
*/
59 /* ************************ Function Prototypes
********************** */
61 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD print-cheque Procedure
62 FUNCTION print-cheque
RETURNS DECIMAL
63 ( /* parameter-definitions
*/ ) FORWARD.
65 /* _UIB-CODE-BLOCK-END
*/
69 /* *********************** Procedure Settings
************************ */
71 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
72 /* Settings for
THIS-PROCEDURE
76 Add Fields to
: Neither
77 Other Settings
: CODE-ONLY
COMPILE
79 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
81 /* ************************* Create Window
************************** */
83 &ANALYZE-SUSPEND _CREATE-WINDOW
84 /* DESIGN Window definition
(used by the UIB
)
85 CREATE WINDOW Procedure
ASSIGN
88 /* END WINDOW DEFINITION
*/
94 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
95 /* ************************* Included-Libraries
*********************** */
97 {inc
/method
/m-txtrep.i
}
100 /* _UIB-CODE-BLOCK-END
*/
105 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
108 /* *************************** Main Block
*************************** */
113 IF output-to-pdf
THEN DO:
114 RUN txtrep-output-mode
( "pdf" ).
115 RUN hpgl-output-mode
( "pdf" ).
117 RUN make-control-string
( "PCL", "reset,simplex,portrait,a4,tm,0,lm,4", OUTPUT reset-page
, OUTPUT rows
, OUTPUT cols
).
118 RUN pclrep-start
( preview
OR exporting
, "reset,portrait,tm,2,a4,lm,4," + line1-font
).
120 IF NOT one-per-page
THEN DO:
121 RUN txtrep-pdf-filename
( 'PaymentDetails-'
+ STRING(first-cheque-no
) + '
-'
+ STRING(last-cheque-no
) ).
122 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
123 PUT CONTROL reset-page.
126 FOR EACH Cheque
WHERE Cheque.BankAccountCode
= bank-account
127 AND Cheque.ChequeNo
>= first-cheque-no
128 AND Cheque.ChequeNo
<= last-cheque-no
NO-LOCK:
130 IF one-per-page
THEN DO:
131 RUN txtrep-pdf-filename
( 'PaymentDetails-'
+ STRING(Cheque.ChequeNo
) ).
132 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
133 PUT CONTROL reset-page.
134 RUN inst-page-header.
143 IF NOT one-per-page
THEN
147 OUTPUT TO VALUE( IF exporting
THEN file-name
ELSE txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
148 RUN pclrep-start
( preview
OR exporting
, "reset,portrait,tm,2,a4,lm,4," + line1-font
).
150 FOR EACH Cheque
WHERE Cheque.BankAccountCode
= bank-account
151 AND Cheque.ChequeNo
>= first-cheque-no
152 AND Cheque.ChequeNo
<= last-cheque-no
NO-LOCK:
154 IF one-per-page
OR pclrep-test-bottom
(8.5) THEN RUN pclrep-page-break.
160 MESSAGE "Export Complete" VIEW-AS ALERT-BOX INFORMATION TITLE "Finished".
165 /* _UIB-CODE-BLOCK-END
*/
169 /* ********************** Internal Procedures
*********************** */
171 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
172 PROCEDURE inst-page-footer
:
173 /*------------------------------------------------------------------------------
175 ------------------------------------------------------------------------------*/
179 /* _UIB-CODE-BLOCK-END
*/
183 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
184 PROCEDURE inst-page-header
:
185 /*------------------------------------------------------------------------------
187 ------------------------------------------------------------------------------*/
190 RUN pclrep-line
( time-font
, pr-line
).
192 IF AVAILABLE(Cheque
) THEN DO:
193 pr-line
= FILL(' '
,110) + Cheque.BankAccountCode
+ STRING(Cheque.ChequeNo
, ">>999999").
194 RUN pclrep-line
( title-font
, pr-line
).
197 RUN pclrep-line
( ?
, "").
199 RUN pclrep-line
( ?
, "").
200 RUN pclrep-line
( title-font
, SPC
(45) + "Payment Details" ).
201 RUN pclrep-line
( time-font
, "").
202 RUN pclrep-line
( time-font
, "").
207 /* _UIB-CODE-BLOCK-END
*/
211 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
212 PROCEDURE parse-parameters
:
213 /*------------------------------------------------------------------------------
215 ------------------------------------------------------------------------------*/
216 DEF VAR token
AS CHAR NO-UNDO.
217 DEF VAR i
AS INT NO-UNDO.
219 {inc
/showopts.i
"report-options"}
221 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
222 token
= ENTRY( i
, report-options
, "~n" ).
224 CASE ENTRY( 1, token
):
225 WHEN "Preview" THEN preview
= Yes.
227 WHEN "OnePerPage" THEN one-per-page
= Yes.
229 WHEN "ChequeRange" THEN ASSIGN
230 bank-account
= ENTRY(2,token
)
231 first-cheque-no
= INT(ENTRY(3,token
))
232 last-cheque-no
= INT(ENTRY(4,token
)).
234 WHEN "OutputPDF" THEN output-to-pdf
= Yes.
242 /* _UIB-CODE-BLOCK-END
*/
246 /* ************************ Function Implementations
***************** */
248 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION print-cheque Procedure
249 FUNCTION print-cheque
RETURNS DECIMAL
250 ( /* parameter-definitions
*/ ) :
251 /*------------------------------------------------------------------------------
254 ------------------------------------------------------------------------------*/
255 DEF VAR line
AS CHAR NO-UNDO.
256 DEF VAR cheque-total
AS DEC NO-UNDO INITIAL 0.0 .
257 DEF VAR tax-total
AS DEC NO-UNDO INITIAL 0.0 .
259 line
= "Cheque " + STRING( Cheque.ChequeNo
, ">999999")
260 + " C" + STRING( Cheque.CreditorCode
, "99999") + " " + Cheque.Payee.
261 RUN pclrep-line
( break1-font
, line
).
263 FOR EACH Voucher
WHERE Voucher.BankAccountCode
= Cheque.BankAccountCode
264 AND Voucher.ChequeNo
= Cheque.ChequeNo
NO-LOCK
265 BY Voucher.BankAccountCode
BY Voucher.ChequeNo
BY Voucher.VoucherSeq
:
266 line
= STRING( "VCHR" + STRING( Voucher.VoucherSeq
), "X(11)")
267 + (IF Voucher.Date
= ?
THEN FILL(" ",10) ELSE STRING( Voucher.Date
, "99/99/9999" )) + " "
268 + STRING( Voucher.Description
, "X(50)" ) + " "
269 + STRING( Voucher.InvoiceReference
, "X(25)") + " "
270 + STRING( Voucher.InvoicePeriod
, "X(25)") .
271 cheque-total
= cheque-total
+ Voucher.TaxValue
+ Voucher.GoodsValue .
272 tax-total
= tax-total
+ Voucher.TaxValue.
273 RUN pclrep-line
( line1-font
, line
).
275 IF CAN-FIND( FIRST VoucherLine
OF Voucher
) THEN DO:
276 FOR EACH VoucherLine
OF Voucher
NO-LOCK:
277 line
= SPC
(16) + VoucherLine.EntityType
+ " "
278 + STRING( VoucherLine.EntityCode
, "99999" ) + " "
279 + STRING( VoucherLine.AccountCode
, "9999.99" ) + " "
280 + STRING( VoucherLine.Amount
, ">>>,>>>,>>9.99CR") + " "
281 + STRING( VoucherLine.TaxAmount
, ">>>,>>>,>>9.99CR") + " "
282 + STRING( VoucherLine.Description
, "X(50)") .
283 RUN pclrep-line
( line2-font
, line
).
287 line
= SPC
(16) + Voucher.EntityType
+ " "
288 + STRING( Voucher.EntityCode
, "99999" ) + " "
289 + STRING( Voucher.AccountCode
, "9999.99" ) + " "
290 + STRING( Voucher.GoodsValue
+ Voucher.TaxValue
, ">>>,>>>,>>9.99CR") + " "
291 + STRING( Voucher.TaxValue
, ">>>,>>>,>>9.99CR") + " "
292 + STRING( Voucher.Description
, "X(50)") .
293 RUN pclrep-line
( line2-font
, line
).
295 RUN pclrep-line
( line2-font
, "" ).
298 line
= SPC
(32) + FILL( FILL("-", 14) + " ", 2).
299 RUN pclrep-line
( line2-font
, line
).
300 line
= SPC
(32) + STRING( cheque-total
, ">>>,>>>,>>9.99CR" ) + " "
301 + STRING( tax-total
, ">>>,>>>,>>9.99CR" ).
302 RUN pclrep-line
( line2-font
, line
).
303 RUN pclrep-line
( ?
, ?
).
307 /* _UIB-CODE-BLOCK-END
*/