Changes for Catalyst APMS. Added PDF checkboxes to screens the generate remittance...
[capital-apms-progress.git] / vwr / mnt / v-kcktru.w
blobae210aa6f668dd9493f4ca709785922353e6f046
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
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: v-kcktru.w
10 Description: Kick of transaction update
11 ------------------------------------------------------------------------*/
12 CREATE WIDGET-POOL.
13 /* *************************** Definitions ************************** */
15 DEFINE TEMP-TABLE Update-Month NO-UNDO
16 FIELD TrnCount AS INTEGER FORMAT ">>,>>9" COLUMN-LABEL "# Lines"
17 FIELD Closed AS CHAR FORMAT "X(6)" COLUMN-LABEL "Status"
18 FIELD MonthName AS CHAR FORMAT "X(3)" COLUMN-LABEL "Mth"
19 FIELD Year AS INT FORMAT "9999" COLUMN-LABEL "Year"
20 FIELD MonthCode LIKE Month.MonthCode
21 FIELD ActualMonth AS CHAR FORMAT "X(8)" COLUMN-LABEL "Post to"
22 FIELD MonthValue AS DEC FORMAT "->>,>>>,>>9.99" COLUMN-LABEL "Month Total"
23 INDEX XPKUpdate-Month IS UNIQUE PRIMARY MonthCode Closed .
25 {inc/ofc-this.i}
26 {inc/ofc-set-l.i "Fail-Unbalanced-Update" "fail-unbalanced-update"}
28 DEF VAR force-month AS INT NO-UNDO.
29 RUN pre-initialize.
31 /* _UIB-CODE-BLOCK-END */
32 &ANALYZE-RESUME
35 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
37 /* ******************** Preprocessor Definitions ******************** */
39 &Scoped-define PROCEDURE-TYPE SmartViewer
41 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
43 /* Name of first Frame and/or Browse and/or first Query */
44 &Scoped-define FRAME-NAME F-Main
45 &Scoped-define BROWSE-NAME br-UpdateMonths
47 /* External Tables */
48 &Scoped-define EXTERNAL-TABLES NewBatch
49 &Scoped-define FIRST-EXTERNAL-TABLE NewBatch
52 /* Need to scope the external tables to this procedure */
53 DEFINE QUERY external_tables FOR NewBatch.
54 /* Internal Tables (found by Frame, Query & Browse Queries) */
55 &Scoped-define INTERNAL-TABLES Update-Month
57 /* Definitions for BROWSE br-UpdateMonths */
58 &Scoped-define FIELDS-IN-QUERY-br-UpdateMonths MonthName Year Closed TrnCount ActualMonth MonthValue
59 &Scoped-define ENABLED-FIELDS-IN-QUERY-br-UpdateMonths
60 &Scoped-define FIELD-PAIRS-IN-QUERY-br-UpdateMonths
61 &Scoped-define SELF-NAME br-UpdateMonths
62 &Scoped-define OPEN-QUERY-br-UpdateMonths OPEN QUERY {&SELF-NAME} FOR EACH Update-Month BY Update-Month.MonthCode .
63 &Scoped-define TABLES-IN-QUERY-br-UpdateMonths Update-Month
64 &Scoped-define FIRST-TABLE-IN-QUERY-br-UpdateMonths Update-Month
67 /* Definitions for FRAME F-Main */
68 &Scoped-define OPEN-BROWSERS-IN-QUERY-F-Main ~
69 ~{&OPEN-QUERY-br-UpdateMonths}
71 /* Standard List Definitions */
72 &Scoped-Define ENABLED-OBJECTS RECT-13 br-UpdateMonths ~
73 tgl_ReverseNextPeriod btn_update cmb_ForceMonth tgl_ForceMonth
74 &Scoped-Define DISPLAYED-FIELDS NewBatch.Description NewBatch.BatchType ~
75 NewBatch.DocumentCount NewBatch.Total
76 &Scoped-Define DISPLAYED-OBJECTS fil_Operator tgl_ReverseNextPeriod ~
77 cmb_ForceMonth tgl_ForceMonth
79 /* Custom List Definitions */
80 /* ADM-CREATE-FIELDS,ADM-ASSIGN-FIELDS,List-3,List-4,List-5,List-6 */
82 /* _UIB-PREPROCESSOR-BLOCK-END */
83 &ANALYZE-RESUME
87 /* *********************** Control Definitions ********************** */
90 /* Definitions of the field level widgets */
91 DEFINE BUTTON btn_update DEFAULT
92 LABEL "&Update"
93 SIZE 16 BY 1.4
94 FONT 9.
96 DEFINE VARIABLE cmb_ForceMonth AS CHARACTER FORMAT "X(256)":U
97 LABEL "month"
98 VIEW-AS COMBO-BOX INNER-LINES 10
99 LIST-ITEMS "",""
100 SIZE 17.43 BY 1.05 NO-UNDO.
102 DEFINE VARIABLE fil_Operator AS CHARACTER FORMAT "X(256)":U
103 LABEL "Operator"
104 VIEW-AS FILL-IN
105 SIZE 49.43 BY 1
106 BGCOLOR 16 NO-UNDO.
108 DEFINE RECTANGLE RECT-13
109 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
110 SIZE 63.72 BY 14.3.
112 DEFINE VARIABLE tgl_ForceMonth AS LOGICAL INITIAL no
113 LABEL ""
114 VIEW-AS TOGGLE-BOX
115 SIZE 2.29 BY .8 NO-UNDO.
117 DEFINE VARIABLE tgl_ReverseNextPeriod AS LOGICAL INITIAL no
118 LABEL "Reversing Journal"
119 VIEW-AS TOGGLE-BOX
120 SIZE 16.57 BY 1.3 NO-UNDO.
122 /* Query definitions */
123 &ANALYZE-SUSPEND
124 DEFINE QUERY br-UpdateMonths FOR
125 Update-Month SCROLLING.
126 &ANALYZE-RESUME
128 /* Browse definitions */
129 DEFINE BROWSE br-UpdateMonths
130 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br-UpdateMonths V-table-Win _FREEFORM
131 QUERY br-UpdateMonths DISPLAY
132 MonthName
133 Year
134 Closed
135 TrnCount
136 ActualMonth
137 MonthValue
138 /* _UIB-CODE-BLOCK-END */
139 &ANALYZE-RESUME
140 WITH NO-ROW-MARKERS SEPARATORS SIZE 49.43 BY 6.9
141 FONT 8.
144 /* ************************ Frame Definitions *********************** */
146 DEFINE FRAME F-Main
147 NewBatch.Description AT ROW 1.4 COL 12.72 COLON-ALIGNED
148 LABEL "Description"
149 VIEW-AS FILL-IN
150 SIZE 49.43 BY 1
151 BGCOLOR 16 FONT 11
152 fil_Operator AT ROW 3 COL 12.72 COLON-ALIGNED
153 NewBatch.BatchType AT ROW 4.2 COL 12.72 COLON-ALIGNED
154 VIEW-AS FILL-IN
155 SIZE 6.86 BY 1
156 BGCOLOR 16
157 NewBatch.DocumentCount AT ROW 4.2 COL 29.86 COLON-ALIGNED
158 LABEL "Documents"
159 VIEW-AS FILL-IN
160 SIZE 10.29 BY .9
161 BGCOLOR 16
162 NewBatch.Total AT ROW 4.2 COL 48.72 COLON-ALIGNED FORMAT "-ZZZ,ZZZ,ZZ9.99"
163 VIEW-AS FILL-IN
164 SIZE 13.43 BY .9
165 BGCOLOR 16
166 br-UpdateMonths AT ROW 5.6 COL 14.72
167 tgl_ReverseNextPeriod AT ROW 12.5 COL 15
168 btn_update AT ROW 13.7 COL 48.14
169 cmb_ForceMonth AT ROW 13.9 COL 17.43
170 tgl_ForceMonth AT ROW 14 COL 15
171 RECT-13 AT ROW 1 COL 1
172 "Force posting to:" VIEW-AS TEXT
173 SIZE 11.72 BY 1 AT ROW 13.9 COL 3
174 "Update Months:" VIEW-AS TEXT
175 SIZE 11.43 BY 1 AT ROW 5.6 COL 3.29
176 FONT 10
177 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
178 SIDE-LABELS NO-UNDERLINE THREE-D
179 AT COL 1 ROW 1 SCROLLABLE
180 FONT 10
181 DEFAULT-BUTTON btn_update.
184 /* *********************** Procedure Settings ************************ */
186 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
187 /* Settings for THIS-PROCEDURE
188 Type: SmartViewer
189 External Tables: ttpl.NewBatch
190 Allow: Basic,DB-Fields
191 Frames: 1
192 Add Fields to: EXTERNAL-TABLES
193 Other Settings: PERSISTENT-ONLY COMPILE
196 /* This procedure should always be RUN PERSISTENT. Report the error, */
197 /* then cleanup and return. */
198 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
199 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
200 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
201 RETURN.
202 END.
204 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
206 /* ************************* Create Window ************************** */
208 &ANALYZE-SUSPEND _CREATE-WINDOW
209 /* DESIGN Window definition (used by the UIB)
210 CREATE WINDOW V-table-Win ASSIGN
211 HEIGHT = 16.95
212 WIDTH = 72.
213 /* END WINDOW DEFINITION */
215 &ANALYZE-RESUME
218 /* *************** Runtime Attributes and UIB Settings ************** */
220 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
221 /* SETTINGS FOR WINDOW V-table-Win
222 VISIBLE,,RUN-PERSISTENT */
223 /* SETTINGS FOR FRAME F-Main
224 NOT-VISIBLE Size-to-Fit */
225 /* BROWSE-TAB br-UpdateMonths Total F-Main */
226 ASSIGN
227 FRAME F-Main:SCROLLABLE = FALSE
228 FRAME F-Main:HIDDEN = TRUE.
230 /* SETTINGS FOR FILL-IN NewBatch.BatchType IN FRAME F-Main
231 NO-ENABLE */
232 /* SETTINGS FOR COMBO-BOX cmb_ForceMonth IN FRAME F-Main
233 ALIGN-L */
234 /* SETTINGS FOR FILL-IN NewBatch.Description IN FRAME F-Main
235 NO-ENABLE EXP-LABEL */
236 /* SETTINGS FOR FILL-IN NewBatch.DocumentCount IN FRAME F-Main
237 NO-ENABLE EXP-LABEL */
238 /* SETTINGS FOR FILL-IN fil_Operator IN FRAME F-Main
239 NO-ENABLE */
240 /* SETTINGS FOR FILL-IN NewBatch.Total IN FRAME F-Main
241 NO-ENABLE EXP-FORMAT */
242 /* _RUN-TIME-ATTRIBUTES-END */
243 &ANALYZE-RESUME
246 /* Setting information for Queries and Browse Widgets fields */
248 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br-UpdateMonths
249 /* Query rebuild information for BROWSE br-UpdateMonths
250 _START_FREEFORM
251 OPEN QUERY {&SELF-NAME} FOR EACH Update-Month
252 BY Update-Month.MonthCode .
253 _END_FREEFORM
254 _Query is OPENED
255 */ /* BROWSE br-UpdateMonths */
256 &ANALYZE-RESUME
258 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
259 /* Query rebuild information for FRAME F-Main
260 _Options = "NO-LOCK"
261 _Query is NOT OPENED
262 */ /* FRAME F-Main */
263 &ANALYZE-RESUME
268 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
269 /* ************************* Included-Libraries *********************** */
271 {src/adm/method/viewer.i}
272 {inc/method/m-drlvwr.i}
274 /* _UIB-CODE-BLOCK-END */
275 &ANALYZE-RESUME
280 /* ************************ Control Triggers ************************ */
282 &Scoped-define SELF-NAME btn_update
283 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_update V-table-Win
284 ON CHOOSE OF btn_update IN FRAME F-Main /* Update */
286 {&SELF-NAME}:SENSITIVE = No.
287 RUN update-batch.
288 {&SELF-NAME}:SENSITIVE = Yes.
289 RUN dispatch ( 'exit':U ).
290 END.
292 /* _UIB-CODE-BLOCK-END */
293 &ANALYZE-RESUME
296 &Scoped-define SELF-NAME cmb_ForceMonth
297 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_ForceMonth V-table-Win
298 ON U1 OF cmb_ForceMonth IN FRAME F-Main /* month */
300 {inc/selcmb/scmthe1.i "?" "force-month"}
301 END.
303 /* _UIB-CODE-BLOCK-END */
304 &ANALYZE-RESUME
307 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_ForceMonth V-table-Win
308 ON U2 OF cmb_ForceMonth IN FRAME F-Main /* month */
310 {inc/selcmb/scmthe2.i "?" "force-month"}
311 END.
313 /* _UIB-CODE-BLOCK-END */
314 &ANALYZE-RESUME
317 &Scoped-define SELF-NAME tgl_ForceMonth
318 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tgl_ForceMonth V-table-Win
319 ON VALUE-CHANGED OF tgl_ForceMonth IN FRAME F-Main
321 RUN enable-appropriate-fields.
322 END.
324 /* _UIB-CODE-BLOCK-END */
325 &ANALYZE-RESUME
328 &Scoped-define BROWSE-NAME br-UpdateMonths
329 &UNDEFINE SELF-NAME
331 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
334 /* *************************** Main Block *************************** */
336 /* _UIB-CODE-BLOCK-END */
337 &ANALYZE-RESUME
340 /* ********************** Internal Procedures *********************** */
342 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
343 PROCEDURE adm-row-available :
344 /*------------------------------------------------------------------------------
345 Purpose: Dispatched to this procedure when the Record-
346 Source has a new row available. This procedure
347 tries to get the new row (or foriegn keys) from
348 the Record-Source and process it.
349 Parameters: <none>
350 ------------------------------------------------------------------------------*/
352 /* Define variables needed by this internal procedure. */
353 {src/adm/template/row-head.i}
355 /* Create a list of all the tables that we need to get. */
356 {src/adm/template/row-list.i "NewBatch"}
358 /* Get the record ROWID's from the RECORD-SOURCE. */
359 {src/adm/template/row-get.i}
361 /* FIND each record specified by the RECORD-SOURCE. */
362 {src/adm/template/row-find.i "NewBatch"}
364 /* Process the newly available records (i.e. display fields,
365 open queries, and/or pass records on to any RECORD-TARGETS). */
366 {src/adm/template/row-end.i}
368 END PROCEDURE.
370 /* _UIB-CODE-BLOCK-END */
371 &ANALYZE-RESUME
374 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
375 PROCEDURE disable_UI :
376 /*------------------------------------------------------------------------------
377 Purpose: DISABLE the User Interface
378 Parameters: <none>
379 Notes: Here we clean-up the user-interface by deleting
380 dynamic widgets we have created and/or hide
381 frames. This procedure is usually called when
382 we are ready to "clean-up" after running.
383 ------------------------------------------------------------------------------*/
384 /* Hide all frames. */
385 HIDE FRAME F-Main.
386 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
387 END PROCEDURE.
389 /* _UIB-CODE-BLOCK-END */
390 &ANALYZE-RESUME
393 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable-appropriate-fields V-table-Win
394 PROCEDURE enable-appropriate-fields :
395 /*------------------------------------------------------------------------------
396 Purpose:
397 ------------------------------------------------------------------------------*/
398 DO WITH FRAME {&FRAME-NAME}:
399 IF INPUT tgl_ForceMonth THEN
400 ENABLE cmb_ForceMonth.
401 ELSE
402 DISABLE cmb_ForceMonth.
403 END.
404 END PROCEDURE.
406 /* _UIB-CODE-BLOCK-END */
407 &ANALYZE-RESUME
410 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE post-row-available V-table-Win
411 PROCEDURE post-row-available :
412 /*------------------------------------------------------------------------------
413 Purpose: Set the local batch code to the current row available
414 ------------------------------------------------------------------------------*/
415 DEF VAR month-status AS CHAR NO-UNDO.
417 DEF BUFFER xx-Month FOR Month.
419 IF NOT AVAILABLE(NewBatch) THEN RETURN.
421 DO WITH FRAME {&FRAME-NAME}:
422 APPLY 'U1':U TO cmb_ForceMonth.
423 RUN enable-appropriate-fields.
424 END.
427 FIND Person WHERE Person.PersonCode = NewBatch.PersonCode NO-LOCK NO-ERROR.
428 IF AVAILABLE(Person) AND Person.PersonCode > 0 THEN DO:
429 fil_Operator = Person.FirstName + " " + Person.LastName.
430 DISPLAY fil_Operator
431 WITH FRAME {&FRAME-NAME} IN WINDOW {&WINDOW-NAME}.
432 END.
434 FOR EACH NewAcctTrans OF NewBatch NO-LOCK:
435 IF NewAcctTrans.Date = ? OR NewAcctTrans.Date < DATE(1,1,1990) THEN DO:
436 MESSAGE "Transactions in Batch have bad Date field!"
437 VIEW-AS ALERT-BOX ERROR TITLE "Bad Dates in Batch".
438 RUN notify( 'exit':U ).
439 RETURN.
440 END.
441 FIND Month WHERE Month.MonthCode = NewAccttrans.MonthCode NO-LOCK NO-ERROR.
442 IF NOT AVAILABLE(Month) THEN
443 FIND LAST Month WHERE Month.StartDate <= NewAccttrans.Date NO-LOCK NO-ERROR.
444 IF NOT AVAILABLE(Month) THEN
445 FIND FIRST Month WHERE Month.EndDate >= NewAccttrans.Date NO-LOCK NO-ERROR.
446 month-status = (IF Month.MonthStatus = "CLOS" THEN (IF Month.MonthCode = NewAcctTrans.MonthCode THEN "Forced" ELSE "Closed") ELSE "").
448 FIND FIRST Update-Month WHERE Update-Month.MonthCode = Month.MonthCode
449 AND Update-Month.Closed = month-status NO-LOCK NO-ERROR.
450 IF NOT AVAILABLE(Update-Month) THEN DO:
451 CREATE Update-Month.
452 ASSIGN
453 Update-Month.MonthCode = Month.MonthCode
454 Update-Month.MonthName = Month.MonthName
455 Update-Month.Year = YEAR(Month.EndDate)
456 Update-Month.Closed = month-status
457 Update-Month.TrnCount = 0 .
459 IF month-status = "Closed" THEN DO:
460 FIND FIRST xx-Month WHERE xx-Month.MonthCode > Month.MonthCode
461 AND xx-Month.MonthStatus = "OPEN" NO-LOCK NO-ERROR.
462 IF NOT AVAILABLE(xx-Month) THEN
463 FIND LAST xx-Month WHERE xx-Month.MonthCode < Month.MonthCode
464 AND xx-Month.MonthStatus = "OPEN" NO-LOCK NO-ERROR.
465 IF NOT AVAILABLE(xx-Month) THEN
466 Update-Month.ActualMonth = "Not Open".
467 ELSE
468 Update-Month.ActualMonth = STRING(MONTH(xx-Month.StartDate), "99") + "/"
469 + STRING(YEAR(xx-Month.StartDate), "9999").
470 END.
471 END.
472 Update-Month.TrnCount = Update-Month.TrnCount + 1.
473 Update-Month.MonthValue = Update-Month.MonthValue + NewAcctTrans.Amount.
474 END.
475 OPEN QUERY br-UpdateMonths FOR EACH Update-Month BY Update-Month.MonthCode .
477 END PROCEDURE.
479 /* _UIB-CODE-BLOCK-END */
480 &ANALYZE-RESUME
483 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-initialize V-table-Win
484 PROCEDURE pre-initialize :
485 /*------------------------------------------------------------------------------
486 Purpose:
487 ------------------------------------------------------------------------------*/
489 FIND LAST Month WHERE Month.StartDate <= TODAY NO-LOCK NO-ERROR.
490 IF AVAILABLE(Month) THEN force-month = Month.MonthCode.
491 END.
492 END PROCEDURE.
494 /* _UIB-CODE-BLOCK-END */
495 &ANALYZE-RESUME
498 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
499 PROCEDURE send-records :
500 /*------------------------------------------------------------------------------
501 Purpose: Send record ROWID's for all tables used by
502 this file.
503 Parameters: see template/snd-head.i
504 ------------------------------------------------------------------------------*/
506 /* Define variables needed by this internal procedure. */
507 {src/adm/template/snd-head.i}
509 /* For each requested table, put it's ROWID in the output list. */
510 {src/adm/template/snd-list.i "NewBatch"}
511 {src/adm/template/snd-list.i "Update-Month"}
513 /* Deal with any unexpected table requests before closing. */
514 {src/adm/template/snd-end.i}
516 END PROCEDURE.
518 /* _UIB-CODE-BLOCK-END */
519 &ANALYZE-RESUME
522 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
523 PROCEDURE state-changed :
524 /* -----------------------------------------------------------
525 Purpose:
526 Parameters: <none>
527 Notes:
528 -------------------------------------------------------------*/
529 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
530 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
532 CASE p-state:
533 /* Object instance CASEs can go here to replace standard behavior
534 or add new cases. */
535 {src/adm/template/vstates.i}
536 END CASE.
537 END PROCEDURE.
539 /* _UIB-CODE-BLOCK-END */
540 &ANALYZE-RESUME
543 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-batch V-table-Win
544 PROCEDURE update-batch :
545 /*------------------------------------------------------------------------------
546 Purpose: Run the batch update program
547 ------------------------------------------------------------------------------*/
548 DEF VAR update-options AS CHAR NO-UNDO.
550 RUN verify-update.
551 IF RETURN-VALUE = "FAIL" THEN RETURN.
553 DO WITH FRAME {&FRAME-NAME}:
554 IF INPUT tgl_ForceMonth THEN
555 APPLY 'U2':U TO cmb_ForceMonth. /* Assign the values */
557 IF NewBatch.BatchType BEGINS "PART" THEN
558 /* don't muck around with partly posted ones - just let them be posted again! */.
559 ELSE DO TRANSACTION:
560 FIND CURRENT NewBatch EXCLUSIVE-LOCK.
561 NewBatch.BatchType = "UPDT".
562 FIND CURRENT NewBatch NO-LOCK.
563 END.
565 update-options = "DeleteAfterPosting"
566 + "~nBatchCode," + STRING(NewBatch.BatchCode)
567 + (IF INPUT tgl_ReverseNextPeriod THEN
568 "~nReverseNextPeriod" ELSE "")
569 + (IF INPUT tgl_ForceMonth THEN
570 ("~nForceMonth," + STRING(force-month))
571 ELSE "")
572 + "~nPrintAfterPosting".
573 END.
574 RUN make-bq-entry IN sys-mgr( "process/tru.p", update-options, ?, ?).
576 DO TRANSACTION:
577 FIND CURRENT NewBatch EXCLUSIVE-LOCK NO-ERROR.
578 IF AVAILABLE(NewBatch) AND NewBatch.BatchType = "UPDT" THEN
579 NewBatch.BatchType = "NORM".
580 FIND CURRENT NewBatch NO-LOCK NO-ERROR.
581 END.
583 RUN notify( 'open-query,record-source':U ).
585 END PROCEDURE.
587 /* _UIB-CODE-BLOCK-END */
588 &ANALYZE-RESUME
591 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-update V-table-Win
592 PROCEDURE verify-update :
593 /*------------------------------------------------------------------------------
594 Purpose:
595 ------------------------------------------------------------------------------*/
596 DEF VAR mth-valid AS LOGICAL INITIAL Yes NO-UNDO.
597 DEF VAR warn-result AS LOGICAL INITIAL no NO-UNDO.
599 IF NOT AVAILABLE(NewBatch) THEN DO:
600 MESSAGE "There is no batch selected for update!" SKIP
601 "Please choose a valid batch"
602 VIEW-AS ALERT-BOX ERROR TITLE "Error Running Update".
603 RETURN "FAIL".
604 END.
606 IF NewBatch.BatchType = "ACCR" THEN DO:
607 MESSAGE "Use the Batch Tool to create a 'NORM' batch and update that"
608 VIEW-AS ALERT-BOX ERROR TITLE "Accruals batches cannot update directly".
609 RETURN "FAIL".
610 END.
612 IF CAN-FIND( FIRST Update-Month WHERE Update-Month.Closed = "Closed" ) THEN DO:
613 MESSAGE "Some transactions in this batch relate to closed" SKIP
614 "months. You may want to cancel this batch update" SKIP
615 "and open those months for posting!" SKIP(2)
616 "Or do you want to update the batch anyway, with those" SKIP
617 "transactions posting to the nearest open months?"
618 VIEW-AS ALERT-BOX WARNING BUTTONS OK-CANCEL
619 TITLE "Warning: Transactions relate to closed months"
620 UPDATE warn-result.
621 IF NOT warn-result THEN RETURN "FAIL".
622 END.
624 IF NewBatch.Total <> 0 THEN DO:
625 DEF VAR btot AS DECIMAL NO-UNDO.
627 FOR EACH NewDocument OF NewBatch NO-LOCK,
628 EACH NewAcctTrans OF NewDocument NO-LOCK:
629 btot = btot + ((IF NewDocument.DocumentType = "RCPT" THEN -1 ELSE 1) * NewAcctTrans.Amount).
630 IF NOT CAN-FIND( Month WHERE Month.StartDate >= NewAcctTrans.Date
631 AND Month.EndDate <= NewAcctTrans.Date
632 AND Month.MonthStatus = "OPEN")
633 THEN mth-valid = No.
634 END.
636 IF btot <> 0 AND fail-unbalanced-update AND NOT(NewBatch.BatchType BEGINS "PART") THEN DO:
637 MESSAGE "Batch total does not equal zero!"
638 VIEW-AS ALERT-BOX ERROR
639 TITLE "Error: Non-zero batch total!".
640 RETURN "FAIL".
641 END.
642 ELSE IF btot <> 0 THEN DO:
643 warn-result = no.
644 MESSAGE "Batch total does not equal zero!" SKIP
645 "Are you sure you want to update it?"
646 VIEW-AS ALERT-BOX WARNING BUTTONS OK-CANCEL
647 TITLE "Warning: Non-zero batch total!"
648 UPDATE warn-result.
649 IF NOT warn-result THEN RETURN "FAIL".
650 END.
652 END.
654 END PROCEDURE.
656 /* _UIB-CODE-BLOCK-END */
657 &ANALYZE-RESUME