Added capital works blank section. Synced calling screen.
[capital-apms-progress.git] / process / one-off / fix-it.p
blobb446ffa1fcbcef49056f4466ca3cae5dc40c94a2
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r11
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File :
6 Purpose :
8 Syntax :
10 Description :
12 Author(s) :
13 Created :
14 Notes :
15 ------------------------------------------------------------------------*/
16 /* This .W file was created with the Progress UIB. */
17 /*----------------------------------------------------------------------*/
19 /* *************************** Definitions ************************** */
21 /* _UIB-CODE-BLOCK-END */
22 &ANALYZE-RESUME
25 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
27 /* ******************** Preprocessor Definitions ******************** */
29 &Scoped-define PROCEDURE-TYPE Procedure
33 /* _UIB-PREPROCESSOR-BLOCK-END */
34 &ANALYZE-RESUME
38 /* *********************** Procedure Settings ************************ */
40 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
41 /* Settings for THIS-PROCEDURE
42 Type: Procedure
43 Allow:
44 Frames: 0
45 Add Fields to: Neither
46 Other Settings: CODE-ONLY COMPILE
48 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
50 /* ************************* Create Window ************************** */
52 &ANALYZE-SUSPEND _CREATE-WINDOW
53 /* DESIGN Window definition (used by the UIB)
54 CREATE WINDOW Procedure ASSIGN
55 HEIGHT = 2
56 WIDTH = 40.
58 &ANALYZE-RESUME
63 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
66 /* *************************** Main Block *************************** */
68 RUN fix-property-address.
69 RUN fix-lease-term.
70 RUN fix-rental-space-nulls.
72 /* _UIB-CODE-BLOCK-END */
73 &ANALYZE-RESUME
76 /* ********************** Internal Procedures *********************** */
78 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE calc-date-diff Procedure
79 PROCEDURE calc-date-diff :
80 /*------------------------------------------------------------------------------
81 Purpose:
82 ------------------------------------------------------------------------------*/
83 DEF INPUT PARAMETER start-date AS DATE NO-UNDO.
84 DEF INPUT PARAMETER end-date AS DATE NO-UNDO.
85 DEF OUTPUT PARAMETER yy AS INT NO-UNDO.
86 DEF OUTPUT PARAMETER mm AS INT NO-UNDO.
87 DEF OUTPUT PARAMETER dd AS INT NO-UNDO.
89 DEF VAR dpm AS INT NO-UNDO.
90 DEF VAR start-yy AS INT NO-UNDO.
91 DEF VAR start-mm AS INT NO-UNDO.
93 dd = DAY( end-date ). mm = MONTH( end-date ). yy = YEAR( end-date ).
94 RUN get-number-of-days( yy, mm, OUTPUT dpm).
96 dd = 1 + dd - DAY( start-date ).
97 start-mm = MONTH( start-date ).
98 start-yy = YEAR( start-date ).
99 mm = mm - start-mm.
100 yy = yy - start-yy.
101 IF dd = dpm THEN
102 ASSIGN dd = 0 mm = mm + 1 .
103 ELSE IF dd < 0 THEN DO:
104 RUN get-number-of-days( start-yy, start-mm, OUTPUT dpm).
105 ASSIGN dd = dd + dpm mm = mm - 1 .
106 END.
107 IF mm < 0 THEN ASSIGN mm = mm + 12 yy = yy - 1.
109 END PROCEDURE.
111 /* _UIB-CODE-BLOCK-END */
112 &ANALYZE-RESUME
115 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE fix-lease-term Procedure
116 PROCEDURE fix-lease-term :
117 /*------------------------------------------------------------------------------
118 Purpose:
119 Parameters: <none>
120 Notes:
121 ------------------------------------------------------------------------------*/
123 FOR EACH TenancyLease:
124 RUN calc-date-diff(
125 TenancyLease.LeaseStartDate, TenancyLease.LeaseEndDate,
126 OUTPUT TenancyLease.TermYears,
127 OUTPUT TenancyLease.TermMonths,
128 OUTPUT TenancyLease.TermDays ).
129 END.
131 END PROCEDURE.
133 /* _UIB-CODE-BLOCK-END */
134 &ANALYZE-RESUME
137 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE fix-property-address Procedure
138 PROCEDURE fix-property-address :
139 /*------------------------------------------------------------------------------
140 Purpose: Fix the CHR(253) in the property street address
141 ------------------------------------------------------------------------------*/
142 FOR EACH Property:
143 DO WHILE INDEX( Property.StreetAddress, CHR(218)) > 0:
144 SUBSTRING( Property.StreetAddress, INDEX( Property.StreetAddress, CHR(218))) = CHR(10).
145 END.
146 END.
147 END PROCEDURE.
149 /* _UIB-CODE-BLOCK-END */
150 &ANALYZE-RESUME
153 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE fix-rental-space-nulls Procedure
154 PROCEDURE fix-rental-space-nulls :
155 /*------------------------------------------------------------------------------
156 Purpose:
157 ------------------------------------------------------------------------------*/
158 FOR EACH RentalSpace:
159 IF RentalSpace.AreaSize = ? THEN RentalSpace.AreaSize = 0.
160 IF RentalSpace.ContractedRental = ? THEN RentalSpace.ContractedRental = 0.
161 IF RentalSpace.ChargedRental = ? THEN RentalSpace.ChargedRental = 0.
162 IF RentalSpace.MarketRental = ? THEN RentalSpace.ContractedRental = 0.
163 END.
164 END PROCEDURE.
166 /* _UIB-CODE-BLOCK-END */
167 &ANALYZE-RESUME
170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-number-of-days Procedure
171 PROCEDURE get-number-of-days :
172 /*------------------------------------------------------------------------------
173 Purpose:
174 ------------------------------------------------------------------------------*/
175 DEF INPUT PARAMETER yy AS INT NO-UNDO.
176 DEF INPUT PARAMETER mm AS INT NO-UNDO.
177 DEF OUTPUT PARAMETER days AS INT NO-UNDO.
179 CASE mm:
180 WHEN 1 THEN days = 31.
181 WHEN 2 THEN DO:
182 days = 28.
183 IF (yy MODULO 4) = 0 THEN days = days + 1.
184 END.
185 WHEN 3 THEN days = 31.
186 WHEN 4 THEN days = 30.
187 WHEN 5 THEN days = 31.
188 WHEN 6 THEN days = 30.
189 WHEN 7 THEN days = 31.
190 WHEN 8 THEN days = 31.
191 WHEN 9 THEN days = 30.
192 WHEN 10 THEN days = 31.
193 WHEN 11 THEN days = 30.
194 WHEN 12 THEN days = 31.
195 END.
197 END PROCEDURE.
199 /* _UIB-CODE-BLOCK-END */
200 &ANALYZE-RESUME