Changes for Catalyst APMS. Added PDF checkboxes to screens the generate remittance...
[capital-apms-progress.git] / vwr / mnt / v-chqrun.w
blobc242f292a449e804ad5a81460148b1d7f047c5b1
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI ADM1
2 &ANALYZE-RESUME
3 /* Connected Databases
4 ttpl PROGRESS
5 */
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
8 /*------------------------------------------------------------------------
9 File: vwr\mnt\v-chqrun.w
10 ------------------------------------------------------------------------*/
11 CREATE WIDGET-POOL.
12 /* *************************** Definitions ************************** */
14 &SCOP REPORT-ID "Cheque Run"
16 {inc/ofc-this.i}
17 {inc/ofc-acct.i "CREDITORS" "sundry-creditors"}
19 DEF VAR creditor-list AS CHAR NO-UNDO.
20 DEF VAR pdf-support AS LOGICAL INIT YES NO-UNDO.
21 DEF VAR pdf-output AS LOGICAL INIT NO NO-UNDO.
23 /* ensure bank account is scoped to entire program */
24 FIND FIRST BankAccount NO-LOCK NO-ERROR.
26 {inc/method/m-bankimportfile-gen.i}
28 {inc/ofc-set.i "PDF-Output-Directory" "pdf-output-directory"}
29 IF NOT AVAILABLE(OfficeSetting) THEN
30 pdf-support = NO.
32 /* _UIB-CODE-BLOCK-END */
33 &ANALYZE-RESUME
36 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
38 /* ******************** Preprocessor Definitions ******************** */
40 &Scoped-define PROCEDURE-TYPE SmartViewer
41 &Scoped-define DB-AWARE no
43 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
45 /* Name of first Frame and/or Browse and/or first Query */
46 &Scoped-define FRAME-NAME F-Main
48 /* External Tables */
49 &Scoped-define EXTERNAL-TABLES RP
50 &Scoped-define FIRST-EXTERNAL-TABLE RP
53 /* Need to scope the external tables to this procedure */
54 DEFINE QUERY external_tables FOR RP.
55 /* Standard List Definitions */
56 &Scoped-Define ENABLED-FIELDS RP.Log5 RP.Int1 RP.Char4 RP.Log2 RP.Log6 ~
57 RP.Log4 RP.Char1
58 &Scoped-define ENABLED-TABLES RP
59 &Scoped-define FIRST-ENABLED-TABLE RP
60 &Scoped-Define ENABLED-OBJECTS cmb_Client cmb_bnkact fil_from fil_to ~
61 fil_acct-from fil_acct-to fil_due cmb_PaymentStyle fil_startchq fil_Date ~
62 btn_print cbx_pdfoutput RECT-22
63 &Scoped-Define DISPLAYED-FIELDS RP.Log5 RP.Int1 RP.Char4 RP.Log2 RP.Log6 ~
64 RP.Log4 RP.Char1
65 &Scoped-define DISPLAYED-TABLES RP
66 &Scoped-define FIRST-DISPLAYED-TABLE RP
67 &Scoped-Define DISPLAYED-OBJECTS cmb_Client cmb_bnkact fil_from fil_to ~
68 fil_acct-from fil_acct-to fil_due cmb_PaymentStyle fil_startchq ~
69 fil_LastCheque fil_Date cbx_pdfoutput
71 /* Custom List Definitions */
72 /* ADM-CREATE-FIELDS,ADM-ASSIGN-FIELDS,List-3,List-4,List-5,List-6 */
74 /* _UIB-PREPROCESSOR-BLOCK-END */
75 &ANALYZE-RESUME
79 /* *********************** Control Definitions ********************** */
82 /* Definitions of the field level widgets */
83 DEFINE BUTTON btn_print DEFAULT
84 LABEL "&OK"
85 SIZE 8.57 BY 1
86 FONT 9.
88 DEFINE VARIABLE cbx_pdfoutput AS LOGICAL INITIAL no
89 LABEL "PDF remittance"
90 VIEW-AS TOGGLE-BOX
91 SIZE 14 BY .8 TOOLTIP "Generate the remittance advice from this cheque run a batch of PDF files" NO-UNDO.
93 DEFINE VARIABLE cmb_bnkact AS CHARACTER FORMAT "X(256)":U
94 LABEL "Bank Account"
95 VIEW-AS COMBO-BOX INNER-LINES 15
96 DROP-DOWN-LIST
97 SIZE 52.57 BY 1 NO-UNDO.
99 DEFINE VARIABLE cmb_Client AS CHARACTER FORMAT "X(256)"
100 VIEW-AS COMBO-BOX INNER-LINES 15
101 LIST-ITEMS "Item 1"
102 DROP-DOWN-LIST
103 SIZE 45.14 BY 1 NO-UNDO.
105 DEFINE VARIABLE cmb_PaymentStyle AS CHARACTER FORMAT "X(256)":U
106 VIEW-AS COMBO-BOX INNER-LINES 15
107 DROP-DOWN-LIST
108 SIZE 44.57 BY 1 NO-UNDO.
110 DEFINE VARIABLE fil_acct-from AS DECIMAL FORMAT "9999.99":U INITIAL 0
111 LABEL "Account from"
112 VIEW-AS FILL-IN
113 SIZE 6.86 BY 1.05 NO-UNDO.
115 DEFINE VARIABLE fil_acct-to AS DECIMAL FORMAT "9999.99":U INITIAL 0
116 LABEL "to"
117 VIEW-AS FILL-IN
118 SIZE 6.86 BY 1.05 NO-UNDO.
120 DEFINE VARIABLE fil_Date AS DATE FORMAT "99/99/9999":U
121 LABEL "Cheque Date"
122 VIEW-AS FILL-IN
123 SIZE 11.29 BY 1 NO-UNDO.
125 DEFINE VARIABLE fil_due AS INTEGER FORMAT ">>9":U INITIAL 10
126 LABEL "Cheques due in"
127 VIEW-AS FILL-IN
128 SIZE 4 BY 1 NO-UNDO.
130 DEFINE VARIABLE fil_from AS INTEGER FORMAT "99999":U INITIAL 0
131 LABEL "Creditor from"
132 VIEW-AS FILL-IN
133 SIZE 5.72 BY 1 NO-UNDO.
135 DEFINE VARIABLE fil_LastCheque AS CHARACTER FORMAT "X(256)":U
136 VIEW-AS FILL-IN
137 SIZE 21.14 BY 1.05 NO-UNDO.
139 DEFINE VARIABLE fil_startchq AS INTEGER FORMAT "999999":U INITIAL 0
140 LABEL "Next Cheque No"
141 VIEW-AS FILL-IN
142 SIZE 7.57 BY 1 NO-UNDO.
144 DEFINE VARIABLE fil_to AS INTEGER FORMAT "99999":U INITIAL 0
145 LABEL "to"
146 VIEW-AS FILL-IN
147 SIZE 5.72 BY 1 NO-UNDO.
149 DEFINE RECTANGLE RECT-22
150 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
151 SIZE 65.72 BY 19.75.
154 /* ************************ Frame Definitions *********************** */
156 DEFINE FRAME F-Main
157 RP.Log5 AT ROW 1.4 COL 4.43 HELP
158 "" NO-LABEL
159 VIEW-AS RADIO-SET VERTICAL
160 RADIO-BUTTONS
161 "All Clients/Owners", no,
162 "One Client/Owner", yes
163 SIZE 16.57 BY 1.6
164 cmb_Client AT ROW 2 COL 19 COLON-ALIGNED NO-LABEL
165 cmb_bnkact AT ROW 3.4 COL 11.57 COLON-ALIGNED
166 RP.Int1 AT ROW 5.4 COL 4.43 HELP
167 "" NO-LABEL
168 VIEW-AS RADIO-SET VERTICAL
169 RADIO-BUTTONS
170 "A range of creditor codes", 1,
171 "Vouchers charged to a range of projects", 2,
172 "Vouchers charged to a range of accounts", 3,
173 "A list of creditor codes", 4
174 SIZE 33.14 BY 3.2
175 fil_from AT ROW 5.6 COL 49.86 COLON-ALIGNED
176 fil_to AT ROW 5.6 COL 58.43 COLON-ALIGNED
177 fil_acct-from AT ROW 6.8 COL 47.57 COLON-ALIGNED
178 fil_acct-to AT ROW 6.8 COL 57.29 COLON-ALIGNED
179 RP.Char4 AT ROW 7.8 COL 20.72 COLON-ALIGNED HELP
180 "" NO-LABEL FORMAT "X(256)"
181 VIEW-AS FILL-IN
182 SIZE 43.43 BY 1.05 TOOLTIP "Enter creditor codes separated by commas"
183 fil_due AT ROW 9.2 COL 11.57 COLON-ALIGNED
184 RP.Log2 AT ROW 9.25 COL 43
185 LABEL "Enforce creditor cheque limits"
186 VIEW-AS TOGGLE-BOX
187 SIZE 23.43 BY 1
188 RP.Log6 AT ROW 10.25 COL 43 HELP
190 LABEL "Select my vouchers only"
191 VIEW-AS TOGGLE-BOX
192 SIZE 21 BY .8 TOOLTIP "Only select Approved vouchers last modified by current user."
193 RP.Log4 AT ROW 11 COL 4.43 HELP
194 "" NO-LABEL
195 VIEW-AS RADIO-SET VERTICAL
196 RADIO-BUTTONS
197 "One Payment Style", no,
198 "Force Payment by", yes
199 SIZE 16.57 BY 1.6
200 cmb_PaymentStyle AT ROW 11.4 COL 19.57 COLON-ALIGNED NO-LABEL
201 fil_startchq AT ROW 13.05 COL 11.57 COLON-ALIGNED
202 fil_LastCheque AT ROW 13.05 COL 19 COLON-ALIGNED NO-LABEL
203 fil_Date AT ROW 13.05 COL 52.72 COLON-ALIGNED
204 RP.Char1 AT ROW 14.25 COL 13.57 NO-LABEL
205 VIEW-AS EDITOR NO-WORD-WRAP SCROLLBAR-VERTICAL
206 SIZE 52.57 BY 4.6
207 FONT 8
208 btn_print AT ROW 19.25 COL 57
209 cbx_pdfoutput AT ROW 19.45 COL 43
210 RECT-22 AT ROW 1 COL 1
211 "Select creditors by:" VIEW-AS TEXT
212 SIZE 13.14 BY .8 AT ROW 4.6 COL 2.72
213 "Message Text:" VIEW-AS TEXT
214 SIZE 10.29 BY 1 AT ROW 14.25 COL 3.29
215 FONT 10
216 "days or less" VIEW-AS TEXT
217 SIZE 8 BY 1 AT ROW 9.2 COL 18.14
218 FONT 10
219 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
220 SIDE-LABELS NO-UNDERLINE THREE-D
221 AT COL 1 ROW 1 SCROLLABLE
222 FONT 10
223 DEFAULT-BUTTON btn_print.
226 /* *********************** Procedure Settings ************************ */
228 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
229 /* Settings for THIS-PROCEDURE
230 Type: SmartViewer
231 External Tables: TTPL.RP
232 Allow: Basic,DB-Fields
233 Frames: 1
234 Add Fields to: EXTERNAL-TABLES
235 Other Settings: PERSISTENT-ONLY COMPILE
238 /* This procedure should always be RUN PERSISTENT. Report the error, */
239 /* then cleanup and return. */
240 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
241 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT.":U
242 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
243 RETURN.
244 END.
246 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
248 /* ************************* Create Window ************************** */
250 &ANALYZE-SUSPEND _CREATE-WINDOW
251 /* DESIGN Window definition (used by the UIB)
252 CREATE WINDOW V-table-Win ASSIGN
253 HEIGHT = 22.15
254 WIDTH = 72.72.
255 /* END WINDOW DEFINITION */
257 &ANALYZE-RESUME
259 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
260 /* ************************* Included-Libraries *********************** */
262 {src/adm/method/viewer.i}
263 {inc/method/m-mntvwr.i}
265 /* _UIB-CODE-BLOCK-END */
266 &ANALYZE-RESUME
271 /* *********** Runtime Attributes and AppBuilder Settings *********** */
273 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
274 /* SETTINGS FOR WINDOW V-table-Win
275 VISIBLE,,RUN-PERSISTENT */
276 /* SETTINGS FOR FRAME F-Main
277 NOT-VISIBLE Size-to-Fit */
278 ASSIGN
279 FRAME F-Main:SCROLLABLE = FALSE
280 FRAME F-Main:HIDDEN = TRUE.
282 /* SETTINGS FOR FILL-IN RP.Char4 IN FRAME F-Main
283 EXP-LABEL EXP-FORMAT EXP-HELP */
284 /* SETTINGS FOR FILL-IN fil_LastCheque IN FRAME F-Main
285 NO-ENABLE */
286 /* SETTINGS FOR RADIO-SET RP.Int1 IN FRAME F-Main
287 EXP-HELP */
288 /* SETTINGS FOR TOGGLE-BOX RP.Log2 IN FRAME F-Main
289 EXP-LABEL */
290 /* SETTINGS FOR RADIO-SET RP.Log4 IN FRAME F-Main
291 EXP-HELP */
292 /* SETTINGS FOR RADIO-SET RP.Log5 IN FRAME F-Main
293 EXP-HELP */
294 /* SETTINGS FOR TOGGLE-BOX RP.Log6 IN FRAME F-Main
295 EXP-LABEL EXP-HELP */
296 /* _RUN-TIME-ATTRIBUTES-END */
297 &ANALYZE-RESUME
300 /* Setting information for Queries and Browse Widgets fields */
302 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
303 /* Query rebuild information for FRAME F-Main
304 _Options = "NO-LOCK"
305 _Query is NOT OPENED
306 */ /* FRAME F-Main */
307 &ANALYZE-RESUME
313 /* ************************ Control Triggers ************************ */
315 &Scoped-define SELF-NAME btn_print
316 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_print V-table-Win
317 ON CHOOSE OF btn_print IN FRAME F-Main /* OK */
319 DO WITH FRAME {&FRAME-NAME}:
320 RUN notify( 'set-busy, CONTAINER-SOURCE':U ).
322 RUN cheque-run.
324 IF RETURN-VALUE = "FAIL" THEN
325 RUN notify( 'set-idle, CONTAINER-SOURCE':U ).
326 ELSE
327 RUN dispatch( 'exit':U ).
328 END.
329 END.
331 /* _UIB-CODE-BLOCK-END */
332 &ANALYZE-RESUME
335 &Scoped-define SELF-NAME cbx_pdfoutput
336 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cbx_pdfoutput V-table-Win
337 ON VALUE-CHANGED OF cbx_pdfoutput IN FRAME F-Main /* OK */
339 DO WITH FRAME {&FRAME-NAME}:
340 pdf-output = cbx_pdfoutput:CHECKED IN FRAME {&FRAME-NAME}.
341 END.
342 END.
344 /* _UIB-CODE-BLOCK-END */
345 &ANALYZE-RESUME
348 &Scoped-define SELF-NAME cmb_bnkact
349 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_bnkact V-table-Win
350 ON U1 OF cmb_bnkact IN FRAME F-Main /* Bank Account */
352 {inc/selcmb/scchq1.i "RP" "Char5"}
353 END.
355 /* _UIB-CODE-BLOCK-END */
356 &ANALYZE-RESUME
359 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_bnkact V-table-Win
360 ON U2 OF cmb_bnkact IN FRAME F-Main /* Bank Account */
362 {inc/selcmb/scchq2.i "RP" "Char5"}
363 END.
365 /* _UIB-CODE-BLOCK-END */
366 &ANALYZE-RESUME
369 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_bnkact V-table-Win
370 ON VALUE-CHANGED OF cmb_bnkact IN FRAME F-Main /* Bank Account */
372 RUN display-last-cheque-no.
374 /* Display Import File Generation option? */
375 RUN enable-import-file-gen.
376 END.
378 /* _UIB-CODE-BLOCK-END */
379 &ANALYZE-RESUME
382 &Scoped-define SELF-NAME cmb_Client
383 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_Client V-table-Win
384 ON U1 OF cmb_Client IN FRAME F-Main
386 {inc/selcmb/scclient1.i "RP" "Char2"}
387 RUN display-last-cheque-no.
388 END.
390 /* _UIB-CODE-BLOCK-END */
391 &ANALYZE-RESUME
394 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_Client V-table-Win
395 ON U2 OF cmb_Client IN FRAME F-Main
397 {inc/selcmb/scclient2.i "RP" "Char2"}
398 END.
400 /* _UIB-CODE-BLOCK-END */
401 &ANALYZE-RESUME
404 &Scoped-define SELF-NAME cmb_PaymentStyle
405 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PaymentStyle V-table-Win
406 ON U1 OF cmb_PaymentStyle IN FRAME F-Main
408 {inc/selcmb/scpsty1.i "RP" "Char6"}
410 /* Display Import File Generation option? */
411 RUN enable-import-file-gen.
412 END.
414 /* _UIB-CODE-BLOCK-END */
415 &ANALYZE-RESUME
418 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PaymentStyle V-table-Win
419 ON U2 OF cmb_PaymentStyle IN FRAME F-Main
421 {inc/selcmb/scpsty2.i "RP" "Char6"}
422 END.
424 /* _UIB-CODE-BLOCK-END */
425 &ANALYZE-RESUME
428 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_PaymentStyle V-table-Win
429 ON VALUE-CHANGED OF cmb_PaymentStyle IN FRAME F-Main
431 RUN enable-appropriate-fields.
433 /* Display Import File Generation option? */
434 RUN enable-import-file-gen.
435 END.
437 /* _UIB-CODE-BLOCK-END */
438 &ANALYZE-RESUME
441 &Scoped-define SELF-NAME fil_Date
442 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Date V-table-Win
443 ON LEAVE OF fil_Date IN FRAME F-Main /* Cheque Date */
445 IF INPUT {&SELF-NAME} < TODAY THEN
447 MESSAGE "The cheque should only be dated in the past" SKIP
448 "if you are creating a record of manually produced cheques."
449 VIEW-AS ALERT-BOX WARNING TITLE "Cheque date in the past".
450 /* DISPLAY {&SELF-NAME} WITH FRAME {&FRAME-NAME}. */
451 ASSIGN {&SELF-NAME}.
452 END.
453 ELSE
454 ASSIGN {&SELF-NAME}.
455 END.
457 /* _UIB-CODE-BLOCK-END */
458 &ANALYZE-RESUME
461 &Scoped-define SELF-NAME fil_from
462 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_from V-table-Win
463 ON LEAVE OF fil_from IN FRAME F-Main /* Creditor from */
465 IF SELF:MODIFIED THEN
468 ASSIGN
469 {&SELF-NAME}
470 fil_to = {&SELF-NAME}.
472 DISPLAY fil_to WITH FRAME {&FRAME-NAME}.
474 SELF:MODIFIED = No.
476 END.
478 END.
480 /* _UIB-CODE-BLOCK-END */
481 &ANALYZE-RESUME
484 &Scoped-define SELF-NAME RP.Int1
485 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL RP.Int1 V-table-Win
486 ON VALUE-CHANGED OF RP.Int1 IN FRAME F-Main /* Int1 */
488 RUN enable-appropriate-fields.
490 /* Display Import File Generation option? */
491 RUN enable-import-file-gen.
492 END.
494 /* _UIB-CODE-BLOCK-END */
495 &ANALYZE-RESUME
498 &Scoped-define SELF-NAME RP.Log4
499 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL RP.Log4 V-table-Win
500 ON VALUE-CHANGED OF RP.Log4 IN FRAME F-Main /* Log4 */
502 RUN enable-appropriate-fields.
503 END.
505 /* _UIB-CODE-BLOCK-END */
506 &ANALYZE-RESUME
509 &Scoped-define SELF-NAME RP.Log5
510 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL RP.Log5 V-table-Win
511 ON VALUE-CHANGED OF RP.Log5 IN FRAME F-Main /* Log5 */
513 RUN enable-appropriate-fields.
514 END.
516 /* _UIB-CODE-BLOCK-END */
517 &ANALYZE-RESUME
520 &UNDEFINE SELF-NAME
522 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
525 /* *************************** Main Block *************************** */
527 IF NOT pdf-support THEN DO:
528 cbx_pdfoutput:VISIBLE IN FRAME {&FRAME-NAME} = NO.
529 END.
531 /* _UIB-CODE-BLOCK-END */
532 &ANALYZE-RESUME
535 /* ********************** Internal Procedures *********************** */
537 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
538 PROCEDURE adm-row-available :
539 /*------------------------------------------------------------------------------
540 Purpose: Dispatched to this procedure when the Record-
541 Source has a new row available. This procedure
542 tries to get the new row (or foriegn keys) from
543 the Record-Source and process it.
544 Parameters: <none>
545 ------------------------------------------------------------------------------*/
547 /* Define variables needed by this internal procedure. */
548 {src/adm/template/row-head.i}
550 /* Create a list of all the tables that we need to get. */
551 {src/adm/template/row-list.i "RP"}
553 /* Get the record ROWID's from the RECORD-SOURCE. */
554 {src/adm/template/row-get.i}
556 /* FIND each record specified by the RECORD-SOURCE. */
557 {src/adm/template/row-find.i "RP"}
559 /* Process the newly available records (i.e. display fields,
560 open queries, and/or pass records on to any RECORD-TARGETS). */
561 {src/adm/template/row-end.i}
563 END PROCEDURE.
565 /* _UIB-CODE-BLOCK-END */
566 &ANALYZE-RESUME
568 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-account-range V-table-Win
569 PROCEDURE build-account-range :
570 /*------------------------------------------------------------------------------
571 Purpose: Build a list of creditors based on vouchers which have been updated
572 against a particular range of projects.
573 ------------------------------------------------------------------------------*/
574 DEF INPUT PARAMETER print-date AS DATE NO-UNDO.
575 DEF OUTPUT PARAMETER creditor-list AS CHAR NO-UNDO.
577 DEF VAR start-account AS DEC NO-UNDO.
578 DEF VAR end-account AS DEC NO-UNDO.
579 DEF VAR cheque-total AS DEC INIT 0.00 NO-UNDO.
580 DEF VAR c-creditor AS CHAR NO-UNDO.
581 DEF BUFFER CrdVoucher FOR Voucher.
583 DO WITH FRAME {&FRAME-NAME}:
584 start-account = INPUT fil_acct-from.
585 end-account = INPUT fil_acct-to.
586 END.
588 /* Search by voucher rather than creditor for efficiency */
589 creditor-list = "".
590 FOR EACH Voucher WHERE Voucher.VoucherStatus = "A"
591 AND (Voucher.DateDue <= print-date OR Voucher.DateDue = ?) NO-LOCK:
593 c-creditor = STRING( Voucher.CreditorCode ).
595 IF LOOKUP( c-creditor, creditor-list ) = 0 THEN DO:
597 cheque-total = 0.
598 FOR EACH CrdVoucher WHERE CrdVoucher.CreditorCode = Voucher.CreditorCode
599 AND CrdVoucher.VoucherStatus = "A"
600 AND CrdVoucher.AccountCode >= start-account
601 AND CrdVoucher.AccountCode <= end-account
602 AND (CrdVoucher.DateDue <= print-date
603 OR CrdVoucher.DateDue = ?) NO-LOCK:
605 cheque-total = cheque-total + CrdVoucher.GoodsValue + CrdVoucher.TaxValue.
606 END.
608 IF cheque-total > 0 THEN DO:
609 creditor-list = creditor-list + IF creditor-list = "" THEN "" ELSE ",".
610 creditor-list = creditor-list + c-creditor.
611 END.
612 END.
613 END.
615 END PROCEDURE.
617 /* _UIB-CODE-BLOCK-END */
618 &ANALYZE-RESUME
620 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-creditor-list V-table-Win
621 PROCEDURE build-creditor-list :
622 /*------------------------------------------------------------------------------
623 Purpose: Build a list of creditors based on an entered list.
624 ------------------------------------------------------------------------------*/
625 DEF INPUT PARAMETER print-date AS DATE NO-UNDO.
626 DEF OUTPUT PARAMETER creditor-list AS CHAR NO-UNDO.
628 DEF VAR in-creditor-list AS CHAR NO-UNDO.
629 DEF VAR cheque-total AS DEC INIT 0.00 NO-UNDO.
630 DEF VAR i AS INT NO-UNDO.
631 DEF VAR creditor-code AS INT NO-UNDO.
633 DO WITH FRAME {&FRAME-NAME}:
634 in-creditor-list = INPUT RP.Char4.
635 END.
637 creditor-list = "".
638 DO i = 1 TO NUM-ENTRIES(in-creditor-list):
639 creditor-code = INT( TRIM( ENTRY( i, in-creditor-list ) ) ).
640 cheque-total = 0.
641 FOR EACH Voucher WHERE Voucher.CreditorCode = creditor-code
642 AND Voucher.VoucherStatus = "A"
643 AND (Voucher.DateDue <= print-date
644 OR Voucher.DateDue = ?) NO-LOCK:
645 cheque-total = cheque-total + Voucher.GoodsValue + Voucher.TaxValue.
646 END.
647 IF cheque-total > 0 THEN DO:
648 creditor-list = creditor-list + IF creditor-list = "" THEN "" ELSE ",".
649 creditor-list = creditor-list + STRING(creditor-code).
650 END.
651 ELSE DO:
652 MESSAGE "Creditor " + STRING(creditor-code) ":" SKIP(1)
653 "No cheque will be produced as the total would be " + STRING(cheque-total)
654 VIEW-AS ALERT-BOX INFORMATION
655 TITLE "Cheque Not Required".
656 END.
657 END.
659 END PROCEDURE.
661 /* _UIB-CODE-BLOCK-END */
662 &ANALYZE-RESUME
664 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-creditor-range V-table-Win
665 PROCEDURE build-creditor-range :
666 /*------------------------------------------------------------------------------
667 Purpose: Find the creditors with cheques due in a simple range of creditors
668 ------------------------------------------------------------------------------*/
669 DEF INPUT PARAMETER print-date AS DATE NO-UNDO.
670 DEF OUTPUT PARAMETER creditor-list AS CHAR NO-UNDO.
672 DEF VAR start-crdtor AS INT NO-UNDO.
673 DEF VAR end-crdtor AS INT NO-UNDO.
674 DEF VAR c-creditor AS CHAR NO-UNDO.
675 DEF VAR cheque-total AS DEC INIT 0.00 NO-UNDO.
676 DEF BUFFER CrdVoucher FOR Voucher.
678 start-crdtor = INPUT FRAME {&FRAME-NAME} fil_from.
679 end-crdtor = INPUT FRAME {&FRAME-NAME} fil_to.
680 IF end-crdtor < start-crdtor THEN end-crdtor = start-crdtor.
682 /* Search by voucher rather than creditor for efficiency */
683 creditor-list = "".
684 FOR EACH Voucher WHERE
685 Voucher.VoucherStatus = "A" AND
686 ( Voucher.DateDue <= print-date OR Voucher.DateDue = ? ) NO-LOCK:
688 c-creditor = STRING( Voucher.CreditorCode ).
690 IF Voucher.CreditorCode >= start-crdtor AND
691 Voucher.CreditorCode <= end-crdtor AND
692 LOOKUP( c-creditor, creditor-list ) = 0 THEN
695 cheque-total = 0.
696 FOR EACH CrdVoucher WHERE
697 CrdVoucher.CreditorCode = Voucher.CreditorCode AND
698 CrdVoucher.VoucherStatus = "A" AND
699 ( CrdVoucher.DateDue <= print-date OR CrdVoucher.DateDue = ? ) NO-LOCK:
700 cheque-total = cheque-total + CrdVoucher.GoodsValue + CrdVoucher.TaxValue.
701 END.
703 IF cheque-total > 0 THEN
705 creditor-list = creditor-list + IF creditor-list = "" THEN "" ELSE ",".
706 creditor-list = creditor-list + c-creditor.
707 END.
708 END.
709 END.
711 END PROCEDURE.
713 /* _UIB-CODE-BLOCK-END */
714 &ANALYZE-RESUME
716 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-project-range V-table-Win
717 PROCEDURE build-project-range :
718 /*------------------------------------------------------------------------------
719 Purpose: Build a list of creditors based on vouchers which have been updated
720 against a particular range of projects.
721 ------------------------------------------------------------------------------*/
722 DEF INPUT PARAMETER print-date AS DATE NO-UNDO.
723 DEF OUTPUT PARAMETER creditor-list AS CHAR NO-UNDO.
725 DEF VAR start-project AS INT NO-UNDO.
726 DEF VAR end-project AS INT NO-UNDO.
727 DEF VAR cheque-total AS DEC INIT 0.00 NO-UNDO.
728 DEF VAR c-creditor AS CHAR NO-UNDO.
729 DEF BUFFER CrdVoucher FOR Voucher.
731 DO WITH FRAME {&FRAME-NAME}:
732 start-project = INPUT fil_from.
733 end-project = INPUT fil_to.
734 END.
736 /* Search by voucher rather than creditor for efficiency */
737 creditor-list = "".
738 FOR EACH Voucher WHERE Voucher.VoucherStatus = "A"
739 AND (Voucher.DateDue <= print-date OR Voucher.DateDue = ?) NO-LOCK:
741 c-creditor = STRING( Voucher.CreditorCode ).
743 IF LOOKUP( c-creditor, creditor-list ) = 0 THEN DO:
745 cheque-total = 0.
746 FOR EACH CrdVoucher WHERE CrdVoucher.CreditorCode = Voucher.CreditorCode
747 AND CrdVoucher.VoucherStatus = "A"
748 AND CrdVoucher.EntityType = "J"
749 AND CrdVoucher.EntityCode >= start-project
750 AND CrdVoucher.EntityCode <= end-project
751 AND (CrdVoucher.DateDue <= print-date
752 OR CrdVoucher.DateDue = ?) NO-LOCK:
754 cheque-total = cheque-total + CrdVoucher.GoodsValue + CrdVoucher.TaxValue.
755 END.
757 IF cheque-total > 0 THEN DO:
758 creditor-list = creditor-list + IF creditor-list = "" THEN "" ELSE ",".
759 creditor-list = creditor-list + c-creditor.
760 END.
761 END.
762 END.
764 END PROCEDURE.
766 /* _UIB-CODE-BLOCK-END */
767 &ANALYZE-RESUME
769 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cheque-run V-table-Win
770 PROCEDURE cheque-run :
771 /*------------------------------------------------------------------------------
772 Purpose:
773 ------------------------------------------------------------------------------*/
774 DEF VAR report-options AS CHAR NO-UNDO.
775 DEFINE VARIABLE item-idx AS INTEGER INITIAL 0 NO-UNDO.
777 DO WITH FRAME {&FRAME-NAME}:
778 item-idx = cmb_PaymentStyle:LOOKUP( INPUT cmb_PaymentStyle ).
779 IF item-idx > 0 THEN
780 FIND PaymentStyle WHERE ROWID( PaymentStyle ) =
781 TO-ROWID( ENTRY( item-idx, cmb_PaymentStyle:PRIVATE-DATA ) ) NO-LOCK NO-ERROR.
783 IF AVAILABLE PaymentStyle THEN DO:
784 FIND CURRENT RP SHARE-LOCK.
785 RP.Char6 = PaymentStyle.PaymentStyle.
786 END.
787 END.
789 RUN verify-run.
790 IF RETURN-VALUE = "FAIL" THEN RETURN "FAIL".
792 RUN dispatch( 'update-record':U ).
794 DO WITH FRAME {&FRAME-NAME}:
795 report-options = "ChequeDate," + STRING( INPUT fil_Date, "99/99/9999" )
796 + "~nFirstCheque," + STRING( INPUT fil_StartChq )
797 + "~nDueBefore," + STRING( TODAY + INPUT fil_due, "99/99/9999" )
798 + (IF RP.Log2 THEN "~nEnforceLimit" ELSE "")
799 + (IF RP.Log5 THEN "~nOneClient," + RP.Char2 ELSE "")
800 + (IF RP.Log6 THEN "~nMyVouchers," ELSE "")
801 + "~nBankAccount," + RP.Char5
802 + "~nMessage," + REPLACE( RP.Char1, "~n", CHR(7) ) .
804 report-options = report-options
805 + (IF RP.Log4 = No THEN "~nPaymentStyle," ELSE "~nForcePaymentBy,")
806 + RP.Char6 .
808 CASE RP.Int1:
809 WHEN 1 THEN /* "CreditorRange":U */
810 report-options = report-options + "~nCreditorRange," + STRING( INPUT fil_from ) + "," + STRING( INPUT fil_to ).
811 WHEN 2 THEN /* "ProjectRange":U */
812 report-options = report-options + "~nProjectRange," + STRING( INPUT fil_from ) + "," + STRING( INPUT fil_to ).
813 WHEN 3 THEN /* "AccountRange":U */
814 report-options = report-options + "~nAccountRange," + STRING( INPUT fil_acct-from ) + "," + STRING( INPUT fil_acct-to ).
815 WHEN 4 THEN /* "CreditorList":U */
816 report-options = report-options + "~nCreditorList," + INPUT RP.Char4 .
817 END CASE.
819 END.
821 IF pdf-output THEN
822 report-options = report-options + "~nOutputPDF".
824 RUN process/cheq-run.p ( report-options ).
826 END PROCEDURE.
828 /* _UIB-CODE-BLOCK-END */
829 &ANALYZE-RESUME
831 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
832 PROCEDURE disable_UI :
833 /*------------------------------------------------------------------------------
834 Purpose: DISABLE the User Interface
835 Parameters: <none>
836 Notes: Here we clean-up the user-interface by deleting
837 dynamic widgets we have created and/or hide
838 frames. This procedure is usually called when
839 we are ready to "clean-up" after running.
840 ------------------------------------------------------------------------------*/
841 /* Hide all frames. */
842 HIDE FRAME F-Main.
843 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
844 END PROCEDURE.
846 /* _UIB-CODE-BLOCK-END */
847 &ANALYZE-RESUME
849 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE display-last-cheque-no V-table-Win
850 PROCEDURE display-last-cheque-no :
851 /*------------------------------------------------------------------------------
852 Purpose:
853 ------------------------------------------------------------------------------*/
854 DEF VAR i AS INT NO-UNDO.
855 DEF VAR bank-id AS CHAR NO-UNDO.
857 DO WITH FRAME {&FRAME-NAME}:
858 fil_LastCheque = "".
860 i = cmb_bnkact:LOOKUP( cmb_bnkact:SCREEN-VALUE ).
861 bank-id = ENTRY( i, cmb_bnkact:PRIVATE-DATA ).
862 FIND BankAccount WHERE ROWID(BankAccount) = TO-ROWID(bank-id) NO-LOCK NO-ERROR.
864 IF AVAILABLE(BankAccount) THEN DO:
865 /* the Cheque.Date clause encourages Progress to choose a good index */
866 FIND FIRST Cheque WHERE Cheque.BankAccountCode = BankAccount.BankAccountCode
867 AND Cheque.Date <= TODAY + 999 NO-LOCK NO-ERROR.
868 IF AVAILABLE(Cheque) THEN
869 fil_LastCheque = "(last: " + STRING(Cheque.ChequeNo) + " " + STRING(Cheque.Date, "99/99/9999") + ")".
870 END.
872 DISPLAY fil_LastCheque.
873 END.
874 END PROCEDURE.
876 /* _UIB-CODE-BLOCK-END */
877 &ANALYZE-RESUME
879 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable-appropriate-fields V-table-Win
880 PROCEDURE enable-appropriate-fields :
881 /*------------------------------------------------------------------------------
882 Purpose: Enable the apprpriate fields based on the chosen SelectionType
883 ------------------------------------------------------------------------------*/
884 DEFINE VARIABLE payment-styles AS LOGICAL NO-UNDO INITIAL No.
886 FIND FIRST PaymentStyle NO-LOCK NO-ERROR.
887 IF AVAILABLE(PaymentStyle) THEN DO:
888 FIND NEXT PaymentStyle NO-LOCK NO-ERROR.
889 payment-styles = AVAILABLE(PaymentStyle).
890 END.
892 DO WITH FRAME {&FRAME-NAME}:
893 CASE INPUT RP.Int1:
894 WHEN 1 THEN DO: /* "CreditorRange" */
895 HIDE RP.Char4 fil_acct-from fil_acct-to.
896 fil_from:LABEL = "Creditor from".
897 VIEW fil_from fil_to.
898 END.
899 WHEN 2 THEN DO: /* "ProjectRange" */
900 HIDE RP.Char4 fil_acct-from fil_acct-to.
901 fil_from:LABEL = "Project from".
902 VIEW fil_from fil_to.
903 END.
904 WHEN 3 THEN DO: /* "AccountRange" */
905 HIDE RP.Char4 fil_from fil_to.
906 VIEW fil_acct-from fil_acct-to.
907 END.
908 WHEN 4 THEN DO: /* "CreditorList" */
909 HIDE fil_from fil_to fil_acct-from fil_acct-to.
910 VIEW RP.Char4.
911 END.
912 END.
914 VIEW RP.Log5 RP.Log2.
916 IF payment-styles THEN
917 VIEW RP.Log4 cmb_PaymentStyle.
918 ELSE
919 HIDE RP.Log4 cmb_PaymentStyle .
921 IF INPUT RP.Log5 THEN
922 VIEW cmb_Client.
923 ELSE
924 HIDE cmb_Client.
926 END.
927 END PROCEDURE.
929 /* _UIB-CODE-BLOCK-END */
930 &ANALYZE-RESUME
932 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable-import-file-gen V-table-Win
933 PROCEDURE enable-import-file-gen :
934 /*------------------------------------------------------------------------------
935 Purpose:
936 Parameters: <none>
937 Notes:
938 ------------------------------------------------------------------------------*/
939 /* Display Import File Generation option? */
940 /* Payer Bank Account */
941 DEFINE VARIABLE item-idx AS INTEGER NO-UNDO.
942 DEFINE VARIABLE v-bankaccount LIKE BankAccount.BankAccount INITIAL 0 NO-UNDO.
943 DEFINE VARIABLE v-bank AS INTEGER INITIAL 0 NO-UNDO.
944 DEFINE VARIABLE v-branch AS INTEGER INITIAL 0 NO-UNDO.
945 DEFINE VARIABLE v-account AS INTEGER INITIAL 0 NO-UNDO.
946 DEFINE VARIABLE v-suffix AS INTEGER INITIAL 0 NO-UNDO.
947 /* Payment Style */
948 DEFINE VARIABLE v-allorone-payment-style AS CHARACTER INITIAL '' NO-UNDO.
949 DEFINE VARIABLE v-payment-style AS CHARACTER INITIAL '' NO-UNDO.
951 DO WITH FRAME {&FRAME-NAME}:
952 FIND CURRENT RP SHARE-LOCK NO-ERROR.
954 /* Check Payer Bank Account */
955 item-idx = cmb_bnkact:LOOKUP( INPUT cmb_bnkact ).
956 IF item-idx > 0 THEN DO:
957 FIND BankAccount WHERE ROWID( BankAccount ) =
958 TO-ROWID( ENTRY( item-idx, cmb_bnkact:PRIVATE-DATA ) ) NO-LOCK NO-ERROR.
960 IF AVAILABLE BankAccount THEN DO:
961 RUN get-bankbranchaccountsuffix (
962 BankAccount.BankAccount,
963 OUTPUT v-bank,
964 OUTPUT v-branch,
965 OUTPUT v-account,
966 OUTPUT v-suffix
968 /* IF RETURN-VALUE = "FAIL" THEN RETURN "FAIL". */
969 END.
971 END.
973 END.
975 END PROCEDURE.
977 /* _UIB-CODE-BLOCK-END */
978 &ANALYZE-RESUME
980 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-bank-account V-table-Win
981 PROCEDURE get-bank-account :
982 /*------------------------------------------------------------------------------
983 Purpose:
984 Parameters: <none>
985 Notes:
986 ------------------------------------------------------------------------------*/
988 DO WITH FRAME {&FRAME-NAME}:
990 DEF VAR item-idx AS INT NO-UNDO.
992 item-idx = cmb_bnkact:LOOKUP( INPUT cmb_bnkact ).
993 IF item-idx = 0 THEN RETURN.
995 FIND BankAccount WHERE ROWID( BankAccount ) =
996 TO-ROWID( ENTRY( item-idx, cmb_bnkact:PRIVATE-DATA ) ) NO-LOCK.
998 END.
1000 END PROCEDURE.
1002 /* _UIB-CODE-BLOCK-END */
1003 &ANALYZE-RESUME
1005 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
1006 PROCEDURE inst-initialize :
1007 /*------------------------------------------------------------------------------
1008 Purpose:
1009 ------------------------------------------------------------------------------*/
1011 DEF VAR user-name AS CHAR NO-UNDO.
1012 RUN get-username IN sys-mgr( OUTPUT user-name ).
1014 FIND RP WHERE
1015 RP.ReportID = {&REPORT-ID} AND
1016 RP.UserName = user-name
1017 NO-ERROR.
1019 {inc/ofc-this.i}
1020 IF NOT AVAILABLE RP THEN DO:
1021 CREATE RP.
1022 ASSIGN RP.ReportID = {&REPORT-ID}
1023 RP.UserName = user-name .
1025 RP.Char1 = "Please forward all invoices to:~n" + Office.StreetAddress .
1027 END.
1029 fil_from = 0.
1030 fil_to = 99999.
1032 fil_due = 10.
1033 fil_date = TODAY.
1035 DISPLAY
1036 fil_from
1037 fil_to
1038 fil_due
1039 fil_date
1040 WITH FRAME {&FRAME-NAME}.
1042 fil_from:MODIFIED IN FRAME {&FRAME-NAME} = No.
1043 RUN dispatch( 'display-fields':U ).
1044 RUN dispatch( 'enable-fields':U ).
1045 RUN enable-appropriate-fields.
1046 RUN enable-import-file-gen.
1047 RUN display-last-cheque-no.
1049 END PROCEDURE.
1051 /* _UIB-CODE-BLOCK-END */
1052 &ANALYZE-RESUME
1054 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE old-cheque-run V-table-Win
1055 PROCEDURE old-cheque-run :
1056 /*------------------------------------------------------------------------------
1057 Purpose:
1058 Parameters: <none>
1059 Notes:
1060 ------------------------------------------------------------------------------*/
1061 DEF VAR report-options AS CHAR NO-UNDO.
1062 DEF VAR batch-no AS INT NO-UNDO.
1063 DEF VAR start-printing AS LOGICAL NO-UNDO INITIAL Yes.
1065 RUN get-bank-account.
1066 RUN verify-run.
1067 IF RETURN-VALUE = "FAIL" THEN RETURN RETURN-VALUE.
1069 RUN dispatch( 'update-record':U ).
1071 DEF VAR print-date AS DATE NO-UNDO.
1072 DEF VAR tran-date AS DATE NO-UNDO.
1073 DEF VAR cheque-no AS INT NO-UNDO.
1074 DEF VAR start-no AS INT NO-UNDO.
1075 DEF VAR end-no AS INT NO-UNDO.
1076 DEF VAR n-days AS INT NO-UNDO.
1077 DEF VAR n-cheques AS INT INIT 0 NO-UNDO.
1078 DEF VAR printed-ok AS LOGI NO-UNDO.
1079 DEF VAR cheque-total AS DEC NO-UNDO.
1080 DEF VAR i AS INT NO-UNDO.
1082 n-days = INPUT FRAME {&FRAME-NAME} fil_due.
1083 start-no = INPUT FRAME {&FRAME-NAME} fil_startchq.
1084 print-date = TODAY + n-days.
1085 tran-date = INPUT FRAME {&FRAME-NAME} fil_Date .
1087 cheque-no = start-no.
1089 cheque-run:
1090 DO TRANSACTION ON ERROR UNDO cheque-run, RETURN:
1092 /* Create the batch */
1093 CREATE NewBatch.
1094 ASSIGN
1095 NewBatch.BatchType = 'NORM'
1096 NewBatch.Description = "Cheque Batch - " + STRING( TODAY, "99/99/9999" ).
1098 batch-no = NewBatch.BatchCode .
1099 n-cheques = NUM-ENTRIES( creditor-list ).
1101 DO i = 1 TO n-cheques:
1103 FIND FIRST Creditor WHERE Creditor.CreditorCode = INT( ENTRY( i, creditor-list ) )
1104 NO-LOCK.
1106 CREATE NewDocument.
1107 ASSIGN
1108 NewDocument.BatchCode = batch-no
1109 NewDocument.DocumentType = "CHEQ"
1110 NewDocument.Description = Creditor.PayeeName
1111 NewDocument.Reference = STRING( cheque-no ).
1113 CREATE Cheque.
1114 ASSIGN
1115 Cheque.BatchCode = batch-no
1116 Cheque.DocumentCode = NewDocument.DocumentCode
1117 Cheque.BankAccountCode = BankAccount.BankAccountCode
1118 Cheque.ChequeNo = cheque-no
1119 Cheque.CreditorCode = Creditor.CreditorCode
1120 Cheque.Date = INPUT FRAME {&FRAME-NAME} fil_Date
1121 Cheque.PayeeName = Creditor.PayeeName.
1123 cheque-total = 0.
1124 FOR EACH Voucher OF Creditor WHERE
1125 Voucher.VoucherStatus = "A" AND
1126 ( Voucher.DateDue <= print-date OR Voucher.DateDue = ? ) EXCLUSIVE-LOCK:
1128 ASSIGN
1129 Voucher.VoucherStatus = "P"
1130 Voucher.BankAccountCode = Cheque.BankAccountCode
1131 Voucher.ChequeNo = Cheque.ChequeNo
1133 cheque-total = cheque-total + Voucher.GoodsValue + Voucher.TaxValue.
1134 END.
1136 /* Debit the creditor */
1137 CREATE NewAcctTrans.
1138 ASSIGN
1139 NewAcctTrans.BatchCode = batch-no
1140 NewAcctTrans.DocumentCode = NewDocument.DocumentCode
1141 NewAcctTrans.EntityType = "C"
1142 NewAcctTrans.EntityCode = Creditor.CreditorCode
1143 NewAcctTrans.AccountCode = sundry-creditors
1144 NewAcctTrans.Amount = cheque-total
1145 NewAcctTrans.Date = tran-date
1146 NewAcctTrans.Description = ""
1147 NewAcctTrans.Reference = "".
1149 ASSIGN
1150 Cheque.Amount = cheque-total.
1152 end-no = cheque-no.
1153 cheque-no = cheque-no + 1.
1155 /* Credit the bank account */
1156 CREATE NewAcctTrans.
1157 ASSIGN
1158 NewAcctTrans.BatchCode = batch-no
1159 NewAcctTrans.DocumentCode = NewDocument.DocumentCode
1160 NewAcctTrans.EntityType = "L"
1161 NewAcctTrans.EntityCode = BankAccount.CompanyCode
1162 NewAcctTrans.AccountCode = BankAccount.AccountCode
1163 NewAcctTrans.Amount = cheque-total * -1
1164 NewAcctTrans.Date = tran-date
1165 NewAcctTrans.Description = ""
1166 NewAcctTrans.Reference = "".
1168 END.
1170 MESSAGE "There are" n-cheques "cheques to printed." SKIP
1171 "Start printing Now ?" SKIP(2)
1172 "The printer will wait for you to insert cheque paper."
1173 VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO
1174 TITLE "Start Printing ?" UPDATE start-printing.
1176 IF NOT start-printing THEN UNDO cheque-run, RETURN.
1177 END.
1179 report-options = "BankAccount," + BankAccount.BankAccountCode
1180 + "~nChequeRange," + STRING(start-no) + "," + STRING(end-no)
1181 + "~nMessage," + REPLACE( RP.Char1, "~n", CHR(7)).
1182 IF pdf-output THEN
1183 report-options = report-options + "~nOutputPDF".
1185 RUN process/report/chqprt.p( report-options ).
1187 END PROCEDURE.
1189 /* _UIB-CODE-BLOCK-END */
1190 &ANALYZE-RESUME
1192 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
1193 PROCEDURE pre-destroy :
1194 /*------------------------------------------------------------------------------
1195 Purpose:
1196 Parameters: <none>
1197 Notes:
1198 ------------------------------------------------------------------------------*/
1200 RUN check-modified( "CLEAR" ).
1202 END PROCEDURE.
1204 /* _UIB-CODE-BLOCK-END */
1205 &ANALYZE-RESUME
1207 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
1208 PROCEDURE send-records :
1209 /*------------------------------------------------------------------------------
1210 Purpose: Send record ROWID's for all tables used by
1211 this file.
1212 Parameters: see template/snd-head.i
1213 ------------------------------------------------------------------------------*/
1215 /* Define variables needed by this internal procedure. */
1216 {src/adm/template/snd-head.i}
1218 /* For each requested table, put it's ROWID in the output list. */
1219 {src/adm/template/snd-list.i "RP"}
1221 /* Deal with any unexpected table requests before closing. */
1222 {src/adm/template/snd-end.i}
1224 END PROCEDURE.
1226 /* _UIB-CODE-BLOCK-END */
1227 &ANALYZE-RESUME
1229 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE sort-by-creditor-name V-table-Win
1230 PROCEDURE sort-by-creditor-name :
1231 /*------------------------------------------------------------------------------
1232 Purpose:
1233 Parameters: <none>
1234 Notes:
1235 ------------------------------------------------------------------------------*/
1237 DEF INPUT PARAMETER in-list AS CHAR NO-UNDO.
1238 DEF OUTPUT PARAMETER out-list AS CHAR NO-UNDO.
1240 DEF VAR sel_sort AS HANDLE NO-UNDO.
1241 DEF VAR i AS INT NO-UNDO.
1242 DEF VAR delim AS CHAR NO-UNDO INIT "~~".
1243 /* HACK - Create a selection list to do the sorting */
1245 CREATE SELECTION-LIST sel_sort
1246 ASSIGN
1247 FRAME = FRAME {&FRAME-NAME}:HANDLE
1248 HIDDEN = Yes
1249 DELIMITER = delim
1250 SORT = Yes.
1252 sel_sort:LIST-ITEMS = "".
1254 DO i = 1 TO NUM-ENTRIES( in-list ):
1255 FIND Creditor WHERE Creditor.CreditorCode = INT( ENTRY( i, in-list ) )
1256 NO-LOCK NO-ERROR.
1257 IF AVAILABLE Creditor THEN
1258 IF sel_sort:ADD-LAST( Creditor.Name + "|" + ENTRY( i, in-list ) ) THEN.
1259 END.
1261 DO i = 1 TO NUM-ENTRIES( sel_sort:LIST-ITEMS, delim ):
1262 out-list = TRIM( out-list + "," + ENTRY( 2, sel_sort:ENTRY( i ), "|" ), "," ).
1263 END.
1265 END PROCEDURE.
1267 /* _UIB-CODE-BLOCK-END */
1268 &ANALYZE-RESUME
1270 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
1271 PROCEDURE state-changed :
1272 /* -----------------------------------------------------------
1273 Purpose:
1274 Parameters: <none>
1275 Notes:
1276 -------------------------------------------------------------*/
1277 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
1278 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
1280 CASE p-state:
1281 /* Object instance CASEs can go here to replace standard behavior
1282 or add new cases. */
1283 {src/adm/template/vstates.i}
1284 END CASE.
1285 END PROCEDURE.
1287 /* _UIB-CODE-BLOCK-END */
1288 &ANALYZE-RESUME
1290 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-bank-accounts V-table-Win
1291 PROCEDURE update-bank-accounts :
1292 /*------------------------------------------------------------------------------
1293 Purpose:
1294 Parameters: <none>
1295 Notes:
1296 ------------------------------------------------------------------------------*/
1298 DEF VAR item AS CHAR NO-UNDO.
1299 DEF VAR id-list AS CHAR NO-UNDO.
1300 DEF VAR default-account AS CHAR NO-UNDO.
1301 cmb_bnkact:LIST-ITEMS IN FRAME {&FRAME-NAME} = "".
1303 FIND Office WHERE Office.ThisOffice NO-LOCK.
1304 FIND OfficeControlAccount OF Office WHERE OfficeControlAccount.Name = "PYMTBANK" NO-LOCK NO-ERROR.
1306 FOR EACH BankAccount NO-LOCK:
1307 item = STRING( BankAccount.CompanyCode, ">>>>9" ) + ' ' +
1308 STRING( BankAccount.AccountCode, "9999.99" ) + ' ' +
1309 BankAccount.AccountName.
1310 IF cmb_bnkact:ADD-LAST( item ) THEN.
1311 id-list = id-list + IF id-list = "" THEN "" ELSE ",".
1312 id-list = id-list + STRING( ROWID( BankAccount ) ).
1313 IF AVAILABLE(OfficeControlAccount) AND BankAccount.BankAccountCode = OfficeControlAccount.Description THEN default-account = item.
1314 END.
1316 cmb_bnkact:PRIVATE-DATA = id-list.
1317 cmb_bnkact:SCREEN-VALUE = IF default-account <> "" THEN default-account ELSE
1318 ENTRY( 1, cmb_bnkact:LIST-ITEMS ).
1319 RUN get-bank-account.
1321 END PROCEDURE.
1323 /* _UIB-CODE-BLOCK-END */
1324 &ANALYZE-RESUME
1326 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-run V-table-Win
1327 PROCEDURE verify-run :
1328 /*------------------------------------------------------------------------------
1329 Purpose:
1330 ------------------------------------------------------------------------------*/
1331 DEF VAR print-date AS DATE NO-UNDO.
1332 DEF VAR n-days AS INT NO-UNDO.
1333 DEF VAR i AS INT NO-UNDO.
1334 DEF VAR start-cheque AS INT NO-UNDO.
1335 DEF VAR end-cheque AS INT NO-UNDO.
1337 DO WITH FRAME {&FRAME-NAME}:
1338 start-cheque = INPUT fil_startchq.
1339 n-days = INPUT fil_due.
1340 END.
1341 print-date = TODAY + n-days.
1343 IF start-cheque = 0 THEN DO:
1344 MESSAGE "You must enter a starting cheque number."
1345 VIEW-AS ALERT-BOX ERROR TITLE "No starting cheque entered".
1346 APPLY 'ENTRY':U TO fil_startchq.
1347 RETURN "FAIL".
1348 END.
1350 CASE INPUT RP.Int1:
1351 WHEN 1 THEN RUN build-creditor-range( print-date, OUTPUT creditor-list ). /* "CreditorRange" */
1352 WHEN 2 THEN RUN build-project-range( print-date, OUTPUT creditor-list ). /* "ProjectRange" */
1353 WHEN 3 THEN RUN build-account-range( print-date, OUTPUT creditor-list ). /* "AccountRange" */
1354 WHEN 4 THEN RUN build-creditor-list( print-date, OUTPUT creditor-list ). /* "CreditorList" */
1355 OTHERWISE DO:
1356 MESSAGE "Some form of selection must be chosen!"
1357 VIEW-AS ALERT-BOX ERROR TITLE "Select Range Type".
1358 /*APPLY 'ENTRY':U TO RP.Char3.*/
1359 RETURN "FAIL".
1360 END.
1361 END.
1363 RUN sort-by-creditor-name( INPUT creditor-list, OUTPUT creditor-list ).
1365 end-cheque = start-cheque + NUM-ENTRIES( creditor-list ) - 1.
1366 IF CAN-FIND( FIRST Cheque WHERE
1367 Cheque.BankAccountCode = BankAccount.BankAccountCode AND
1368 Cheque.ChequeNo >= start-cheque AND Cheque.ChequeNo <= end-cheque ) THEN
1370 MESSAGE
1371 "Cheque numbers could not be assigned because" SKIP
1372 "one or more of the required numbers has already" SKIP
1373 "been used." SKIP(2)
1374 "You need to change the starting cheque number."
1375 VIEW-AS ALERT-BOX ERROR TITLE "Cheque numbers already allocated".
1376 APPLY 'ENTRY':U TO fil_startchq IN FRAME {&FRAME-NAME}.
1377 RETURN "FAIL".
1378 END.
1381 IF NUM-ENTRIES( creditor-list ) = 0 THEN DO:
1382 MESSAGE "There are no cheques to be printed !" VIEW-AS ALERT-BOX INFORMATION.
1383 RETURN "FAIL".
1384 END.
1386 END PROCEDURE.
1388 /* _UIB-CODE-BLOCK-END */
1389 &ANALYZE-RESUME