1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI ADM1
6 &Scoped-define WINDOW-NAME W-Win
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS W-Win
8 /*------------------------------------------------------------------------
9 ------------------------------------------------------------------------*/
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
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.
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
*/
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
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 ~
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 ~
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
*/
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
107 DEFINE BUTTON btn_cancel
112 DEFINE BUTTON btn_close
117 DEFINE BUTTON btn_close-part
118 LABEL "&Partial Close"
122 DEFINE BUTTON btn_none
123 LABEL "&Select &None"
127 DEFINE BUTTON btn_ReOpen
128 LABEL "&Re-Open Group"
132 DEFINE VARIABLE fil_Entity
AS INTEGER FORMAT "999999":U
INITIAL ?
137 DEFINE VARIABLE fil_entityname
AS CHARACTER FORMAT "X(256)":U
140 FGCOLOR 12 FONT 10 NO-UNDO.
142 DEFINE VARIABLE fil_EntityType
AS CHARACTER FORMAT "X(256)":U
147 DEFINE VARIABLE fil_PartCloseAs
AS CHARACTER FORMAT "X(256)":U
152 DEFINE VARIABLE fil_total
AS DECIMAL FORMAT "ZZZ,ZZZ,ZZ9.99CR":U
INITIAL 0
155 SIZE 18.29 BY 1 NO-UNDO.
157 DEFINE RECTANGLE RECT-4
158 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
161 /* Query definitions
*/
163 DEFINE QUERY br-trn
FOR
167 /* Browse definitions
*/
169 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br-trn W-Win _FREEFORM
170 QUERY br-trn
NO-LOCK DISPLAY
174 OpenTrans.Description
176 /* _UIB-CODE-BLOCK-END
*/
178 WITH NO-ROW-MARKERS MULTIPLE SIZE 96 BY 16.6 ROW-HEIGHT-CHARS .5.
181 /* ************************ Frame Definitions
*********************** */
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
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
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
222 TITLE = "Manual Transaction Closing"
227 VIRTUAL-HEIGHT = 50.3
228 VIRTUAL-WIDTH = 182.86
237 ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
238 /* END WINDOW DEFINITION
*/
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
*/
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
260 /* BROWSE-TAB br-trn fil_entityname F-Main
*/
262 FRAME F-Main
:SCROLLABLE = FALSE.
264 /* SETTINGS
FOR FILL-IN fil_entityname
IN FRAME F-Main
266 /* SETTINGS
FOR FILL-IN fil_EntityType
IN FRAME F-Main
268 /* SETTINGS
FOR FILL-IN fil_total
IN FRAME F-Main
270 IF SESSION:DISPLAY-TYPE = "GUI":U
AND VALID-HANDLE(W-Win
)
271 THEN W-Win
:HIDDEN = yes.
273 /* _RUN-TIME-ATTRIBUTES-END
*/
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
282 OPEN QUERY BROWSE-2
FOR EACH OpenTrans.
286 */ /* BROWSE br-trn
*/
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.
305 /* _UIB-CODE-BLOCK-END
*/
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.
318 /* _UIB-CODE-BLOCK-END
*/
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 ?.
332 /* _UIB-CODE-BLOCK-END
*/
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.
342 /* _UIB-CODE-BLOCK-END
*/
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
*/
353 /* _UIB-CODE-BLOCK-END
*/
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
).
364 /* _UIB-CODE-BLOCK-END
*/
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.
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"
383 MESSAGE "Transactions successfully closed" VIEW-AS ALERT-BOX INFORMATION.
385 RUN selection-changed.
389 APPLY '
ENTRY'
:U
TO fil_Entity .
393 /* _UIB-CODE-BLOCK-END
*/
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.
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"
412 MESSAGE "Transactions successfully closed" VIEW-AS ALERT-BOX INFORMATION.
414 RUN selection-changed.
418 APPLY '
ENTRY'
:U
TO fil_Entity .
422 /* _UIB-CODE-BLOCK-END
*/
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
*/
433 /* _UIB-CODE-BLOCK-END
*/
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
*/
444 /* _UIB-CODE-BLOCK-END
*/
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
454 IF RETURN-VALUE = "FAIL" THEN RETURN NO-APPLY.
457 /* _UIB-CODE-BLOCK-END
*/
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}.
468 DISABLE btn_close-part
WITH FRAME {&FRAME-NAME}.
471 /* _UIB-CODE-BLOCK-END
*/
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.
481 /* _UIB-CODE-BLOCK-END
*/
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
*/
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.
507 ------------------------------------------------------------------------------*/
511 /* _UIB-CODE-BLOCK-END
*/
514 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available W-Win
515 PROCEDURE adm-row-available
:
516 /*------------------------------------------------------------------------------
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
}
542 /* _UIB-CODE-BLOCK-END
*/
545 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE close-transactions W-Win
546 PROCEDURE close-transactions
:
547 /*------------------------------------------------------------------------------
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).
570 DO TRANSACTION ON ERROR UNDO close-transactions
, RETURN "FAIL":
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
).
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 "").
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
600 closing-group
= IF AVAILABLE(ClosingGroup
) AND ClosingGroup.ClosingGroup
<> ?
THEN
601 ClosingGroup.ClosingGroup
+ 1 ELSE 1.
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 "").
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.
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.
646 /* _UIB-CODE-BLOCK-END
*/
649 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE close-trn-query W-Win
650 PROCEDURE close-trn-query
:
651 /*------------------------------------------------------------------------------
655 ------------------------------------------------------------------------------*/
661 /* _UIB-CODE-BLOCK-END
*/
664 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI W-Win _DEFAULT-DISABLE
665 PROCEDURE disable_UI
:
666 /*------------------------------------------------------------------------------
667 Purpose
: DISABLE the User Interface
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.
680 /* _UIB-CODE-BLOCK-END
*/
683 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI W-Win _DEFAULT-ENABLE
684 PROCEDURE enable_UI
:
685 /*------------------------------------------------------------------------------
686 Purpose
: ENABLE the User Interface
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}
703 /* _UIB-CODE-BLOCK-END
*/
706 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE entity-changed W-Win
707 PROCEDURE entity-changed
:
708 /*------------------------------------------------------------------------------
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.
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.
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}.
740 ASSIGN fil_entityname
= entity-name.
741 DISPLAY fil_entityname
WITH FRAME {&FRAME-NAME}.
744 RUN selection-changed.
748 /* _UIB-CODE-BLOCK-END
*/
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".
756 Notes
: If activated
, should
APPLY CLOSE, *not
* dispatch adm-exit.
757 -------------------------------------------------------------*/
758 APPLY "CLOSE":U
TO THIS-PROCEDURE.
764 /* _UIB-CODE-BLOCK-END
*/
767 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-row-available W-Win
768 PROCEDURE local-row-available
:
769 /*------------------------------------------------------------------------------
770 Purpose
: Override standard ADM method
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.
*/
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}.
788 RUN refresh-window-title
IN sys-mgr
( THIS-PROCEDURE ).
792 /* _UIB-CODE-BLOCK-END
*/
795 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE open-trn-query W-Win
796 PROCEDURE open-trn-query
:
797 /*------------------------------------------------------------------------------
798 Purpose
: Open the transaction query
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 .
819 IF et
= "C" THEN ac
= sundry-creditors.
820 ELSE ac
= sundry-debtors.
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:
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.
*/
850 DEF BUFFER AltTran
FOR AcctTran.
851 FOR EACH AltTran
NO-LOCK OF ClosingGroup
:
852 OpenTrans.Amount
= OpenTrans.Amount
+ AltTran.Amount.
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:
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.
879 OPEN QUERY br-trn
FOR EACH OpenTrans
BY OpenTrans.Date
DESCENDING.
883 /* _UIB-CODE-BLOCK-END
*/
886 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-row-available W-Win
887 PROCEDURE pre-row-available
:
888 /*------------------------------------------------------------------------------
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.
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.
911 /* _UIB-CODE-BLOCK-END
*/
914 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE re-open-group W-Win
915 PROCEDURE re-open-group
:
916 /*------------------------------------------------------------------------------
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".
929 RUN selection-changed.
933 /* _UIB-CODE-BLOCK-END
*/
936 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE select-all W-Win
937 PROCEDURE select-all
:
938 /*------------------------------------------------------------------------------
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.
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
).
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.
961 br-trn
:SELECT-FOCUSED-ROW() IN FRAME {&FRAME-NAME}.
968 REPOSITION br-trn
TO ROWID ROWID( OpenTrans
).
970 RUN selection-changed.
974 /* _UIB-CODE-BLOCK-END
*/
977 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE select-none W-Win
978 PROCEDURE select-none
:
979 /*------------------------------------------------------------------------------
983 ------------------------------------------------------------------------------*/
985 IF br-trn
:DESELECT-ROWS() IN FRAME {&FRAME-NAME} THEN.
987 RUN selection-changed.
991 /* _UIB-CODE-BLOCK-END
*/
994 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE selection-changed W-Win
995 PROCEDURE selection-changed
:
996 /*------------------------------------------------------------------------------
1000 ------------------------------------------------------------------------------*/
1001 DEF VAR i
AS INT NO-UNDO.
1003 DO WITH FRAME {&FRAME-NAME}:
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.
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.
1021 /* _UIB-CODE-BLOCK-END
*/
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
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
}
1045 /* _UIB-CODE-BLOCK-END
*/
1048 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed W-Win
1049 PROCEDURE state-changed
:
1050 /* -----------------------------------------------------------
1054 -------------------------------------------------------------*/
1055 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
1056 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
1059 /* _UIB-CODE-BLOCK-END
*/
1062 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE user-layout W-Win
1063 PROCEDURE user-layout
:
1064 /*------------------------------------------------------------------------------
1068 ------------------------------------------------------------------------------*/
1072 /* _UIB-CODE-BLOCK-END
*/