Added capital works blank section. Synced calling screen.
[capital-apms-progress.git] / win / w-trncls.w
blobaf7ef319e2d81f8a6f63737f52a5e67ae4e6e08e
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI ADM1
2 &ANALYZE-RESUME
3 /* Connected Databases
4 ttpl PROGRESS
5 */
6 &Scoped-define WINDOW-NAME W-Win
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS W-Win
8 /*------------------------------------------------------------------------
9 ------------------------------------------------------------------------*/
11 CREATE WIDGET-POOL.
13 /* *************************** Definitions ************************** */
15 DEF VAR reference AS CHAR FORMAT "X(12)" LABEL "Reference" NO-UNDO.
16 DEF VAR description AS CHAR FORMAT "X(60)" LABEL "Description" NO-UNDO.
18 DEF VAR sundry-creditors LIKE ChartOfAccount.AccountCode NO-UNDO.
19 DEF VAR sundry-debtors LIKE ChartOfAccount.AccountCode NO-UNDO.
21 DEF VAR source-table AS CHAR NO-UNDO.
24 DEFINE WORK-TABLE OpenTrans NO-UNDO
25 FIELD rowid AS ROWID
26 FIELD state AS CHAR FORMAT "X" COLUMN-LABEL "S"
27 FIELD Date LIKE AcctTran.Date
28 FIELD Reference LIKE AcctTran.Reference
29 FIELD Description LIKE AcctTran.Description
30 FIELD Amount LIKE AcctTran.Amount.
32 {inc/ofc-this.i}
33 FIND OfficeControlAccount NO-LOCK OF Office WHERE OfficeControlAccount.Name = "DEBTORS".
34 sundry-debtors = OfficeControlAccount.AccountCode.
35 FIND OfficeControlAccount NO-LOCK OF Office WHERE OfficeControlAccount.Name = "CREDITORS".
36 sundry-creditors = OfficeControlAccount.AccountCode.
38 {inc/ofc-set-l.i "Multi-Ledger-Creditors" "multi-ledger-creditors"}
40 /* _UIB-CODE-BLOCK-END */
41 &ANALYZE-RESUME
44 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
46 /* ******************** Preprocessor Definitions ******************** */
48 &Scoped-define PROCEDURE-TYPE SmartWindow
49 &Scoped-define DB-AWARE no
51 &Scoped-define ADM-CONTAINER WINDOW
53 /* Name of first Frame and/or Browse and/or first Query */
54 &Scoped-define FRAME-NAME F-Main
55 &Scoped-define BROWSE-NAME br-trn
57 /* External Tables */
58 &Scoped-define EXTERNAL-TABLES Tenant Creditor
59 &Scoped-define FIRST-EXTERNAL-TABLE Tenant
62 /* Need to scope the external tables to this procedure */
63 DEFINE QUERY external_tables FOR Tenant, Creditor.
64 /* Internal Tables (found by Frame, Query & Browse Queries) */
65 &Scoped-define INTERNAL-TABLES OpenTrans
67 /* Definitions for BROWSE br-trn */
68 &Scoped-define FIELDS-IN-QUERY-br-trn OpenTrans.State OpenTrans.Date OpenTrans.Reference OpenTrans.Description OpenTrans.Amount
69 &Scoped-define ENABLED-FIELDS-IN-QUERY-br-trn
70 &Scoped-define SELF-NAME br-trn
71 &Scoped-define QUERY-STRING-br-trn FOR EACH OpenTrans
72 &Scoped-define OPEN-QUERY-br-trn OPEN QUERY BROWSE-2 FOR EACH OpenTrans.
73 &Scoped-define TABLES-IN-QUERY-br-trn OpenTrans
74 &Scoped-define FIRST-TABLE-IN-QUERY-br-trn OpenTrans
77 /* Definitions for FRAME F-Main */
78 &Scoped-define OPEN-BROWSERS-IN-QUERY-F-Main ~
79 ~{&OPEN-QUERY-br-trn}
81 /* Standard List Definitions */
82 &Scoped-Define ENABLED-OBJECTS fil_Entity br-trn btn_all btn_none ~
83 btn_ReOpen fil_PartCloseAs btn_close-part btn_close btn_cancel ~
84 fil_EntityType RECT-4
85 &Scoped-Define DISPLAYED-OBJECTS fil_Entity fil_entityname fil_total ~
86 fil_PartCloseAs fil_EntityType
88 /* Custom List Definitions */
89 /* List-1,List-2,List-3,List-4,List-5,List-6 */
91 /* _UIB-PREPROCESSOR-BLOCK-END */
92 &ANALYZE-RESUME
96 /* *********************** Control Definitions ********************** */
98 /* Define the widget handle for the window */
99 DEFINE VAR W-Win AS WIDGET-HANDLE NO-UNDO.
101 /* Definitions of the field level widgets */
102 DEFINE BUTTON btn_all
103 LABEL "Select &All"
104 SIZE 10 BY 1.05
105 FONT 9.
107 DEFINE BUTTON btn_cancel
108 LABEL "&Cancel"
109 SIZE 10 BY 1.05
110 FONT 9.
112 DEFINE BUTTON btn_close
113 LABEL "Close &Group"
114 SIZE 10.86 BY 1.05
115 FONT 9.
117 DEFINE BUTTON btn_close-part
118 LABEL "&Partial Close"
119 SIZE 11.43 BY 1.05
120 FONT 9.
122 DEFINE BUTTON btn_none
123 LABEL "&Select &None"
124 SIZE 12.57 BY 1.05
125 FONT 9.
127 DEFINE BUTTON btn_ReOpen
128 LABEL "&Re-Open Group"
129 SIZE 13.14 BY 1.05
130 FONT 10.
132 DEFINE VARIABLE fil_Entity AS INTEGER FORMAT "999999":U INITIAL ?
133 VIEW-AS FILL-IN
134 SIZE 7 BY 1
135 FONT 10 NO-UNDO.
137 DEFINE VARIABLE fil_entityname AS CHARACTER FORMAT "X(256)":U
138 VIEW-AS FILL-IN
139 SIZE 49.14 BY 1
140 FGCOLOR 12 FONT 10 NO-UNDO.
142 DEFINE VARIABLE fil_EntityType AS CHARACTER FORMAT "X(256)":U
143 VIEW-AS TEXT
144 SIZE 6.86 BY 1
145 FONT 10 NO-UNDO.
147 DEFINE VARIABLE fil_PartCloseAs AS CHARACTER FORMAT "X(256)":U
148 VIEW-AS FILL-IN
149 SIZE 49.14 BY 1
150 FONT 10 NO-UNDO.
152 DEFINE VARIABLE fil_total AS DECIMAL FORMAT "ZZZ,ZZZ,ZZ9.99CR":U INITIAL 0
153 LABEL "Total"
154 VIEW-AS FILL-IN
155 SIZE 18.29 BY 1 NO-UNDO.
157 DEFINE RECTANGLE RECT-4
158 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
159 SIZE 97.14 BY 19.4.
161 /* Query definitions */
162 &ANALYZE-SUSPEND
163 DEFINE QUERY br-trn FOR
164 OpenTrans SCROLLING.
165 &ANALYZE-RESUME
167 /* Browse definitions */
168 DEFINE BROWSE br-trn
169 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br-trn W-Win _FREEFORM
170 QUERY br-trn NO-LOCK DISPLAY
171 OpenTrans.State
172 OpenTrans.Date
173 OpenTrans.Reference
174 OpenTrans.Description
175 OpenTrans.Amount
176 /* _UIB-CODE-BLOCK-END */
177 &ANALYZE-RESUME
178 WITH NO-ROW-MARKERS MULTIPLE SIZE 96 BY 16.6 ROW-HEIGHT-CHARS .5.
181 /* ************************ Frame Definitions *********************** */
183 DEFINE FRAME F-Main
184 fil_Entity AT ROW 1.4 COL 7 COLON-ALIGNED NO-LABEL
185 fil_entityname AT ROW 1.4 COL 16.14 COLON-ALIGNED NO-LABEL
186 br-trn AT ROW 2.6 COL 2.14
187 btn_all AT ROW 19.4 COL 2.14
188 btn_none AT ROW 19.4 COL 13.57
189 btn_ReOpen AT ROW 19.4 COL 27.86
190 fil_total AT ROW 19.4 COL 77.86 COLON-ALIGNED
191 fil_PartCloseAs AT ROW 20.8 COL 8.72 COLON-ALIGNED NO-LABEL
192 btn_close-part AT ROW 20.8 COL 59.86
193 btn_close AT ROW 20.8 COL 74.14
194 btn_cancel AT ROW 20.8 COL 87.86
195 fil_EntityType AT ROW 1.4 COL 2.14 NO-LABEL
196 RECT-4 AT ROW 1.2 COL 1.57
197 "Part Close As" VIEW-AS TEXT
198 SIZE 9.14 BY 1 AT ROW 20.8 COL 1.57
199 FONT 10
200 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
201 SIDE-LABELS NO-UNDERLINE THREE-D
202 AT COL 1 ROW 1 SCROLLABLE .
205 /* *********************** Procedure Settings ************************ */
207 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
208 /* Settings for THIS-PROCEDURE
209 Type: SmartWindow
210 External Tables: TTPL.Tenant,TTPL.Creditor
211 Allow: Basic,Browse,DB-Fields,Query,Smart,Window
212 Other Settings: COMPILE
214 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
216 /* ************************* Create Window ************************** */
218 &ANALYZE-SUSPEND _CREATE-WINDOW
219 IF SESSION:DISPLAY-TYPE = "GUI":U THEN
220 CREATE WINDOW W-Win ASSIGN
221 HIDDEN = YES
222 TITLE = "Manual Transaction Closing"
223 HEIGHT = 21.05
224 WIDTH = 98.14
225 MAX-HEIGHT = 50.3
226 MAX-WIDTH = 182.86
227 VIRTUAL-HEIGHT = 50.3
228 VIRTUAL-WIDTH = 182.86
229 RESIZE = no
230 SCROLL-BARS = no
231 STATUS-AREA = no
232 BGCOLOR = ?
233 FGCOLOR = ?
234 THREE-D = yes
235 MESSAGE-AREA = no
236 SENSITIVE = yes.
237 ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
238 /* END WINDOW DEFINITION */
239 &ANALYZE-RESUME
241 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB W-Win
242 /* ************************* Included-Libraries *********************** */
244 {src/adm/method/containr.i}
245 {inc/method/m-drlwin.i}
247 /* _UIB-CODE-BLOCK-END */
248 &ANALYZE-RESUME
253 /* *********** Runtime Attributes and AppBuilder Settings *********** */
255 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
256 /* SETTINGS FOR WINDOW W-Win
257 VISIBLE,,RUN-PERSISTENT */
258 /* SETTINGS FOR FRAME F-Main
259 Size-to-Fit */
260 /* BROWSE-TAB br-trn fil_entityname F-Main */
261 ASSIGN
262 FRAME F-Main:SCROLLABLE = FALSE.
264 /* SETTINGS FOR FILL-IN fil_entityname IN FRAME F-Main
265 NO-ENABLE */
266 /* SETTINGS FOR FILL-IN fil_EntityType IN FRAME F-Main
267 ALIGN-L */
268 /* SETTINGS FOR FILL-IN fil_total IN FRAME F-Main
269 NO-ENABLE */
270 IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-Win)
271 THEN W-Win:HIDDEN = yes.
273 /* _RUN-TIME-ATTRIBUTES-END */
274 &ANALYZE-RESUME
277 /* Setting information for Queries and Browse Widgets fields */
279 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br-trn
280 /* Query rebuild information for BROWSE br-trn
281 _START_FREEFORM
282 OPEN QUERY BROWSE-2 FOR EACH OpenTrans.
283 _END_FREEFORM
284 _Options = "NO-LOCK"
285 _Query is OPENED
286 */ /* BROWSE br-trn */
287 &ANALYZE-RESUME
293 /* ************************ Control Triggers ************************ */
295 &Scoped-define SELF-NAME W-Win
296 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-Win W-Win
297 ON END-ERROR OF W-Win /* Manual Transaction Closing */
298 OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
299 /* This case occurs when the user presses the "Esc" key.
300 In a persistently run window, just ignore this. If we did not, the
301 application would exit. */
302 IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
303 END.
305 /* _UIB-CODE-BLOCK-END */
306 &ANALYZE-RESUME
309 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-Win W-Win
310 ON WINDOW-CLOSE OF W-Win /* Manual Transaction Closing */
312 /* This ADM code must be left here in order for the SmartWindow
313 and its descendents to terminate properly on exit. */
314 APPLY "CLOSE":U TO THIS-PROCEDURE.
315 RETURN NO-APPLY.
316 END.
318 /* _UIB-CODE-BLOCK-END */
319 &ANALYZE-RESUME
322 &Scoped-define BROWSE-NAME br-trn
323 &Scoped-define SELF-NAME br-trn
324 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br-trn W-Win
325 ON ROW-DISPLAY OF br-trn IN FRAME F-Main
327 IF AVAILABLE OpenTrans THEN
328 ASSIGN OpenTrans.Amount:FGCOLOR IN BROWSE br-trn =
329 IF OpenTrans.Amount < 0 THEN 12 ELSE ?.
330 END.
332 /* _UIB-CODE-BLOCK-END */
333 &ANALYZE-RESUME
336 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br-trn W-Win
337 ON VALUE-CHANGED OF br-trn IN FRAME F-Main
339 RUN selection-changed.
340 END.
342 /* _UIB-CODE-BLOCK-END */
343 &ANALYZE-RESUME
346 &Scoped-define SELF-NAME btn_all
347 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_all W-Win
348 ON CHOOSE OF btn_all IN FRAME F-Main /* Select All */
350 RUN select-all.
351 END.
353 /* _UIB-CODE-BLOCK-END */
354 &ANALYZE-RESUME
357 &Scoped-define SELF-NAME btn_cancel
358 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_cancel W-Win
359 ON CHOOSE OF btn_cancel IN FRAME F-Main /* Cancel */
361 RUN dispatch( 'exit':U ).
362 END.
364 /* _UIB-CODE-BLOCK-END */
365 &ANALYZE-RESUME
368 &Scoped-define SELF-NAME btn_close
369 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_close W-Win
370 ON CHOOSE OF btn_close IN FRAME F-Main /* Close Group */
372 DEF VAR retry-it AS LOGI INIT Yes.
374 DO WHILE retry-it:
376 RUN close-transactions("F").
377 IF RETURN-VALUE = "FAIL" THEN
378 MESSAGE "A database error has occured" VIEW-AS ALERT-BOX ERROR
379 BUTTONS RETRY-CANCEL TITLE "Error closing transactions"
380 UPDATE retry-it.
381 ELSE
383 MESSAGE "Transactions successfully closed" VIEW-AS ALERT-BOX INFORMATION.
384 RUN open-trn-query.
385 RUN selection-changed.
386 retry-it = No.
387 END.
388 END.
389 APPLY 'ENTRY':U TO fil_Entity .
390 RETURN NO-APPLY.
391 END.
393 /* _UIB-CODE-BLOCK-END */
394 &ANALYZE-RESUME
397 &Scoped-define SELF-NAME btn_close-part
398 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_close-part W-Win
399 ON CHOOSE OF btn_close-part IN FRAME F-Main /* Partial Close */
401 DEF VAR retry-it AS LOGI INIT Yes NO-UNDO.
403 DO WHILE retry-it:
405 RUN close-transactions("P").
406 IF RETURN-VALUE = "FAIL" THEN
407 MESSAGE "A database error has occured" VIEW-AS ALERT-BOX ERROR
408 BUTTONS RETRY-CANCEL TITLE "Error closing transactions"
409 UPDATE retry-it.
410 ELSE
412 MESSAGE "Transactions successfully closed" VIEW-AS ALERT-BOX INFORMATION.
413 RUN open-trn-query.
414 RUN selection-changed.
415 retry-it = No.
416 END.
417 END.
418 APPLY 'ENTRY':U TO fil_Entity .
419 RETURN NO-APPLY.
420 END.
422 /* _UIB-CODE-BLOCK-END */
423 &ANALYZE-RESUME
426 &Scoped-define SELF-NAME btn_none
427 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_none W-Win
428 ON CHOOSE OF btn_none IN FRAME F-Main /* Select None */
430 RUN select-none.
431 END.
433 /* _UIB-CODE-BLOCK-END */
434 &ANALYZE-RESUME
437 &Scoped-define SELF-NAME btn_ReOpen
438 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_ReOpen W-Win
439 ON CHOOSE OF btn_ReOpen IN FRAME F-Main /* Re-Open Group */
441 RUN re-open-group.
442 END.
444 /* _UIB-CODE-BLOCK-END */
445 &ANALYZE-RESUME
448 &Scoped-define SELF-NAME fil_Entity
449 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Entity W-Win
450 ON LEAVE OF fil_Entity IN FRAME F-Main
452 IF fil_entity <> INPUT FRAME {&FRAME-NAME} fil_entity THEN
453 RUN entity-changed.
454 IF RETURN-VALUE = "FAIL" THEN RETURN NO-APPLY.
455 END.
457 /* _UIB-CODE-BLOCK-END */
458 &ANALYZE-RESUME
461 &Scoped-define SELF-NAME fil_PartCloseAs
462 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_PartCloseAs W-Win
463 ON ANY-PRINTABLE OF fil_PartCloseAs IN FRAME F-Main
465 IF TRIM(SELF:SCREEN-VALUE) <> "" THEN
466 ENABLE btn_close-part WITH FRAME {&FRAME-NAME}.
467 ELSE
468 DISABLE btn_close-part WITH FRAME {&FRAME-NAME}.
469 END.
471 /* _UIB-CODE-BLOCK-END */
472 &ANALYZE-RESUME
475 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_PartCloseAs W-Win
476 ON LEAVE OF fil_PartCloseAs IN FRAME F-Main
478 RUN selection-changed.
479 END.
481 /* _UIB-CODE-BLOCK-END */
482 &ANALYZE-RESUME
485 &UNDEFINE SELF-NAME
487 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK W-Win
490 /* *************************** Main Block *************************** */
492 /* Include custom Main Block code for SmartWindows. */
493 {src/adm/template/windowmn.i}
495 /* _UIB-CODE-BLOCK-END */
496 &ANALYZE-RESUME
499 /* ********************** Internal Procedures *********************** */
501 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects W-Win _ADM-CREATE-OBJECTS
502 PROCEDURE adm-create-objects :
503 /*------------------------------------------------------------------------------
504 Purpose: Create handles for all SmartObjects used in this procedure.
505 After SmartObjects are initialized, then SmartLinks are added.
506 Parameters: <none>
507 ------------------------------------------------------------------------------*/
509 END PROCEDURE.
511 /* _UIB-CODE-BLOCK-END */
512 &ANALYZE-RESUME
514 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available W-Win
515 PROCEDURE adm-row-available :
516 /*------------------------------------------------------------------------------
517 Purpose:
518 Parameters: <none>
519 Notes:
520 ------------------------------------------------------------------------------*/
522 /* Define variables needed by this internal procedure. */
523 {src/adm/template/row-head.i}
525 /* Create a list of all the tables that we need to get. */
526 IF {inc/availrow.i "list" "Tenant"}
527 ELSE IF {inc/availrow.i "list" "Creditor"}
529 /* Get the record ROWID's from the RECORD-SOURCE. */
530 {src/adm/template/row-get.i}
532 /* FIND each record specified by the RECORD-SOURCE. */
533 IF {inc/availrow.i "find" "Tenant"}
534 ELSE IF {inc/availrow.i "find" "Creditor"}
536 /* Process the newly available records (i.e. display fields,
537 open queries, and/or pass records on to any RECORD-TARGETS). */
538 {src/adm/template/row-end.i}
540 END PROCEDURE.
542 /* _UIB-CODE-BLOCK-END */
543 &ANALYZE-RESUME
545 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE close-transactions W-Win
546 PROCEDURE close-transactions :
547 /*------------------------------------------------------------------------------
548 Purpose:
549 Parameters: <none>
550 Notes:
551 ------------------------------------------------------------------------------*/
552 DEF INPUT PARAMETER new-state AS CHAR NO-UNDO.
554 DO WITH FRAME {&FRAME-NAME}:
555 DEF VAR i AS INT NO-UNDO.
556 DEF VAR closing-group LIKE AcctTran.ClosingGroup NO-UNDO.
557 DEF VAR entity-type LIKE AcctTran.EntityType NO-UNDO.
558 DEF VAR entity-code LIKE AcctTran.EntityCode NO-UNDO.
559 DEF VAR account-code LIKE AcctTran.AccountCode NO-UNDO.
560 DEF VAR last-date AS DATE NO-UNDO.
562 DEF BUFFER LastAcctTran FOR AcctTran.
564 entity-type = IF AVAILABLE Tenant THEN 'T' ELSE 'C'.
565 entity-code = IF AVAILABLE Tenant THEN Tenant.TenantCode ELSE Creditor.CreditorCode.
566 account-code = IF AVAILABLE Tenant THEN sundry-debtors ELSE sundry-creditors.
568 last-date = DATE( 1, 1, 1).
569 close-transactions:
570 DO TRANSACTION ON ERROR UNDO close-transactions, RETURN "FAIL":
572 closing-group = ?.
573 DO i = 1 TO br-trn:NUM-SELECTED-ROWS:
574 IF br-trn:FETCH-SELECTED-ROW( i ) THEN.
575 FIND CURRENT OpenTrans.
576 IF OpenTrans.State = "P" THEN DO:
577 FIND ClosingGroup EXCLUSIVE-LOCK WHERE ROWID(ClosingGroup) = OpenTrans.rowid.
578 FOR EACH AcctTran EXCLUSIVE-LOCK OF ClosingGroup:
579 ASSIGN AcctTran.ClosingGroup = (IF closing-group = ? THEN ClosingGroup.ClosingGroup ELSE closing-group)
580 AcctTran.ClosedState = new-state.
581 last-date = MAXIMUM( AcctTran.Date, last-date ).
582 END.
583 IF closing-group = ? THEN ASSIGN
584 closing-group = ClosingGroup.ClosingGroup
585 ClosingGroup.ClosedStatus = new-state
586 ClosingGroup.Description = (IF new-state = "P" THEN INPUT fil_PartCloseAs ELSE "").
587 ELSE DO:
588 DELETE ClosingGroup.
589 END.
590 END.
591 END.
593 IF closing-group = ? THEN DO:
594 FIND LAST ClosingGroup WHERE ClosingGroup.EntityType = entity-type
595 AND ClosingGroup.EntityCode = entity-code
596 AND ClosingGroup.AccountCode = account-code
597 AND ClosingGroup.ClosingGroup > 0
598 NO-LOCK NO-ERROR.
600 closing-group = IF AVAILABLE(ClosingGroup) AND ClosingGroup.ClosingGroup <> ? THEN
601 ClosingGroup.ClosingGroup + 1 ELSE 1.
603 CREATE ClosingGroup.
604 ASSIGN
605 ClosingGroup.EntityType = entity-type
606 ClosingGroup.EntityCode = entity-code
607 ClosingGroup.AccountCode = account-code
608 ClosingGroup.ClosingGroup = closing-group
609 ClosingGroup.DateClosed = TODAY
610 ClosingGroup.Description = (IF new-state = "P" THEN INPUT fil_PartCloseAs ELSE "").
611 END.
612 ELSE
613 FIND ClosingGroup WHERE ClosingGroup.EntityType = entity-type
614 AND ClosingGroup.EntityCode = entity-code
615 AND ClosingGroup.AccountCode = account-code
616 AND ClosingGroup.ClosingGroup = closing-group NO-LOCK.
618 DO i = 1 TO br-trn:NUM-SELECTED-ROWS:
619 IF br-trn:FETCH-SELECTED-ROW(i) THEN.
620 FIND CURRENT OpenTrans.
621 IF OpenTrans.State = "O" THEN DO:
622 FIND AcctTran EXCLUSIVE-LOCK WHERE ROWID(AcctTran) = OpenTrans.rowid.
623 ASSIGN AcctTran.ClosingGroup = closing-group
624 AcctTran.ClosedState = new-state.
625 last-date = MAXIMUM( AcctTran.Date, last-date ).
626 FIND CURRENT AcctTran NO-LOCK.
627 END.
628 END.
630 FIND ClosingGroup WHERE ClosingGroup.EntityType = entity-type
631 AND ClosingGroup.EntityCode = entity-code
632 AND ClosingGroup.AccountCode = account-code
633 AND ClosingGroup.ClosingGroup = closing-group EXCLUSIVE-LOCK.
635 ClosingGroup.ClosedStatus = new-state.
636 ClosingGroup.DateClosed = last-date.
638 FIND ClosingGroup WHERE ClosingGroup.EntityType = entity-type
639 AND ClosingGroup.EntityCode = entity-code
640 AND ClosingGroup.AccountCode = account-code
641 AND ClosingGroup.ClosingGroup = closing-group NO-LOCK.
642 END.
643 END.
644 END PROCEDURE.
646 /* _UIB-CODE-BLOCK-END */
647 &ANALYZE-RESUME
649 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE close-trn-query W-Win
650 PROCEDURE close-trn-query :
651 /*------------------------------------------------------------------------------
652 Purpose:
653 Parameters: <none>
654 Notes:
655 ------------------------------------------------------------------------------*/
657 CLOSE QUERY br-trn.
659 END PROCEDURE.
661 /* _UIB-CODE-BLOCK-END */
662 &ANALYZE-RESUME
664 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI W-Win _DEFAULT-DISABLE
665 PROCEDURE disable_UI :
666 /*------------------------------------------------------------------------------
667 Purpose: DISABLE the User Interface
668 Parameters: <none>
669 Notes: Here we clean-up the user-interface by deleting
670 dynamic widgets we have created and/or hide
671 frames. This procedure is usually called when
672 we are ready to "clean-up" after running.
673 ------------------------------------------------------------------------------*/
674 /* Delete the WINDOW we created */
675 IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-Win)
676 THEN DELETE WIDGET W-Win.
677 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
678 END PROCEDURE.
680 /* _UIB-CODE-BLOCK-END */
681 &ANALYZE-RESUME
683 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI W-Win _DEFAULT-ENABLE
684 PROCEDURE enable_UI :
685 /*------------------------------------------------------------------------------
686 Purpose: ENABLE the User Interface
687 Parameters: <none>
688 Notes: Here we display/view/enable the widgets in the
689 user-interface. In addition, OPEN all queries
690 associated with each FRAME and BROWSE.
691 These statements here are based on the "Other
692 Settings" section of the widget Property Sheets.
693 ------------------------------------------------------------------------------*/
694 DISPLAY fil_Entity fil_entityname fil_total fil_PartCloseAs fil_EntityType
695 WITH FRAME F-Main IN WINDOW W-Win.
696 ENABLE fil_Entity br-trn btn_all btn_none btn_ReOpen fil_PartCloseAs
697 btn_close-part btn_close btn_cancel fil_EntityType RECT-4
698 WITH FRAME F-Main IN WINDOW W-Win.
699 {&OPEN-BROWSERS-IN-QUERY-F-Main}
700 VIEW W-Win.
701 END PROCEDURE.
703 /* _UIB-CODE-BLOCK-END */
704 &ANALYZE-RESUME
706 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE entity-changed W-Win
707 PROCEDURE entity-changed :
708 /*------------------------------------------------------------------------------
709 Purpose:
710 ------------------------------------------------------------------------------*/
712 DEF VAR unavailable AS LOGI INIT Yes NO-UNDO.
713 DEF VAR entity-name AS CHAR NO-UNDO.
715 IF source-table = 'Creditor' THEN
717 FIND Creditor WHERE Creditor.CreditorCode = INPUT FRAME {&FRAME-NAME}
718 fil_entity NO-LOCK NO-ERROR.
719 ASSIGN entity-name = Creditor.Name NO-ERROR.
720 unavailable = NOT AVAILABLE Creditor.
721 END.
722 ELSE IF source-table = 'Tenant' THEN
724 FIND Tenant WHERE Tenant.TenantCode = INPUT FRAME {&FRAME-NAME}
725 fil_entity NO-LOCK NO-ERROR.
726 ASSIGN entity-name = Tenant.Name NO-ERROR.
727 unavailable = NOT AVAILABLE Tenant.
728 END.
730 IF unavailable THEN
732 MESSAGE "There is no" source-table "with code" INPUT FRAME {&FRAME-NAME} fil_entity
733 VIEW-AS ALERT-BOX ERROR.
734 DISPLAY fil_entity WITH FRAME {&FRAME-NAME}.
735 APPLY 'ENTRY':U TO fil_entity IN FRAME {&FRAME-NAME}.
736 RETURN "FAIL".
737 END.
739 ASSIGN fil_entity.
740 ASSIGN fil_entityname = entity-name.
741 DISPLAY fil_entityname WITH FRAME {&FRAME-NAME}.
743 RUN open-trn-query.
744 RUN selection-changed.
746 END PROCEDURE.
748 /* _UIB-CODE-BLOCK-END */
749 &ANALYZE-RESUME
751 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-exit W-Win
752 PROCEDURE local-exit :
753 /* -----------------------------------------------------------
754 Purpose: Starts an "exit" by APPLYing CLOSE event, which starts "destroy".
755 Parameters: <none>
756 Notes: If activated, should APPLY CLOSE, *not* dispatch adm-exit.
757 -------------------------------------------------------------*/
758 APPLY "CLOSE":U TO THIS-PROCEDURE.
760 RETURN.
762 END PROCEDURE.
764 /* _UIB-CODE-BLOCK-END */
765 &ANALYZE-RESUME
767 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-row-available W-Win
768 PROCEDURE local-row-available :
769 /*------------------------------------------------------------------------------
770 Purpose: Override standard ADM method
771 Notes:
772 ------------------------------------------------------------------------------*/
774 /* Code placed here will execute PRIOR to standard behavior. */
775 RUN pre-row-available.
777 /* Dispatch standard ADM method. */
778 RUN dispatch IN THIS-PROCEDURE ( INPUT 'row-available':U ) .
780 /* Code placed here will execute AFTER standard behavior. */
781 fil_entity =
782 IF source-table = 'Creditor' THEN Creditor.CreditorCode ELSE
783 IF source-table = 'Tenant' THEN Tenant.TenantCode ELSE 0.
785 DISPLAY fil_entity WITH FRAME {&FRAME-NAME}.
786 RUN entity-changed.
788 RUN refresh-window-title IN sys-mgr ( THIS-PROCEDURE ).
790 END PROCEDURE.
792 /* _UIB-CODE-BLOCK-END */
793 &ANALYZE-RESUME
795 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE open-trn-query W-Win
796 PROCEDURE open-trn-query :
797 /*------------------------------------------------------------------------------
798 Purpose: Open the transaction query
799 Parameters: <none>
800 Notes:
801 ------------------------------------------------------------------------------*/
802 DEF VAR key-name AS CHAR NO-UNDO.
803 DEF VAR key-value AS CHAR NO-UNDO.
804 DEF VAR et AS CHAR NO-UNDO.
805 DEF VAR ec AS INT NO-UNDO.
806 DEF VAR ac AS DEC NO-UNDO.
808 RUN get-attribute( 'Key-Name':U ).
809 key-name = RETURN-VALUE.
810 RUN get-attribute( 'Key-Value':U ).
811 key-value = RETURN-VALUE.
813 IF key-name = "CreditorCode" THEN ASSIGN et = "C" ec = INT(key-value) .
814 ELSE IF key-name = "TenantCode" THEN ASSIGN et = "T" ec = INT(key-value) .
815 ELSE IF AVAILABLE(Creditor) THEN ASSIGN et = "C" ec = Creditor.CreditorCode .
816 ELSE IF AVAILABLE(Tenant) THEN ASSIGN et = "T" ec = Tenant.TenantCode .
817 ELSE RETURN "FAIL".
819 IF et = "C" THEN ac = sundry-creditors.
820 ELSE ac = sundry-debtors.
823 &SCOP TRN-BY-CLAUSE
825 /* Clear the existing work table */
826 FOR EACH OpenTrans: DELETE OpenTrans. END.
828 /* create entries in the work table for each partly closed group */
829 FOR EACH ClosingGroup NO-LOCK WHERE ClosingGroup.EntityType = et
830 AND ClosingGroup.EntityCode = ec
831 AND (ClosingGroup.AccountCode = ac OR (multi-ledger-creditors AND et = 'C'))
832 AND ClosingGroup.ClosedStatus = "P",
833 LAST AcctTran NO-LOCK OF ClosingGroup
834 BY ClosingGroup.EntityType BY ClosingGroup.EntityCode BY ClosingGroup.AccountCode
835 BY ClosingGroup.ClosedStatus BY ClosingGroup.Date DESCENDING:
836 CREATE OpenTrans.
837 ASSIGN OpenTrans.rowid = ROWID(ClosingGroup)
838 OpenTrans.state = "P"
839 OpenTrans.Date = ClosingGroup.Date
840 OpenTrans.Reference = "CG " + STRING( ClosingGroup.ClosingGroup)
841 OpenTrans.Description = (IF ClosingGroup.Description <> "" THEN ClosingGroup.Description ELSE AcctTran.Description)
842 OpenTrans.Amount = 0 .
844 IF OpenTrans.Description = "" THEN DO:
845 FIND Document NO-LOCK OF AcctTran.
846 IF OpenTrans.Description = "" THEN OpenTrans.Description = Document.Description.
847 /* IF OpenTrans.Reference = "" THEN OpenTrans.Reference = Document.Reference.*/
848 END.
850 DEF BUFFER AltTran FOR AcctTran.
851 FOR EACH AltTran NO-LOCK OF ClosingGroup:
852 OpenTrans.Amount = OpenTrans.Amount + AltTran.Amount.
853 END.
854 END.
856 /* create entries in the work table for each open transaction */
857 FOR EACH AcctTran NO-LOCK WHERE AcctTran.EntityType = et AND AcctTran.EntityCode = ec
858 AND (AcctTran.AccountCode = ac OR (multi-ledger-creditors AND et = 'C'))
859 AND AcctTran.ClosingGroup = ?
860 BY AcctTran.EntityType BY AcctTran.EntityCode BY AcctTran.AccountCode
861 BY AcctTran.MonthCode DESCENDING BY AcctTran.Date DESCENDING
862 BY AcctTran.BatchCode DESCENDING BY AcctTran.DocumentCode DESCENDING BY AcctTran.TransactionCode DESCENDING:
864 CREATE OpenTrans.
865 ASSIGN OpenTrans.rowid = ROWID(AcctTran)
866 OpenTrans.state = "O"
867 OpenTrans.Date = AcctTran.Date
868 OpenTrans.Reference = AcctTran.Reference
869 OpenTrans.Description = AcctTran.Description
870 OpenTrans.Amount = AcctTran.Amount .
872 IF OpenTrans.Description = "" OR OpenTrans.Reference = "" THEN DO:
873 FIND Document NO-LOCK OF AcctTran.
874 IF OpenTrans.Description = "" THEN OpenTrans.Description = Document.Description.
875 IF OpenTrans.Reference = "" THEN OpenTrans.Reference = Document.Reference.
876 END.
877 END.
879 OPEN QUERY br-trn FOR EACH OpenTrans BY OpenTrans.Date DESCENDING.
881 END PROCEDURE.
883 /* _UIB-CODE-BLOCK-END */
884 &ANALYZE-RESUME
886 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-row-available W-Win
887 PROCEDURE pre-row-available :
888 /*------------------------------------------------------------------------------
889 Purpose:
890 Parameters: <none>
891 Notes:
892 ------------------------------------------------------------------------------*/
893 DEF VAR source-link-name AS CHAR NO-UNDO.
895 RUN get-link-handle IN adm-broker-hdl ( INPUT THIS-PROCEDURE, 'RECORD-SOURCE':U,
896 OUTPUT source-link-name ).
897 RUN get-attribute IN WIDGET-HANDLE(source-link-name) ('INTERNAL-TABLES':U ).
898 source-table = RETURN-VALUE.
900 source-table =
901 IF LOOKUP( "Tenant", source-table, " " ) <> 0 THEN "Tenant" ELSE
902 IF LOOKUP( "Creditor", source-table, " " ) <> 0 THEN "Creditor" ELSE "".
904 DO WITH FRAME {&FRAME-NAME}:
905 fil_EntityType = source-table.
906 DISPLAY fil_EntityType.
907 END.
909 END PROCEDURE.
911 /* _UIB-CODE-BLOCK-END */
912 &ANALYZE-RESUME
914 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE re-open-group W-Win
915 PROCEDURE re-open-group :
916 /*------------------------------------------------------------------------------
917 Purpose:
918 ------------------------------------------------------------------------------*/
919 DO WITH FRAME {&FRAME-NAME}:
920 IF NOT AVAILABLE(OpenTrans) OR OpenTrans.state <> "P" THEN RETURN.
922 FIND ClosingGroup EXCLUSIVE-LOCK WHERE ROWID(ClosingGroup) = OpenTrans.rowid.
923 FOR EACH AcctTran EXCLUSIVE-LOCK OF ClosingGroup:
924 ASSIGN AcctTran.ClosingGroup = ?
925 AcctTran.ClosedState = "O".
926 END.
927 DELETE ClosingGroup.
928 RUN open-trn-query.
929 RUN selection-changed.
930 END.
931 END PROCEDURE.
933 /* _UIB-CODE-BLOCK-END */
934 &ANALYZE-RESUME
936 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE select-all W-Win
937 PROCEDURE select-all :
938 /*------------------------------------------------------------------------------
939 Purpose:
940 ------------------------------------------------------------------------------*/
941 DEF VAR i AS INT NO-UNDO INITIAL 1.
942 DEF VAR test-1 AS LOGI NO-UNDO.
943 DEF VAR test-2 AS LOGI NO-UNDO.
945 IF NUM-RESULTS("br-trn") = 0 OR
946 NUM-RESULTS("br-trn") = ? THEN RETURN.
948 GET FIRST br-trn.
949 REPOSITION br-trn TO ROWID ROWID( OpenTrans ).
951 DO WHILE AVAILABLE OpenTrans:
952 ASSIGN test-1 = BROWSE {&BROWSE-NAME}:IS-ROW-SELECTED(i) NO-ERROR.
953 IF NOT test-1 THEN DO:
954 ASSIGN test-2 = {&BROWSE-NAME}:SELECT-ROW(i) IN FRAME {&FRAME-NAME} NO-ERROR.
955 IF NOT test-2 THEN DO:
956 REPOSITION br-trn TO ROWID ROWID( OpenTrans ).
957 i = 1.
958 ASSIGN test-1 = BROWSE {&BROWSE-NAME}:IS-ROW-SELECTED(i) NO-ERROR.
959 ASSIGN test-2 = {&BROWSE-NAME}:SELECT-ROW(i) IN FRAME {&FRAME-NAME} NO-ERROR.
960 END.
961 br-trn:SELECT-FOCUSED-ROW() IN FRAME {&FRAME-NAME}.
962 END.
963 GET NEXT br-trn.
964 i = i + 1.
965 END.
967 GET FIRST br-trn.
968 REPOSITION br-trn TO ROWID ROWID( OpenTrans ).
970 RUN selection-changed.
972 END PROCEDURE.
974 /* _UIB-CODE-BLOCK-END */
975 &ANALYZE-RESUME
977 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE select-none W-Win
978 PROCEDURE select-none :
979 /*------------------------------------------------------------------------------
980 Purpose:
981 Parameters: <none>
982 Notes:
983 ------------------------------------------------------------------------------*/
985 IF br-trn:DESELECT-ROWS() IN FRAME {&FRAME-NAME} THEN.
987 RUN selection-changed.
989 END PROCEDURE.
991 /* _UIB-CODE-BLOCK-END */
992 &ANALYZE-RESUME
994 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE selection-changed W-Win
995 PROCEDURE selection-changed :
996 /*------------------------------------------------------------------------------
997 Purpose:
998 Parameters: <none>
999 Notes:
1000 ------------------------------------------------------------------------------*/
1001 DEF VAR i AS INT NO-UNDO.
1003 DO WITH FRAME {&FRAME-NAME}:
1004 fil_Total = 0.
1006 DO i = 1 TO br-trn:NUM-SELECTED-ROWS:
1007 IF br-trn:FETCH-SELECTED-ROW(i) THEN fil_Total = fil_Total + OpenTrans.Amount.
1008 END.
1010 DISPLAY fil_Total.
1012 btn_close:SENSITIVE = br-trn:NUM-SELECTED-ROWS > 0 AND fil_Total = 0.
1013 fil_PartCloseAs:SENSITIVE = NOT(btn_close:SENSITIVE).
1014 btn_close-part:SENSITIVE = NOT(btn_close:SENSITIVE) AND TRIM(INPUT fil_PartCloseAs) <> "".
1015 btn_all:SENSITIVE = br-trn:NUM-SELECTED-ROWS <> NUM-RESULTS( "br-trn" ).
1016 btn_none:SENSITIVE = br-trn:NUM-SELECTED-ROWS > 0.
1017 END.
1019 END PROCEDURE.
1021 /* _UIB-CODE-BLOCK-END */
1022 &ANALYZE-RESUME
1024 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records W-Win _ADM-SEND-RECORDS
1025 PROCEDURE send-records :
1026 /*------------------------------------------------------------------------------
1027 Purpose: Send record ROWID's for all tables used by
1028 this file.
1029 Parameters: see template/snd-head.i
1030 ------------------------------------------------------------------------------*/
1032 /* Define variables needed by this internal procedure. */
1033 {src/adm/template/snd-head.i}
1035 /* For each requested table, put it's ROWID in the output list. */
1036 {src/adm/template/snd-list.i "Tenant"}
1037 {src/adm/template/snd-list.i "Creditor"}
1038 {src/adm/template/snd-list.i "OpenTrans"}
1040 /* Deal with any unexpected table requests before closing. */
1041 {src/adm/template/snd-end.i}
1043 END PROCEDURE.
1045 /* _UIB-CODE-BLOCK-END */
1046 &ANALYZE-RESUME
1048 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed W-Win
1049 PROCEDURE state-changed :
1050 /* -----------------------------------------------------------
1051 Purpose:
1052 Parameters: <none>
1053 Notes:
1054 -------------------------------------------------------------*/
1055 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
1056 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
1057 END PROCEDURE.
1059 /* _UIB-CODE-BLOCK-END */
1060 &ANALYZE-RESUME
1062 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE user-layout W-Win
1063 PROCEDURE user-layout :
1064 /*------------------------------------------------------------------------------
1065 Purpose:
1066 Parameters: <none>
1067 Notes:
1068 ------------------------------------------------------------------------------*/
1070 END PROCEDURE.
1072 /* _UIB-CODE-BLOCK-END */
1073 &ANALYZE-RESUME