Really, this should be it, for the passing income.
[capital-apms-progress.git] / trigger / wrrntrvw.p
blobfa92a75ac452beebc48fc98d52f41feabee6c739
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File : trigger/wrrntrvw.p
6 Purpose : Update tasks to reflect reviews completed and reviews due
8 Description :
10 Author(s) : Andrew McMillan
11 Created : 20/1/1999
12 ------------------------------------------------------------------------*/
13 TRIGGER PROCEDURE FOR WRITE OF RentReview OLD OldReview.
15 /* could call workflow/update-task.p if dates have changed */
17 /* _UIB-CODE-BLOCK-END */
18 &ANALYZE-RESUME
21 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
23 /* ******************** Preprocessor Definitions ******************** */
25 &Scoped-define PROCEDURE-TYPE Procedure
29 /* _UIB-PREPROCESSOR-BLOCK-END */
30 &ANALYZE-RESUME
34 /* *********************** Procedure Settings ************************ */
36 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
37 /* Settings for THIS-PROCEDURE
38 Type: Procedure
39 Allow:
40 Frames: 0
41 Add Fields to: Neither
42 Other Settings: CODE-ONLY COMPILE
44 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
46 /* ************************* Create Window ************************** */
48 &ANALYZE-SUSPEND _CREATE-WINDOW
49 /* DESIGN Window definition (used by the UIB)
50 CREATE WINDOW Procedure ASSIGN
51 HEIGHT = .25
52 WIDTH = 42.14.
53 /* END WINDOW DEFINITION */
55 &ANALYZE-RESUME
60 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
63 /* *************************** Main Block *************************** */
65 FIND TenancyLease OF RentReview NO-LOCK NO-ERROR.
66 IF AVAILABLE(TenancyLease) THEN DO:
67 IF NEW RentReview THEN
68 RUN schedule-review.
69 ELSE DO:
70 IF RentReview.ReviewStatus <> OldReview.ReviewStatus THEN RUN review-status-change.
71 IF RentReview.DateDue <> OldReview.DateDue THEN RUN review-date-change.
72 END.
73 END.
74 IF NOT AVAILABLE(RentReview) THEN DO:
75 MESSAGE "Deleting rent review".
76 END.
78 /* _UIB-CODE-BLOCK-END */
79 &ANALYZE-RESUME
82 /* ********************** Internal Procedures *********************** */
84 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE review-date-change Procedure
85 PROCEDURE review-date-change :
86 /*------------------------------------------------------------------------------
87 Purpose:
88 ------------------------------------------------------------------------------*/
89 DEF VAR date-due AS DATE NO-UNDO.
90 DEF VAR task-no AS INT NO-UNDO.
91 DEF VAR results AS CHAR NO-UNDO.
93 FIND FlowTask WHERE FlowTask.DueDate = OldReview.DateDue
94 AND FlowTask.EntityType = "T"
95 AND FlowTask.EntityCode = TenancyLease.TenantCode
96 AND FlowTask.FlowTaskType = "RR" NO-LOCK NO-ERROR.
97 IF AVAILABLE(FlowTask) THEN DO:
98 date-due = FlowTask.DueDate.
99 task-no = FlowTask.FlowTaskNo.
100 IF RentReview.DateDue = ? THEN DO:
101 FIND CURRENT FlowTask EXCLUSIVE-LOCK NO-ERROR.
102 DELETE FlowTask NO-ERROR.
103 FIND CURRENT FlowTask NO-LOCK NO-ERROR.
104 END.
105 ELSE DO:
106 RUN workflow/update-task.p( INPUT-OUTPUT date-due, INPUT-OUTPUT task-no, "MoveTask",
107 STRING(RentReview.DateDue),
108 OUTPUT results ).
109 END.
110 END.
111 ELSE DO:
112 date-due = RentReview.DateDue.
113 RUN workflow/update-task.p( INPUT-OUTPUT date-due, INPUT-OUTPUT task-no, "NewTask",
114 "T," + STRING(TenancyLease.TenantCode) + ",RR",
115 OUTPUT results ).
116 END.
118 END PROCEDURE.
120 /* _UIB-CODE-BLOCK-END */
121 &ANALYZE-RESUME
124 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE review-status-change Procedure
125 PROCEDURE review-status-change :
126 /*------------------------------------------------------------------------------
127 Purpose:
128 ------------------------------------------------------------------------------*/
129 DEF VAR date-due AS DATE NO-UNDO.
130 DEF VAR task-no AS INT NO-UNDO.
131 DEF VAR results AS CHAR NO-UNDO.
133 FIND FlowTask WHERE FlowTask.DueDate = OldReview.DateDue
134 AND FlowTask.EntityType = "T"
135 AND FlowTask.EntityCode = TenancyLease.TenantCode
136 AND FlowTask.FlowTaskType = "RR" NO-LOCK NO-ERROR.
137 IF AVAILABLE(FlowTask) THEN DO:
138 date-due = FlowTask.DueDate.
139 task-no = FlowTask.FlowTaskNo.
140 RUN workflow/update-task.p( INPUT-OUTPUT date-due, INPUT-OUTPUT task-no, "TaskDone",
141 RentReview.ReviewStatus,
142 OUTPUT results ).
143 END.
144 ELSE DO:
145 /* if the date has changed then it will get fixed in the next screen */
146 date-due = OldReview.DateDue.
147 RUN workflow/update-task.p( INPUT-OUTPUT date-due, INPUT-OUTPUT task-no, "NewTask",
148 "T," + STRING(TenancyLease.TenantCode) + ",RR",
149 OUTPUT results ).
151 /* might not have been created with the right status on it */
152 RUN workflow/update-task.p( INPUT-OUTPUT date-due, INPUT-OUTPUT task-no, "TaskDone",
153 RentReview.ReviewStatus,
154 OUTPUT results ).
155 END.
157 END PROCEDURE.
159 /* _UIB-CODE-BLOCK-END */
160 &ANALYZE-RESUME
163 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE schedule-review Procedure
164 PROCEDURE schedule-review :
165 /*------------------------------------------------------------------------------
166 Purpose:
167 ------------------------------------------------------------------------------*/
168 IF RentReview.DateDue = ? THEN RETURN.
170 DEF VAR date-due AS DATE NO-UNDO.
171 DEF VAR task-no AS INT NO-UNDO.
172 DEF VAR results AS CHAR NO-UNDO.
174 date-due = RentReview.DateDue.
175 RUN workflow/update-task.p( INPUT-OUTPUT date-due, INPUT-OUTPUT task-no, "NewTask",
176 "T," + STRING(TenancyLease.TenantCode) + ",RR",
177 OUTPUT results ).
179 END PROCEDURE.
181 /* _UIB-CODE-BLOCK-END */
182 &ANALYZE-RESUME