1 PACKAGE EAM_METERS_UTIL AUTHID CURRENT_USER AS
2 /* $Header: EAMETERS.pls 120.1 2005/06/20 05:43:21 appldev ship $ */
3
4 /**
5 * This procedure updates LTD readings for disabled change meter readings
6 */
7 procedure update_change_meter_ltd(p_meter_id in number,
8 p_meter_reading_id in number);
9
10 /**
11 * This function is used to calcuate the meter usage rate. The algorithm it
12 * uses put equal weight on each individual meter reading.
13 */
14 function get_meter_usage_rate(p_meter_id in number,
15 p_user_defined_rate in number,
16 p_use_past_reading in number)
17 return number;
18 /**
19 This function provides another signature for get_usage_rate function.
20 */
21 function get_meter_usage_rate(p_meter_id in number
22 )
23 return number;
24
25 /**
26 * This function is used to tell whether there is any mandatory meter reading
27 * or not for completing the given work order.
28 */
29 function has_mandatory_meter_reading(p_wip_entity_id in number)
30 return boolean;
31
32
33 /**
34 * This function is used to determine whether the meter reading is mandatory
35 * for the given wo or not. It should be called in the meter reading form when
36 * referenced by the completion page.
37 */
38 function is_meter_reading_mandatory(p_wip_entity_id in number,
39 p_meter_id in number)
40 return boolean;
41
42 /**
43 * This function is used to determine whether the meter reading is mandatory
44 * for the given wo or not. It should be called in the meter reading form when
45 * referenced by the completion page.
46 */
47 function is_meter_reading_mandatory_v(p_wip_entity_id in number,
48 p_meter_id in number)
49 return varchar2;
50
51 /**
52 * This procedure determines if the Last Service Reading of the meter for
53 * the asset activity association is mandatory by checking if the meter
54 * is used in any of the PM defined for the association. If it is required,
55 * then the function returns true, otherwise false.
56 */
57 function is_meter_reading_required(p_activity_assoc_id in number,
58 p_meter_id in number)
59 return boolean;
60 /**
61 * This procedure determines if the Last Service Reading of the meter for
62 * the asset activity association is mandatory by checking if the meter
63 * is used in any of the PM defined for the association. If it is required,
64 * then the function returns 'Y', otherwise 'N'.
65 */
66 function is_meter_reading_required_v(p_activity_assoc_id in number,
67 p_meter_id in number)
68 return varchar2;
69
70 /**
71 * This procedure updates the last service reading of the meter for the
72 * asset activity association. It also recursively updates the meter readings
73 * of the child activity association in the suppression hierarchy.
74 */
75 procedure update_last_service_reading(p_wip_entity_id in number,
76 p_activity_assoc_id in number,
77 p_meter_id in number,
78 p_meter_reading in number);
79
80 /**
81 * This procedure updates the last service reading of the meter for the
82 * asset activity association. It also recursively updates the meter readings
83 * of the child activity association in the suppression hierarchy.
84 */
85 procedure update_last_service_reading_wo(p_wip_entity_id in number,
86 p_meter_id in number,
87 p_meter_reading in number,
88 p_wo_end_date in date,
89 x_return_status OUT NOCOPY VARCHAR2,
90 x_msg_count OUT NOCOPY NUMBER,
91 x_msg_data OUT NOCOPY VARCHAR2);
92
93 /**
94 * This procedure is a wrapper over update_last_service_dates
95 * This is getting called from
96 * EAMPLNWB.fmb -> MASS_COMPLETE block -> Work_Order_Completion
97 * procedure. Do not call this from other locations
98 */
99 procedure updt_last_srvc_dates_wo_wpr (p_wip_entity_id in number,
100 p_start_date in date,
101 p_end_date in date,
102 x_return_status OUT NOCOPY VARCHAR2,
103 x_msg_count OUT NOCOPY NUMBER,
104 x_msg_data OUT NOCOPY VARCHAR2) ;
105
106 /**
107 * This procedure updates the last service start/end date for the
108 * asset activity association. It also recursively updates dates
109 * of the child activity association in the suppression hierarchy.
110 */
111 procedure update_last_service_dates( p_wip_entity_id in number,
112 p_activity_assoc_id in number,
113 p_start_date in date,
114 p_end_date in date);
115
116 /**
117 * This procedure updates the last service start/end date for the
118 * asset activity association. It also recursively updates dates
119 * of the child activity association in the suppression hierarchy.
120 */
121 procedure update_last_service_dates_wo(p_wip_entity_id in number,
122 p_start_date in date,
123 p_end_date in date,
124 x_return_status OUT NOCOPY VARCHAR2,
125 x_msg_count OUT NOCOPY NUMBER,
126 x_msg_data OUT NOCOPY VARCHAR2);
127
128
129 /**
130 * This procedure should be called when resetting a meter. It updates the corresponding
131 * PM schedule rule data if applicable.
132 */
133 procedure reset_meter(p_meter_id in number,
134 p_current_reading in number,
135 p_last_reading in number,
136 p_change_val in number);
137
138 /**
139 * This procedure calculates the average of the meter readings for the meter
140 */
141 procedure get_average(p_meter_id in number,
142 p_from_date in date,
143 p_to_date in date,
144 x_average OUT NOCOPY number );
145
146
147 /**
148 * This function checks if the user can enter a reading for the specified date.
149 * It checks if the reading date falls in between a normal reading and a reset reading
150 */
151 function cannot_enter_value(p_meter_id in number,
152 p_reading_date in date
153 )return boolean;
154
155 /**
156 * This function checks if the user is trying to update a reset reading
157 */
158 function cannot_update_reset(p_meter_id in number,
159 p_reading_date in date
160 )return boolean;
161
162 /**
163 * This function checks if a particular reading is a reset reading
164 */
165 function reset_reading_exists(p_meter_id in number,
166 p_reading_date in date
167 )return boolean;
168
169 /* this function checks if a particular reading is a normal (non-reset)
170 reading that is right prior to a reset reading */
171 /*
172 function normal_reading_before_reset ( p_meter_reading_id in number)
173 return boolean;
174 */
175
176 /* following function checks if there exists and readings after the
177 specific reading date */
178 function next_reading_exists (p_meter_id in number,
179 p_reading_date in date)
180 return boolean;
181
182 /* following function determines whether a non-disabled reading
183 exists on p_reading_date for meter p_meter_id
184 */
185 function reading_exists(p_meter_id in number,
186 p_reading_date in date)
187 return boolean;
188
189 /* This function determines whether a new meter reading would
190 violate the ascending or descending order of the meter.
191 If there is violation, "true" is returned; otherwise, "false" is
192 returned. */
193
194 function violate_order(p_meter_id in number,
195 p_reading_date in date,
196 p_current_reading in number)
197 return boolean;
198
199 /* This function calculates the life_to_date reading for a new reading. */
200 function calculate_ltd(p_meter_id in number,
201 p_reading_date in date,
202 p_new_reading in number,
203 p_meter_type in number)
204 return number;
205
206
207 /* This function verifies that the meter reading meets the follow criteria:
208 1. meter reading is not a reading between a normal reading and a reset reading
209 2. meter reading is not a reset reading with normal readings after it.
210 */
211 function can_be_disabled(p_meter_id number,
212 p_meter_reading_id number,
213 x_reason_cannot_disable out nocopy number)
214 return boolean;
215
216
217 /**
218 * This is a private function to resursively iterate through the suppression tree
219 * to see whether any one of them needs meter reading.
220 */
221 function pm_need_meter_reading(p_parent_pm_id in number)
222 return boolean;
223
224 /**
225 * This is a private helper function that retrieves the activity association id
226 * given the wip entity id.
227 */
228 function get_activity_assoc_id(p_wip_entity_id number)
229 return number;
230
231 /**
232 * This is a private function. It resursively iterate through the suppression tree
233 * to see whether the meter is used in the sub tree of the given node.
234 */
235 function mr_mandatory_for_pm(p_activity_assoc_id in number,
236 p_meter_id in number) return boolean;
237
238 PROCEDURE VALIDATE_USED_IN_SCHEDULING(p_meter_id IN NUMBER,
239 x_return_status OUT NOCOPY VARCHAR2,
240 x_msg_count OUT NOCOPY NUMBER,
241 x_msg_data OUT NOCOPY VARCHAR2);
242
243
244
245 END eam_meters_util;
246
247