[Home] [Help]
PACKAGE BODY: APPS.BEN_DETERMINE_COVERAGE
Source
1 Package Body BEN_DETERMINE_COVERAGE as
2 /* $Header: bencvrge.pkb 120.31.12010000.2 2008/08/05 14:36:35 ubhat ship $ */
3 --------------------------------------------------------------------------------
4 /*
5 +==============================================================================+
6 | Copyright (c) 1997 Oracle Corporation |
7 | Redwood Shores, California, USA |
8 | All rights reserved. |
9 +==============================================================================+
10 Name:
11 Determine Coverage
12
13 Purpose:
14 Determines proper coverages based on mlt_cd. Writes to BEN_ENRT_BNFT table.
15
16 History:
17
18 Date Who Version What?
19 ---- --- ------- -----
20 7 May 98 Ty Hayden 110.0 Created.
21 16 Jun 98 Ty Hayden 110.1 Do not error when coverage
22 not found.
23 16 Jun 98 T Guy 110.2 Removed other exception.
24 22 Jun 98 Ty Hayden 110.3 Added Mn,Mx,Incr,and Val edits.
25 25 Jun 98 T Guy 110.4 Replaced all occurrences of
26 PER10 with PERTEN.
27 11 Aug 98 Ty Hayden 110.5 Added mlt cd NSVU
28 08 Oct 98 T Guy 115.3 Added schema changes for ben_enrt_bnft
29 Added message numbers and debugging
30 messages.
31 12 Oct 98 T Guy 115.4 Added mlt cd SAAEAR. Added dflt_val
32 logic.
33 22 Oct 98 T Guy 115.5 removed show errors statement
34 23 Oct 98 T Guy 115.6 added new column for write coverage
35 p_comp_lvl_fctr_id
36 p_cvg_mlt_cd
37 p_entr_val_at_enrt_flag
38 p_mx_val
39 p_mn_val
40 p_incrmt_val
41 p_rt_typ_cd
42 04 Nov 98 T Guy 115.7 fixed SAEER mlt_cd and local variable
43 assignment in calculate_val (val2).
44 Added g_record_error if person does
45 not have compensation. This will role
46 back all records associated with this
47 person.
48 05 Nov 98 T Guy 115.8 Added logic to treat %RNG% mlt cd as
49 FLFX when vr trtmnt cd is RPLC.
50 16 Nov 98 T Guy 115.9 Added lower/upper limit value and rule
51 checking. Removed post_write Procedure
52 as this logic has been added to the
53 write_coverage procedure.
54 24 Nov 98 T Guy 115.10 Fixed undefined upr/lwr rule checking
55 02 Dec 98 T Guy 115.11 Fixed set_token error for null
56 compensation
57 16 Dec 98 T Guy 115.12 No Change.
58 18 Dec 98 T Guy 115.13 Restructured looping for RNG cvg mlt cds
59 Fixes bug 1568.
60 18 Dec 98 T Guy 115.14 Removed ^m characters.
61 22 Dec 98 T Guy 115.15 Fixed bug 1563. when val is null added
62 check for entr_val_at_enrt_flag being off
63 18 Jan 99 G Perry 115.16 LED V ED
64 16 Feb 99 T Guy 115.17 Fixed bugs 1819, 1820
65 16 Feb 99 T Guy 115.18 Took out nocopy show errors statement
66 24 Feb 99 T Guy 115.19 Added level jumping and ctfn checking
67 26 Feb 99 T Guy 115.20 Fixed NSVU for bug 1820.
68 26 Feb 99 T Guy 115.21 Fixed error with ordr_num values
69 09 Mar 99 G Perry 115.23 IS to AS.
70 29 Mar 99 T Guy 115.24 Added default val to write_coverage
71 28 Apr 99 Shdas 115.25 Added contexts to rule
72 calls(genutils.formula).
73 29 Apr 99 lmcdonal 115.26 prtt_enrt_rslt now has status code.
74 07 may 99 Shdas 115.27 Added calls(genutils.formula) to
75 mn_cvg_rl,mx_cvg_rl.
76 14 May 99 G Perry 115.28 Added logic to check for PLIP
77 and then PL if PLIP not found.
78 17 May 99 T Guy 115.29 Fixed call to elctbl_chc_ctfn_api.
79 19 May 99 T Guy 115.30 Make version match header. removed
80 entr_val_at_enrt check for %RNG% codes
81 19 May 99 T Guy 115.31 Write DFLT_VAL only when entr_val_at_enrt
82 Fixed cursor to pick up dflt_flag from
83 chc instead of cvg_calc_mthd.
84 1 Jul 99 T Guy 115.32 Added rt_typ_cd of PERHNDRD
85 1 Jul 99 lmcdonal 115.33 Moved check_val (limit_checks) and
86 calcuate_val (rt_typ_calc)
87 to genutils.
88 9 Jul 99 mhoyes 115.34 Added trace messages.
89 16 Jul 99 lmcdonal 115.35 limit_checks parms changed.
90 20-JUL-99 Gperry 115.36 genutils -> benutils package
91 rename.
92 22-JUL-99 mhoyes 115.37 - Added new trace messages.
93 - Replaced all + 0s.
94 07-Sep-99 tguy 115.38 fixed calls to pay_mag_util
95 21-sep-99 tguy 115.39 added check for dflt_enrt_cd for
96 dflt_val assignemnt
97 04-OCT-99 mhoyes 115.40 - Modified code BENEFIT to BNFT.
98 - Tuned cursors. Replaced
99 c_cvg_plip, c_cvg_pln and
100 c_cvg_oipl with calls to
101 ben_cvg_cache.epeplncvg_getdets.
102 04-OCT-99 tguy 115.41 - added call to dt_fndate.
103 13-OCT-99 tguy 115.42 - moved increment value outside of
104 if statement. this fixed bug 3692
105 14-OCT-99 maagrawa 115.43 Modified level jumping logic.
106 Major change in chk_bnft_ctfn
107 procedure.
108 02-Nov-99 maagrawa 115.44 Made call to BEN_DETERMINE_CHC_CTFN
109 .write_ctfn to write level jumping
110 ctfns for the benefit records.
111 15-Nov-99 mhoyes 115.45 - Added trace messages.
112 19-Nov-99 pbodla 115.46 - p_elig_per_elctbl_chc_id parameter
113 passed to benutils.limit_checks
114 - p_elig_per_elctbl_chc_id parameter
115 added to chk_bnft_ctfn proc and all
116 it's calls.
117 - Passed p_elig_per_elctbl_chc_id to
118 all benutils.formula calls.
119 29-Nov-99 jcarpent 115.47 - Added call to det._dflt_enrt_cd
120 07-Dec-99 jcarpent 115.48 - Assign defaults for flat fixed.
121 06-Jan-00 maagrawa 115.49 Modified chk_bnft_ctfn to look for
122 mx_cvg_alwd_amt for ctfns.(1142060)
123 19-Jan-00 tguy 115.50 Added check for rounding when vrbl
124 rt trtmt cd = rplc do not round at
125 value at this level. Fixed error
126 message for null or zero comp.
127 20-Jan-00 thayden 115.51 Added prtt_enrt_rslt_id. bug 1146784
128 05-Feb-00 maagrawa 115.52 Fixed chk_bnft_ctfn (4392)
129 shdas-(1166169)
130 18-Feb-00 jcarpent 115.53 Make choice not eligible if bnft
131 is at max. and already have bnft.
132 22-Feb-00 shdas 115.54 Added codes for crntly_enrld_flag(1198551)
133 25-Feb-00 jcarpent 115.55 Close cursor problem c_other_pl_cvg.
134 26-Feb-00 thayden 115.56 If mlt_cd is Range, don't copy min,max,
135 incrmt,dflt to enrt benefit.
136 03-Mar-00 maagrawa 115.57 Created a new procedure write_ctfn
137 within the procedure main.
138 Always check for certs. when the
139 min. and max. benefit amounts are
140 defined.(1198549).
141 16-Mar-00 jcarpent 115.58 Added logic to handle ptips which
142 have plans with options and
143 maximums are reached. (1238601)
144 30-Mar-00 jcarpent 115.59 Cvg_mlt_cd's of saaear and nsvu
145 always had dflt_flag of N, changed
146 to use l_epe.dflt_flag. Also
147 was giving two default sometimes
148 changed default conditions.
149 bug 1252087/4983.
150 31-Mar-00 mmogel 115.60 Added tokens to messages to make the
151 messages more meaningful to the user
152 14-Apr-00 jcarpent 115.61 For all but RNG, write coverage if
153 it's above the max but then update
154 the choice to be not electable. (5095)
155 09-May-00 lmcdonal 115.62 ctfn's at the option level are written
156 in benchctf.pkb. don't write them at
157 the bnft level too. Bug 1277371.
158 12-May-00 lmcdonal 115.63 Bug 1249901 - when coverage is entered
159 at enrollment, we don't know if ctfns
160 are required until during enrt. Write
161 ctfn records, load new mx_wout_ctfn
162 field. Also override cvg-calc-mx
163 with rstrn-mx-with-ctfn val when writing
164 enrt-bnft row.
165 14-May-00 shdas 115.64 Bug 5152.Moved rounding function from
166 write coverage to main so that cvg value gets
167 rounded before applying variable profile.
168 18-May-00 jcarpent 115.65 Bug 5209. If choice is updated to be
169 not electable also make not the default.
170 Also, deenroll from the result if
171 above the max.
172 24-May-00 tmicheal 115.66 bug 4844 fixd
173 05-Jun-00 stee 115.67 When writing certifications, do
174 not restrict by the
175 bnft_or_option_retrctn_cd. There
176 is a check in the write_ctfn
177 procedure for duplicate
178 certification. wwbug #1308629.
179 20-Jul-00 bbulusu 115.68 Bug Fix 5368. Was not checking
180 for enter at enrollment when
181 comparing enrolled benefit amount
182 to null computed value.
183 25 Sep 00 mhoyes 115.69 - Commented out nocopy highly executed hr_utility
184 .set_locations.
185 07 Nov 00 mhoyes 115.70 - Referenced electable choice performance
186 APIs.
187 - Referenced comp object loop electable
188 choice context globals.
189 22 Nov 00 mhoyes 115.71 - Forward port of 1473060 on 115.69.
190 22 Nov 00 mhoyes 115.72 - Reinstated 115.70.
191 21 Nov 00 jcarpent 115.73 - bug 1470467. Check for provided
192 ctfns if over max. Leapfrog
193 based on 115.69
194 22 Nov 00 jcarpent 115.74 - Merged version with 115.70 and 115.71.
195 23-Jan-01 mhoyes 115.75 - Added calculate only mode for EFC.
196 21-Feb-01 kmahendr 115.76 - Bug#1569790 - Benefit row is inserted
197 for interim coverage if multi_cd is Flat
198 amt with enter value at enrollment flag on
199 22-Mar-01 mhoyes 115.77 - Called epecobjtree_getcvgdets to get l_cvg.
200 27-mar-01 tilak 115.78 - bug : 1433393 ,ultm lwr limit and upr limit
201 column added in vapro
202 the resilt of vapro and cvg validated against the
203 ultiamte limit
204 03-apr-01 tilak 115.79 bug : 1712464 ultm lwr limit rl,and upr limit rl
205 added
206 02-Aug-01 ikasire 115.80 Bug 1895846 fixes for suspended enrollments
207 02-Aug-01 ikasire 115.81 to add modification history for 115.80
208 28-Aug-01 kmahendr 115.82 Bug#1936976-result_id is populated based on
209 benefit amount
210 29-aug-01 tilak 115.83 bug:1949361 jurisdiction code is
211 derived inside benutils.formula.
212 27-Sep-01 kmahendr 115.84 Bug#1981673-Added parameter ann_mn_elcn_val and
213 ann_mx_elcn_val to ben_determine_variable_rates
214 call
215 02-nov-01 tjesumic 115.85 bug : 2083726 fixed , if variable rate define
216 and the treatment code is replace then
217 default valu , increment value , min , max taken from
218 variable rate
219 14-nov-01 tjesumic 115.86 DBDRV added
220 21-nov-01 tjesumic 115.87 default valu , increment value , min , max taken from
221 variable rat for REPLC , SF , ADDTO,MB
222 21-nov-01 tjesumic 115.88 correction in REPLC , SF , ADDTO,MB calculation
223 28-Dec-01 jcarpent 115.89 - Bug:2157614: Altered cursor
224 c_other_oipls_in_plan_type for
225 performance issue.
226 28-Dec-01 jcarpent 115.90 - Bug#1910867: Fixed code to handle
227 dschwart/cdaniels condition when the maximum amount is NULL.
228
229 28-Dec-01 dschwart/ 115.91 - Bug#2054078: Max Coverage without certification
230 BBurns/jcarpent was not showing up on form because it was not
231 being written to ben_enrt_bnft. Made modifications
232 to chk_bnft_ctfn_val parameters + related code to
233 fix this.
234 26-Mar-02 kmahendr 115.92 - Bug#1833008 - Added parameter p_cal_for to the call
235 determine_compensation to handle multi-assignment.
236 22-Apr-02 hnarayan 115.92 Bug 2319790 - changed chk_bnft_ctfn procedure
237 29-May-02 shdas 115.93 Bug 2325109 - Message token not sho wing values.
238 08-Jun-02 pabodla 115.94 Do not select the contingent worker
239 assignment when assignment data is
240 fetched.
241 08-AUg-02 ikasire 115.95 Bug 2502633 Interim Enhancements
242 Added logic to create additional benefit
243 row for the purpose of interim enrollment.
244 03-Sep-02 ikasire 115.96 Bug 2543071 interim codes Current Same Option
245 in plan typo.wrong parameter passed.
246 05-Sep-02 ikasire 115.97 Bug 2551711 Getting default amount instead of
247 getting min amount for interim
248 06-Sep-02 ikasire 115.98 need to populate current pen_id on the
249 enb record created for SAME case
250 13-Sep-02 tjesumic 115.99 if the dflt enrt cd is rule and global variable
251 g_dflt_elctn_val has the value then the global
252 value is used for default value,global value
253 is populated in bendenrr # 2534744
254 17-Sep-02 hnarayan 115.100 bug 2560721 - added code for setting dflt_flag
255 when coverage is Flat Range , for new enrollments
256 28-Sep-02 ikasire 115.101 Bug 2600087 added nvl(p_lf_evt_ocrd_dt,
257 p_effective_date) to the cursors
258 18-Dec-02 mmudigon 115.102 Bug 2708100 Changes to Flat Range
259 (FLRNG) calculations.
260 Old Flat Rng :
261 Min ---> Max
262 New Flat Rng :
263 Lower Limit --> Upper Limit
264 23-DEC-02 lakrish 115.104 NOCOPY changes
265 03-Jan-03 kmahendr 115.105 Bug#2708285 - the limit is checked after adding
266 the flat amount for CLPFLRNG calculation
267 15-Jan-03 tjesumic 115.106 bug#2736519 new parameter added in chk_bnft_ctfn
268 p_no_mn_cvg_amt_apls_flag,p_no_mx_cvg_amt_apls_flag
269 if the max is 'Y' the l_mx_amt is not validated
270 10-Mar-03 pbodla 115.107 If the coverage calculation method
271 is rule then pass the option id
272 by fetching it if it's not already
273 fetched.
274 13-Aug-03 kmahendr 115.108 Added cvg_mlt_cd ERL
275 14-Aug-03 vsethi 115.109 Bug#3095224 - the limit is checked after adding
276 the flat amount for FLFXPCL, FLPCLRNG calculation
277 25-Aug-03 kmahendr 115.111 Bug#3108422 - ctfn calls made for RL and ERL
278 26-Aug-03 kmahendr 115.112 Bug#3108422 - ctfn_rqd_flag changed for ERL
279 02-Oct-03 ikasire 115.113 Bug#3132792 - Enrollment is not suspending if
280 certification was received for the plan in
281 lower amount.
282 31-Oct-03 kmahendr 115.114 Bug#3230649 - added primary_flag condition and
283 order by in cursors c_asg.
284 15-Mar-04 rpgupta 115.115 Bug 3497676 - Allow a 0 coverage to be created
285 08-Apr-04 kmahendr 115.116 Bug3560065 - check for other_pl_cvg removed
286
287 17-Mar-04 pbodla 115.117 FONM : use cvg_strt_dt changes .
288 22-Apr-04 kmahendr 115.118 Bug#3585768 - limitation check removed
289 01-Jul-04 ikasire 115.119 Bug 3695079 We need to take the min of
290 mx with cert and increases plus current benefit
291 amount in deriving the max with cert amount
292 09-Aug-04 kmahendr 115.120 Bug#3772179 - Max without certification is
293 assigned a value in chk_bnft_ctfn.
294 05-Aug-04 tjesumic 115.121 FONM for ben_derive_factors fonm date paseed as param
295 17-Aug-04 hmani 115.122 Added newly added lookup codes 3806262
296 23-Aug-04 mmudigon 115.123 Excluding sspndd enrollmets in
297 cursor c_current_enrt
298 2534391 :NEED TO LEAVE ACTION ITEMS
299 15-Nov-04 kmahendr 115.124 Unrest. enh changes
300 01-Dec-04 abparekh 115.125 Bug 3828288 : For Flat Amount Calc Method consider Max Amount
301 as minimum of CCM Max, PLN Max WCfn, ( Current + PLN Max Incr WCfn )
302 01-dec-04 kmahendr 115.126 Unrest. enh changes
303 27-Dec-04 abparekh 115.127 Bug 3828288 : For Flat Amount Calc Method consider Max Increase
304 Amount only for Currently Enrolled records.
305 11-Jan-05 ikasire 115.128 CF Interim Suspended BUG 4064635 Multiple Changes
306 18-Jan-05 ikasire 115.129 CF Interim Suspended more changes
307 01-Feb-05 ikasire 115.130 CF Changes for 'SM' case
308 23-Feb-05 kmahendr 115.131 p_calculate_only_mode added not to
309 create_enrt_bnft when the value is false
310 07-Mar-05 ikasire 115.132 Bug 4223840 Flat Fixed Enter Value at enrollment
311 issue with mx_wout_ctfn_val issue
312 25-Mar-05 ikasire 115.133 Bug 4262970. Default is not identified properly in the
313 subsequent life event.
314 27-Mar-05 ikasire 115.134 Bug 4262970 - extend the fix to other flat range codes
315 28-Mar-05 kmahendr 115.135 Bug#4256191 - least of max, upper_limit_value
316 sent to get_least_val procedure
317 30-Mar-05 kmahendr 115.136 Bug#4256191 - rule evaluated before
318 determining the least amount
319 18-Apr-05 ssarkar 115.137 Bug# 4275929 : max_witout_cert is passed to max_with_cert ,
320 when null, while calling get_least_value proc.
321 06-jun-05 nhunur 115.138 4383988 - apply fnd_number on what FF returns in numeric variable.
322 30-Jun-05 ikasire 115.139 BUG 4449437 always setting the default flag to N for FLFXPCL
323 19-jul-05 rgajula 115.140 Bug 4436573 Added a new parameter p_cvg_mlt_cd to the
324 ben_determine_coverage.chk_bnft_ctfn to perform few more
325 validations to set the certification required flag of ben_enrt_bnft.
326 25-Sep-05 kmahendr 115.141 Bug#4630782 - in unrestricted mode inelig
327 process not called
328 27-Sep-05 ikasire 115.142 Bug 4627840
329 04-Oct-05 ikasire 115.143 Bug 4649262 ERL fix regression from 4436573
330 20-oct-05 rgajula 115.144 Bug 4644489 Added an additional parameter p_rstrn_mn_cvg_rqd_amt
331 ben_determine_coverage.chk_bnft_ctfn to return the minimum coverage amount
332 as calculated by the minium rule in coverage restrictions, the out parameter will
333 will return the amount as calculated by the rule or the min value in the min feild in retrictions.
334 This returned value is used in the write record for Flat Amount Calculation method as
335 max(cvg_rstrn_amount,cvg_calc_mthd_min_amnt).
336 16-Jan-06 abparekh 115.145 Bug 4954541 : Unrestricted : If coverage does not exist, then delete
337 corresponding BEN_ENRT_BNFT record
338 11-Apr-06 bmanyam 115.147 5105118 changes (115.146) are undone
339 This is leapfrog of 115.145.
340 5105118 is not-a-bug.
341 May 24, 2006 rgajula 115.148 Bug 5236985 Added the l_cvg_rstn_max_with_cert not null condition
342 This necessary if the l_rstrn.mx_cvg_wcfn_amt is
343 made null in the subsequent life event
344 28-Jun-2006 swjain 115.149 Bug 5331889 Added person_id param to mn_cvg_rl and mx_cvg_rl
345 in procedure chk_bnft_ctfn
346 11-Aug-2006 nhunur 115.150 Ult Lower limit value rule is not honoured
347 28-sep-2006 ssarkar 115.151 bug 5529258 : interim rule to be evaluated
348 29-sep-2006 ssarkar 115.152 5529258 : more fix
349 4-Oct-2006 rgajula 115.154 Bug 5573274 : Populated the mx_wout_ctfn value for Flat Range.
350 12-Oct-2006 ikasired 115.154 Bug 5596918 fix for 'SAME' part in carryforward. bnft amt null issue
351 12-Oct-2006 ikasired 115.154 Bug 5596907 fix for carryforward to use right bnft record
352 3-Nov-2006 rgajula 115.156 Bug 5637851 : Added nvl clauses in chk_bnft_ctfn.
353 27-Nov-2006 rgajula 115.157 Bug 5679097: Fix of regression for bug 5637851
354 23-Feb-2007 swjain 115.158 Bug 5887665: Passed ctfn_determine_cd in call to
355 ben_determine_chc_ctfn.write_ctfn in procedure main
356 02-Mar-2007 ssarkar 115.159 Bug 5900235 : write_ctfn to be called for RL if ctfn_rqd is true
357 22-Mar-2007 rgajula 115.161 Bug 5942733 : Removed the NVL clause which was causing the max_wout_cert to be set to max and causing unnecessary UI issues.
358 28-Mar-2007 swjain 115.162 Bug 5933576 : Added code in procedure main to check benefit certifications for 'NSVU' calculation method as well
359 30-Mar-2007 swjain 115.163 Bug 5933576 : When vr_val is null, then set it to default val in procedure main
360 17-May-2007 rtagarra 115.164 Bug 6054310 : Moved the condition added in 115.163 to NSVU Case only.
361 22-may-2007 nhunur 115.165 6066580: FLFXPCL do rounding after addition of flat amount
362 20-Jun-2007 rtagarra 115.166 Bug 6068097 : Made changes for the code NSDCS and NNCS.
363 04-Jul-2007 rtagarra 115.167 Bug 6164688 : For codes 'INCRCTF','DECRCTF' no need to check for order_number for calculation.
364 24-Oct-2007 bmanyam 115.168 6502657 :
365 If Coverage of more than one option
366 in same Plan is reduced due to
367 Upper Limit, then only one of
368 them is retained as Electable.
369 25-Oct-2007 sshetty Fixed bug 6523477
370 12-May-2008 For bug 7004909, changed the default value of coverage amount that was being passed to write coverages function for the type
371 Multiple of compensation
372 */
373 -------------------------------------------------------------------------------------------------------------------------------------------------
374 --
375 g_package varchar2(80) := 'ben_determine_coverage';
376 g_old_val number;
377 --
378 --
379 FUNCTION round_val
380 (p_val in number,
381 p_effective_date in date,
382 p_lf_evt_ocrd_dt in date,
383 p_rndg_cd in varchar2,
384 p_rndg_rl in number) return number is
385 --
386 l_package varchar2(80) := g_package||'.round_val';
387 l_val number;
388 BEGIN
389 --
390 hr_utility.set_location ('Entering '||l_package,10);
391 --
392 if (p_rndg_cd is not null or
393 p_rndg_rl is not null) then
394 --
395 l_val := benutils.do_rounding
396 (p_rounding_cd => p_rndg_cd,
397 p_rounding_rl => p_rndg_rl,
398 p_value => p_val,
399 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date));
400 --
401 else
402 --
403 l_val := p_val;
404 --
405 end if;
406 return l_val;
407 hr_utility.set_location ('Leaving '||l_package,10);
408 --
409 END round_val;
410 --
411 ------------------------------------------------------------------------------
412 --
413 -- PROCEDURE GET_LEAST_VALUE
414 -- Bug 3828288
415 -- This procedure will return following values :
416 -- p_mx_val_wcfn := Minimum ( p_ccm_max_val, p_cvg_rstn_max_with_cert, p_cvg_rstn_max_incr_with_cert )
417 -- p_mx_val_wo_cfn := Minimum ( p_ccm_max_val, p_cvg_rstn_max_wout_cert, p_cvg_rstn_max_incr_wout_cert )
418 --
419 ------------------------------------------------------------------------------
420 PROCEDURE get_least_value ( p_ccm_max_val in number,
421 p_cvg_rstn_max_incr_with_cert in number,
422 p_cvg_rstn_max_with_cert in number,
423 p_cvg_rstn_max_incr_wout_cert in number,
424 p_cvg_rstn_max_wout_cert in number,
425 p_mx_val_wcfn out nocopy number,
426 p_mx_val_wo_cfn out nocopy number
427 )
428 IS
429 BEGIN
430 --
431 --
432 if p_ccm_max_val is not null
433 then
434 p_mx_val_wcfn := nvl ( least ( p_ccm_max_val, p_cvg_rstn_max_with_cert, p_cvg_rstn_max_incr_with_cert ),
435 nvl ( least ( p_ccm_max_val, p_cvg_rstn_max_incr_with_cert ) ,
436 nvl ( least ( p_ccm_max_val, p_cvg_rstn_max_with_cert ) ,
437 p_ccm_max_val
438 )
439 )
440 );
441 p_mx_val_wo_cfn := nvl ( least ( p_ccm_max_val, p_cvg_rstn_max_wout_cert, p_cvg_rstn_max_incr_wout_cert ),
442 nvl ( least ( p_ccm_max_val, p_cvg_rstn_max_incr_wout_cert ) ,
443 least ( p_ccm_max_val, p_cvg_rstn_max_wout_cert ) -- Bug 5942733
444 )
445 );
446 else
447 p_mx_val_wcfn := nvl ( least ( p_cvg_rstn_max_with_cert, p_cvg_rstn_max_incr_with_cert ),
448 nvl ( p_cvg_rstn_max_with_cert,
449 p_cvg_rstn_max_incr_with_cert
450 )
451 );
452 p_mx_val_wo_cfn := nvl ( least ( p_cvg_rstn_max_wout_cert, p_cvg_rstn_max_incr_wout_cert ),
453 nvl ( p_cvg_rstn_max_wout_cert,
454 p_cvg_rstn_max_incr_wout_cert
455 )
456 );
457 end if;
458 --
459 END;
460
461 ---------------------------------------------------
462 --
463 -- Write ben_enrt_bnft
464 --
465 ---------------------------------------------------
466 --
467 PROCEDURE write_coverage
468 (p_calculate_only_mode in boolean default false
469 ,p_bndry_perd_cd in varchar2
470 ,p_bnft_typ_cd in varchar2
471 ,p_val in number
472 ,p_dflt_flag in varchar2
473 ,p_nnmntry_uom in varchar2
474 ,p_elig_per_elctbl_chc_id in number
475 ,p_business_group_id in number
476 ,p_effective_date in date
477 ,p_lf_evt_ocrd_dt in date
478 ,p_person_id in number
479 ,p_lwr_lmt_val in number
480 ,p_lwr_lmt_calc_rl in number
481 ,p_upr_lmt_val in number
482 ,p_upr_lmt_calc_rl in number
483 ,p_rndg_cd in varchar2
484 ,p_rndg_rl in number
485 ,p_comp_lvl_fctr_id in number
486 ,p_cvg_mlt_cd in varchar2
487 ,p_entr_val_at_enrt_flag in varchar2
488 ,p_mx_val in number
489 ,p_mx_wout_ctfn_val in number
490 ,p_mn_val in number
491 ,p_incrmt_val in number
492 ,p_dflt_val in number
493 ,p_rt_typ_cd in varchar2
494 ,p_perform_rounding_flg in boolean
495 ,p_ordr_num in number
496 ,p_ctfn_rqd_flag in varchar2
497 --
498 ,p_enrt_bnft_id out nocopy number
499 ,p_enb_valrow out nocopy ben_determine_coverage.ENBValType
500 --
501 ,p_ultmt_upr_lmt in number default null
502 ,p_ultmt_lwr_lmt in number default null
503 ,p_ultmt_upr_lmt_calc_rl in number default null
504 ,p_ultmt_lwr_lmt_calc_rl in number default null
505 ,p_bnft_amount in number default null
506 ,p_vapro_exist in varchar2 default null
507 )
508 is
509 --
510 l_enrt_bnft_id number;
511 l_object_version_number number;
512 l_package varchar2(80) := g_package||'.write_coverage';
513 l_old_val number;
514 l_val number;
515 l_other_cvg number;
516 --
517 cursor c_asg(cv_effective_date date) is -- FONM
518 select asg.assignment_id,asg.organization_id
519 from per_all_assignments_f asg
520 where asg.person_id = p_person_id
521 and asg.primary_flag = 'Y'
522 and asg.assignment_type <> 'C'
523 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
524 between asg.effective_start_date
525 and asg.effective_end_date
526 order by decode(asg.assignment_type, 'E',1,'B',2,3);
527 --
528 l_asg c_asg%rowtype;
529 --
530 cursor c_epe is
531 select epe.business_group_id,
532 epe.pgm_id,
533 epe.pl_id,
534 epe.pl_typ_id,
535 epe.ptip_id,
536 epe.plip_id,
537 epe.oipl_id,
538 epe.prtt_enrt_rslt_id,
539 pil.ler_id,
540 epe.object_version_number,
541 epe.elctbl_flag,
542 epe.per_in_ler_id
543 from ben_elig_per_elctbl_chc epe,
544 ben_per_in_ler pil
545 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
546 and epe.per_in_ler_id = pil.per_in_ler_id;
547 --
548 l_epe c_epe%rowtype;
549 --
550 /*
551 cursor c_det_crnt_enrt(l_rslt_id number) is
552 select pen.bnft_amt,
553 pen.bnft_ordr_num
554 from ben_prtt_enrt_rslt_f pen,
555 ben_elig_per_elctbl_chc epe
556 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
557 and epe.prtt_enrt_rslt_id = l_rslt_id
558 and pen.prtt_enrt_rslt_id = l_rslt_id;
559 --
560 -- l_det_crnt_enrt c_det_crnt_enrt%rowtype;
561 */
562 l_crnt_enrld_flag varchar2(30) := 'N';
563 --
564 -- FONM
565 cursor c_opt(cv_oipl_id number, cv_effective_date date) is
566 select oipl.opt_id
567 from ben_oipl_f oipl
568 where oipl.oipl_id = cv_oipl_id
569 and cv_effective_date
570 between oipl.effective_start_date
571 and oipl.effective_end_date;
572 --
573 l_opt c_opt%rowtype;
574 --
575 cursor c_state(cv_effective_date date) is -- FONM
576 select region_2
577 from hr_locations_all loc,
578 per_all_assignments_f asg
579 where loc.location_id = asg.location_id
580 and asg.person_id = p_person_id
581 and asg.primary_flag = 'Y'
582 and asg.assignment_type <> 'C'
583 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
584 between asg.effective_start_date
585 and asg.effective_end_date
586 and asg.business_group_id =p_business_group_id
587 order by decode(asg.assignment_type, 'E',1,'B',2,3);
588 --
589 l_state c_state%rowtype;
590 --
591 cursor c_other_oipl_cvg is
592 select enb.val
593 from ben_elig_per_elctbl_chc epe,
594 ben_enrt_bnft enb
595 where epe.pl_id=l_epe.pl_id
596 and nvl(epe.pgm_id,-1)=nvl(l_epe.pgm_id,-1)
597 and epe.per_in_ler_id=l_epe.per_in_ler_id
598 and epe.business_group_id=l_epe.business_group_id
599 and enb.elig_per_elctbl_chc_id=epe.elig_per_elctbl_chc_id
600 and enb.cvg_mlt_cd=p_cvg_mlt_cd
601 and enb.business_group_id=epe.business_group_id
602 and enb.val=l_val
603 ;
604 --
605 cursor c_other_pl_cvg is
606 select enb.val
607 from ben_elig_per_elctbl_chc epe,
608 ben_enrt_bnft enb
609 where epe.ptip_id=l_epe.ptip_id
610 and nvl(epe.pgm_id,-1)=nvl(l_epe.pgm_id,-1)
611 and epe.per_in_ler_id=l_epe.per_in_ler_id
612 and epe.business_group_id=l_epe.business_group_id
613 and enb.elig_per_elctbl_chc_id=epe.elig_per_elctbl_chc_id
614 and enb.cvg_mlt_cd=p_cvg_mlt_cd
615 and enb.business_group_id=epe.business_group_id
616 and enb.val=l_val
617 ;
618 --
619 cursor c_other_pl_in_ptip_cvg(cv_effective_date date) is
620 select enb.val
621 from ben_elig_per_elctbl_chc epe,
622 ben_oipl_f oipl,
623 ben_oipl_f oipl2,
624 ben_enrt_bnft enb
625 where epe.ptip_id=l_epe.ptip_id
626 and nvl(epe.pgm_id,-1)=nvl(l_epe.pgm_id,-1)
627 and epe.pl_typ_id=l_epe.pl_typ_id
628 and epe.per_in_ler_id=l_epe.per_in_ler_id
629 and epe.business_group_id=l_epe.business_group_id
630 and oipl.oipl_id=epe.oipl_id
631 and oipl.business_group_id=epe.business_group_id
632 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
633 between
634 oipl.effective_start_date and oipl.effective_end_date
635 and oipl2.oipl_id=l_epe.oipl_id
636 and oipl2.business_group_id=p_business_group_id
637 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
638 between
639 oipl2.effective_start_date and oipl2.effective_end_date
640 and oipl2.opt_id=oipl.opt_id -- why we join to oipls
641 and enb.elig_per_elctbl_chc_id=epe.elig_per_elctbl_chc_id
642 and enb.cvg_mlt_cd=p_cvg_mlt_cd
643 and enb.business_group_id=epe.business_group_id
644 and enb.val=l_val
645 ;
646 --
647 cursor c_pl_typ_plip_enrt_limit(cv_effective_date date) is
648 select '1', mx_enrd_alwd_ovrid_num
649 from ben_ptip_f
650 where ptip_id=l_epe.ptip_id
651 and business_group_id=l_epe.business_group_id
652 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
653 between
654 effective_start_date and effective_end_date
655 and mx_enrd_alwd_ovrid_num is not null
656 union
657 select '2', mx_enrl_alwd_num
658 from ben_pl_typ_f
659 where pl_typ_id=l_epe.pl_typ_id
660 and business_group_id=l_epe.business_group_id
661 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
662 between
663 effective_start_date and effective_end_date
664 and mx_enrl_alwd_num is not null
665 order by 1
666 ;
667 /*********************************
668 CODE PRIOR TO WWBUG: 2157614
669 cursor c_other_oipls_in_plan_type is
670 select 'Y'
671 from ben_elig_per_elctbl_chc epe
672 where epe.pl_typ_id=l_epe.pl_typ_id
673 and epe.pl_id<>l_epe.pl_id
674 and nvl(epe.pgm_id,-1)=nvl(l_epe.pgm_id,-1)
675 and epe.oipl_id is not null
676 and epe.business_group_id=p_business_group_id
677 ;
678 ***************************/
679 /* Start of Changes for WWBUG: 2157614 */
680 cursor c_other_oipls_in_plan_type(cv_effective_date date) is
681 select 'Y'
682 from ben_pl_f pln,
683 ben_oipl_f oipl
684 where pln.pl_typ_id=l_epe.pl_typ_id
685 and pln.pl_id<>l_epe.pl_id
686 and cv_effective_date between -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date) between
687 pln.effective_start_date and pln.effective_end_date
688 and pln.business_group_id=p_business_group_id
689 and oipl.pl_id=pln.pl_id
690 and oipl.business_group_id=p_business_group_id
691 and cv_effective_date between -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date) between
692 oipl.effective_start_date and oipl.effective_end_date
693 ;
694 /* End of Changes for WWBUG: 2157614 */
695 --Unrestricted enh
696 cursor c_unrest(p_ler_id number) is
697 select 'Y'
698 from ben_ler_f ler
699 where ler.typ_cd = 'SCHEDDU'
700 and ler.ler_id = p_ler_id
701 and p_effective_date between ler.effective_start_date
702 and ler.effective_end_date;
703 --
704 --CF Susp Interim Enhancement
705 --
706 cursor c_cf_bnft_result(cv_effective_date date) is
707 SELECT pen.prtt_enrt_rslt_id,
708 pen.bnft_amt,
709 pen.bnft_ordr_num
710 FROM ben_prtt_enrt_rslt_f pen
711 WHERE pen.person_id = p_person_id
712 AND pen.business_group_id = p_business_group_id
713 AND pen.prtt_enrt_rslt_stat_cd IS NULL
714 AND pen.effective_end_date = hr_api.g_eot
715 AND cv_effective_date <= pen.enrt_cvg_thru_dt
716 AND pen.enrt_cvg_strt_dt < pen.effective_end_date
717 AND NVL(l_epe.oipl_id,-1) = NVL(pen.oipl_id,-1)
718 AND l_epe.pl_id = pen.pl_id
719 AND NVL(l_epe.pgm_id,-1) = NVL(pen.pgm_id,-1)
720 AND ( pen.bnft_ordr_num = p_ordr_num OR
721 pen.bnft_amt = p_val )
722 order by pen.enrt_cvg_strt_dt,decode(pen.sspndd_flag,'Y',1,2);
723 --
724 l_cf_bnft_result c_cf_bnft_result%ROWTYPE;
725 --
726 l_dummy varchar2(1);
727 l_other_oipls_exist varchar2(30);
728 l_enrt_limit number;
729 l_level varchar2(30);
730 l_over_max_level boolean := false ;
731 l_prtt_enrt_rslt_id number;
732 -- FONM
733 l_fonm_cvg_strt_dt date;
734
735
736 BEGIN
737 --
738 hr_utility.set_location ('Entering '||l_package,10);
739 --
740 -- FONM
741 if ben_manage_life_events.fonm = 'Y' then
742 --
743 l_fonm_cvg_strt_dt := ben_manage_life_events.g_fonm_cvg_strt_dt;
744 --
745 end if;
746 --
747 l_val := p_val;
748 --
749 open c_state(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
750 --
751 fetch c_state into l_state;
752 --
753 close c_state;
754 hr_utility.set_location ('close c_state ',10);
755 --
756 open c_asg(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
757 --
758 fetch c_asg into l_asg; -- doesn't matter if null
759 --
760 close c_asg;
761 hr_utility.set_location ('close c_asg ',10);
762 --
763 if p_elig_per_elctbl_chc_id is not null then
764 --
765 open c_epe;
766 --
767 fetch c_epe into l_epe;
768 --
769 close c_epe;
770 hr_utility.set_location ('close c_epe ',10);
771 --
772 end if;
773 --
774 if l_epe.oipl_id is not null then
775 --
776 open c_opt(l_epe.oipl_id, nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
777 --
778 fetch c_opt into l_opt;
779 --
780 close c_opt;
781 hr_utility.set_location ('close c_opt ',10);
782 --
783 end if;
784 --
785 -- check boundaries
786 --
787 hr_utility.set_location ('limit_checks ',10);
788 l_old_val:=l_val;
789 --- bug:1433393 when the vapro not exist then the benefir amount assigned to the
790 --- old_val,
791 --- whne there is no vapro the max limit of benefit is validated to decide
792 --- whether the electable is allowd or not
793 --- the benefit amount (l_val) is after the limit_check so the beneft amount
794 --- (before limit check) assigned to old val
795 if nvl(p_vapro_exist,'N') <> 'Y' then
796 l_old_val := p_bnft_amount ;
797 end if ;
798 ---
799 ---validatiting ultmt lowr limit and ultimate upper limit
800 if p_ultmt_lwr_lmt is not null or p_ultmt_upr_lmt is not null
801 OR p_ultmt_lwr_lmt_calc_rl is not null or p_ultmt_upr_lmt_calc_rl is not null then
802 benutils.limit_checks
803 (p_lwr_lmt_val => p_ultmt_lwr_lmt,
804 p_lwr_lmt_calc_rl => p_ultmt_lwr_lmt_calc_rl,
805 p_upr_lmt_val => p_ultmt_upr_lmt,
806 p_upr_lmt_calc_rl => p_ultmt_upr_lmt_calc_rl,
807 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date), -- FONM : no need to pass the cvg or rt dates.
808 p_assignment_id => l_asg.assignment_id,
809 p_organization_id => l_asg.organization_id,
810 p_business_group_id => l_epe.business_group_id,
811 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
812 p_pgm_id => l_epe.pgm_id,
813 p_pl_id => l_epe.pl_id,
814 p_pl_typ_id => l_epe.pl_typ_id,
815 p_opt_id => l_opt.opt_id,
816 p_ler_id => l_epe.ler_id,
817 p_val => l_val,
818 p_state => l_state.region_2);
819 hr_utility.set_location ('Dn limit_checks ',10);
820 end if ;
821 --
822 -- If the value has been changed due to limits
823 -- and the value has been lowered then we have
824 -- hit the max. Check if another benefit has been
825 -- written at this same level. If so make this electable
826 -- choice not electable. Do this only for the non Range
827 -- cvg_mlt_cd's.
828 --
829 hr_utility.set_location('old='||l_old_val||' new='||
830 l_val||' limit='|| p_ultmt_upr_lmt,31);
831 hr_utility.set_location('per in ler id '|| l_epe.per_in_ler_id,31);
832 hr_utility.set_location('mult code '|| p_cvg_mlt_cd,31);
833 hr_utility.set_location('pl '|| l_epe.pl_id,31);
834 hr_utility.set_location('pgm '|| l_epe.pgm_id,31);
835
836 if l_val<l_old_val and
837 p_cvg_mlt_cd not like '%RNG' and
838 l_epe.elctbl_flag='Y' then
839
840 if l_epe.plip_id is not null or
841 l_epe.oipl_id is not null then
842 if l_epe.oipl_id is not null then
843 --
844 -- Check if it is the only plan within the plan type that has opts
845 --
846 -- 6502657 The c_other_oipls_in_plan_type check is not correct.
847 -- It checks on ben_pl_f and ben_oipl_f tables only
848 -- and this does not ensure Active/ Eligible/Electable Plans.
849 -- A better approach is to check for options only in current Plan
850 /*
851 l_other_oipls_exist:='N';
852 open c_other_oipls_in_plan_type(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM;
853 fetch c_other_oipls_in_plan_type into l_other_oipls_exist;
854 close c_other_oipls_in_plan_type;
855 if l_other_oipls_exist<>'Y' then
856 */
857 --
858 -- Case of one plan with options
859 --
860 -- 6502657 : This check will ensure, if Coverage of
861 -- more than one option in same Plan is reduced
862 -- due to Upper Limit, then only one of them is retained
863 -- as Electable.
864 --
865 hr_utility.set_location('other oipl ' ,90);
866 open c_other_oipl_cvg;
867 fetch c_other_oipl_cvg into l_other_cvg;
868 close c_other_oipl_cvg;
869 /* Bug#3585768 - Enrollment limitation will be enforced at the time of enrollment
870 else
871 l_enrt_limit:=null;
872 open c_pl_typ_plip_enrt_limit(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM;
873 fetch c_pl_typ_plip_enrt_limit into l_level,l_enrt_limit;
874 close c_pl_typ_plip_enrt_limit;
875 if l_enrt_limit>1 then
876 --
877 -- Case of can enroll in many plans
878 -- Note: same logic as one plan with options
879 --
880 open c_other_oipl_cvg;
881 fetch c_other_oipl_cvg into l_other_cvg;
882 close c_other_oipl_cvg;
883 elsif l_enrt_limit=1 then
884 --
885 -- Case of many plans same options and can only choose one
886 --
887 open c_other_pl_in_ptip_cvg(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
888 fetch c_other_pl_in_ptip_cvg into l_other_cvg;
889 close c_other_pl_in_ptip_cvg;
890 else
891 --
892 -- No limits no restriction
893 --
894 null;
895 end if;
896 */
897 -- end if; 6502657
898 /* Bug3560065 : If there are setups to have two plans with same coverage,
899 this fails
900 elsif l_epe.plip_id is not null then
901 --
902 -- Case of no options
903 --
904 open c_other_pl_cvg;
905 fetch c_other_pl_cvg into l_other_cvg;
906 close c_other_pl_cvg;
907 */
908 end if;
909 hr_utility.set_location(' other cal ' || l_other_cvg,99);
910 if l_other_cvg=l_val then
911 --
912 open c_unrest(l_epe.ler_id);
913 fetch c_unrest into l_dummy;
914 close c_unrest;
915 if l_dummy = 'Y' then
916 null;
917 else
918 --
919 if not p_calculate_only_mode then
920 --
921 -- This coverage is above the max
922 -- Update the electable choice to be not electable
923 --
924 ben_elig_per_elc_chc_api.update_perf_elig_per_elc_chc(
925 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
926 p_elctbl_flag => 'N',
927 p_dflt_flag => 'N',
928 p_object_version_number => l_epe.object_version_number,
929 p_effective_date => p_effective_date, -- FONM : no need to send the cvg strt dt
930 p_program_application_id => fnd_global.prog_appl_id,
931 p_program_id => fnd_global.conc_program_id,
932 p_request_id => fnd_global.conc_request_id,
933 p_program_update_date => sysdate
934 );
935 --
936 -- If enrolled will deenroll.
937 --
938 ben_newly_ineligible.main(
939 p_person_id => p_person_id,
940 p_pgm_id => l_epe.pgm_id,
941 p_pl_id => l_epe.pl_id,
942 p_oipl_id => l_epe.oipl_id,
943 p_business_group_id => p_business_group_id,
944 p_ler_id => l_epe.ler_id,
945 p_effective_date => p_effective_date -- FONM : no need to pass cvg or rt dates.
946 );
947 --
948 l_epe.elctbl_flag:='N';
949 hr_utility.set_location('Electable choice was made not electable by bencvrge',29);
950 end if;
951 end if;
952 end if;
953 end if;
954 end if;
955 --
956 -- Note: g_old_val is for RNG cvg_mlt_cd's, withing comp objects.
957 -- l_old_val and l_other_cvg are used for non RNG types
958 -- i.e., across oipls or plips.
959 --
960 open c_cf_bnft_result(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))) ;
961 fetch c_cf_bnft_result into l_cf_bnft_result ;
962 close c_cf_bnft_result ;
963 hr_utility.set_location('l_cf_bnft_result.prtt_enrt_rslt_id '||l_cf_bnft_result.prtt_enrt_rslt_id,39);
964 hr_utility.set_location('l_epe.prtt_enrt_rslt_id '||l_epe.prtt_enrt_rslt_id,39);
965 --
966 l_prtt_enrt_rslt_id := NVL(l_cf_bnft_result.prtt_enrt_rslt_id,l_epe.prtt_enrt_rslt_id);
967 --
968 if g_old_val <> nvl(l_val,-1) or
969 l_epe.elctbl_flag='N'
970 -- ERL changes
971 or p_cvg_mlt_cd = 'ERL' then
972 --
973 -- if l_epe.prtt_enrt_rslt_id is not null then
974 /* NEED TO BE TRASHED NEVER WORKS FOR FLAT RANGE
975 if l_prtt_enrt_rslt_id is not null then
976 open c_det_crnt_enrt(l_prtt_enrt_rslt_id);
977 fetch c_det_crnt_enrt into l_det_crnt_enrt;
978 if c_det_crnt_enrt%notfound then
979 l_crnt_enrld_flag := 'N';
980 else
981 if(l_val = l_det_crnt_enrt.bnft_amt or
982 p_entr_val_at_enrt_flag = 'Y'or l_det_crnt_enrt.bnft_ordr_num = p_ordr_num) then
983 l_crnt_enrld_flag := 'Y';
984 else
985 l_crnt_enrld_flag := 'N';
986 l_prtt_enrt_rslt_id := null;
987 end if;
988 end if;
989 close c_det_crnt_enrt;
990 end if;
991 */
992 if l_cf_bnft_result.prtt_enrt_rslt_id is not null then
993 --
994 if (l_val = l_cf_bnft_result.bnft_amt or
995 p_entr_val_at_enrt_flag = 'Y'or
996 l_cf_bnft_result.bnft_ordr_num = p_ordr_num) then
997 --
998 l_crnt_enrld_flag := 'Y';
999 --
1000 else
1001 --
1002 l_crnt_enrld_flag := 'N';
1003 l_prtt_enrt_rslt_id := null;
1004 --
1005 end if;
1006 --
1007 else
1008 --
1009 l_crnt_enrld_flag := 'N';
1010 l_prtt_enrt_rslt_id := null;
1011 --
1012 end if;
1013 --
1014 hr_utility.set_location('l_prtt_enrt_rslt_id '||l_prtt_enrt_rslt_id,39);
1015 hr_utility.set_location('l_crnt_enrld_flag'||l_crnt_enrld_flag,39);
1016 --
1017 if not p_calculate_only_mode then
1018 --
1019 open c_unrest(l_epe.ler_id);
1020 fetch c_unrest into l_dummy;
1021 close c_unrest;
1022 if l_dummy = 'Y' then
1023 l_enrt_bnft_id := ben_manage_unres_life_events.enb_exists
1024 (p_elig_per_elctbl_chc_id,p_ordr_num);
1025 end if;
1026 if l_enrt_bnft_id is not null then
1027 ben_manage_unres_life_events.update_enrt_bnft
1028 (
1029 p_dflt_flag => p_dflt_flag,
1030 p_val_has_bn_prortd_flag => 'N',
1031 p_bndry_perd_cd => p_bndry_perd_cd,
1032 p_bnft_typ_cd => p_bnft_typ_cd,
1033 p_val => l_val,
1034 p_nnmntry_uom => p_nnmntry_uom,
1035 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
1036 p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id,
1037 p_business_group_id => p_business_group_id,
1038 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
1039 p_program_application_id => fnd_global.prog_appl_id,
1040 p_program_id => fnd_global.conc_program_id,
1041 p_request_id => fnd_global.conc_request_id,
1042 p_comp_lvl_fctr_id => p_comp_lvl_fctr_id,
1043 p_cvg_mlt_cd => p_cvg_mlt_cd,
1044 p_crntly_enrld_flag => l_crnt_enrld_flag,
1045 p_ctfn_rqd_flag => p_ctfn_rqd_flag,
1046 p_entr_val_at_enrt_flag => p_entr_val_at_enrt_flag,
1047 p_mx_val => p_mx_val,
1048 p_mx_wout_ctfn_val => p_mx_wout_ctfn_val,
1049 p_mn_val => p_mn_val,
1050 p_incrmt_val => p_incrmt_val,
1051 p_dflt_val => p_dflt_val,
1052 p_rt_typ_cd => p_rt_typ_cd,
1053 p_program_update_date => sysdate,
1054 p_enrt_bnft_id => l_enrt_bnft_id,
1055 p_ordr_num => p_ordr_num);
1056 else
1057 --
1058 ben_enrt_bnft_api.create_enrt_bnft
1059 (p_validate => false,
1060 p_dflt_flag => p_dflt_flag,
1061 p_val_has_bn_prortd_flag => 'N', -- change when prorating
1062 p_bndry_perd_cd => p_bndry_perd_cd,
1063 p_bnft_typ_cd => p_bnft_typ_cd,
1064 p_val => l_val,
1065 p_nnmntry_uom => p_nnmntry_uom,
1066 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
1067 p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id, --l_epe.prtt_enrt_rslt_id,
1068 p_business_group_id => p_business_group_id,
1069 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date), -- FONM : No need to pass the cvg date.
1070 p_program_application_id => fnd_global.prog_appl_id,
1071 p_program_id => fnd_global.conc_program_id,
1072 p_request_id => fnd_global.conc_request_id,
1073 p_comp_lvl_fctr_id => p_comp_lvl_fctr_id,
1074 p_cvg_mlt_cd => p_cvg_mlt_cd,
1075 p_crntly_enrld_flag => l_crnt_enrld_flag,
1076 p_ctfn_rqd_flag => p_ctfn_rqd_flag,
1077 p_entr_val_at_enrt_flag => p_entr_val_at_enrt_flag,
1078 p_mx_val => p_mx_val, -- max with ctfn
1079 p_mx_wout_ctfn_val => p_mx_wout_ctfn_val, -- max without ctfn
1080 p_mn_val => p_mn_val,
1081 p_incrmt_val => p_incrmt_val,
1082 p_dflt_val => p_dflt_val,
1083 p_rt_typ_cd => p_rt_typ_cd,
1084 p_program_update_date => sysdate,
1085 p_enrt_bnft_id => l_enrt_bnft_id,
1086 p_object_version_number => l_object_version_number,
1087 p_ordr_num => p_ordr_num);
1088 --
1089 end if;
1090 end if;
1091 --
1092 end if;
1093 --
1094 -- Set OUT parameters
1095 --
1096 g_old_val := l_val;
1097 p_enrt_bnft_id := l_enrt_bnft_id;
1098 --
1099 p_enb_valrow.enrt_bnft_id := l_enrt_bnft_id;
1100 p_enb_valrow.val := l_val;
1101 p_enb_valrow.mn_val := p_mn_val;
1102 p_enb_valrow.mx_val := p_mx_val;
1103 p_enb_valrow.mx_wout_ctfn_val := p_mx_wout_ctfn_val;
1104 p_enb_valrow.incrmt_val := p_incrmt_val;
1105 p_enb_valrow.dflt_val := p_dflt_val;
1106 --
1107 hr_utility.set_location ('Leaving '||l_package,10);
1108 --
1109 END write_coverage;
1110 --
1111 ------------------------------------------------------------------------
1112 PROCEDURE combine_with_variable_val
1113 (p_vr_val in number,
1114 p_val in number,
1115 p_vr_trtmt_cd in varchar2,
1116 p_combined_val out nocopy number) is
1117 --
1118 l_package varchar2(80) := g_package||'.combine_with_variable_val';
1119 --
1120 BEGIN
1121 --
1122 hr_utility.set_location ('Entering '||l_package,10);
1123 --
1124 if p_vr_val is null then
1125 --
1126 p_combined_val := p_val;
1127 return;
1128 --
1129 end if;
1130 --
1131 if p_val is null then
1132 --
1133 p_combined_val := p_vr_val;
1134 return;
1135 --
1136 end if;
1137 --
1138 -- Replace
1139 --
1140 if p_vr_trtmt_cd = 'RPLC' then
1141 --
1142 p_combined_val := p_vr_val;
1143 --
1144 -- Multiply By
1145 --
1146 elsif p_vr_trtmt_cd = 'MB' then
1147 --
1148 p_combined_val := p_val * p_vr_val;
1149 --
1150 -- Subtract From
1151 --
1152 elsif p_vr_trtmt_cd = 'SF' then
1153 --
1154 p_combined_val := p_val - p_vr_val;
1155 --
1156 -- Add To
1157 --
1158 elsif p_vr_trtmt_cd = 'ADDTO' then
1159 --
1160 p_combined_val := p_val + p_vr_val;
1161 --
1162 else -- Replace
1163 --
1164 p_combined_val := p_vr_val;
1165 --
1166 end if;
1167 --
1168 hr_utility.set_location ('Leaving '||l_package,10);
1169 --
1170 END combine_with_variable_val;
1171 --
1172 ----------------------------------------------------------------------------
1173 --
1174 procedure chk_bnft_ctfn(p_mx_cvg_wcfn_amt in number default null,
1175 p_mx_cvg_wcfn_mlt_num in number default null,
1176 p_mx_cvg_mlt_incr_num in number default null,
1177 p_mx_cvg_mlt_incr_wcf_num in number default null,
1178 p_mx_cvg_incr_alwd_amt in number default null,
1179 p_mx_cvg_incr_wcf_alwd_amt in number default null,
1180 p_mn_cvg_rqd_amt in number default null,
1181 p_mx_cvg_alwd_amt in number default null,
1182 p_mx_cvg_rl in number default null,
1183 p_mn_cvg_rl in number default null,
1184 p_combined_val in number default null,
1185 p_crnt_bnft_amt in number default null,
1186 p_ordr_num in number default null,
1187 p_crnt_ordr_num in number default null,
1188 p_no_mn_cvg_amt_apls_flag in varchar2 default null,
1189 p_no_mx_cvg_amt_apls_flag in varchar2 default null,
1190 p_effective_date in date,
1191 p_assignment_id in number default null,
1192 p_organization_id in number default null,
1193 p_business_group_id in number default null,
1194 p_pgm_id in number default null,
1195 p_pl_id in number default null,
1196 p_pl_typ_id in number default null,
1197 p_opt_id in number default null,
1198 p_ler_id in number default null,
1199 p_elig_per_elctbl_chc_id in number default null,
1200 p_entr_val_at_enrt_flag in varchar2 default null,
1201 p_jurisdiction_code in varchar2 default null,
1202 --Bug No:4436573 Created another default null parameter for passing the p_cvg_mlt_cd
1203 -- to perform the necessary validation
1204 p_cvg_mlt_cd in varchar2 default null,
1205 --End Bug No:4436573
1206 p_ctfn_rqd out nocopy varchar2,
1207 p_write_rec out nocopy boolean,
1208 p_check_received out nocopy boolean,
1209 /* Start of Changes for WWBUG: 2054078: added parameter */
1210 p_mx_cvg_wout_ctfn_val out nocopy number,
1211 /* End of Changes for WWBUG: 2054078: added parameter */
1212 p_rstrn_mn_cvg_rqd_amt out nocopy number)
1213 /*Bug 4644489 - parameter to return the minimum coverage required amount as calculated by the
1214 minimum rule of static value defined in the min field in coverage restrictions*/
1215 is
1216 --
1217 l_package varchar2(80) := g_package||'.chk_bnft_ctfn';
1218 l_max_possible_amt number := null;
1219 l_mn_amt number := null;
1220 l_mx_amt number := null;
1221 --
1222 l_mn_outputs ff_exec.outputs_t;
1223 l_mx_outputs ff_exec.outputs_t;
1224 --Bug No:4436573 Creating another variable to concatenate
1225 -- all the feilds in PLN and LBR blocks of coverage restriction form
1226 l_pln_lbr_itms varchar2(500) := null;
1227 --End Bug No:4436573
1228 --
1229 /* Bug 5331889 */
1230 cursor fetch_person_id is
1231 select person_id
1232 from per_all_assignments_f
1233 where assignment_id = p_assignment_id;
1234 l_person_id number;
1235
1236 BEGIN
1237 --
1238 hr_utility.set_location ('Entering '||l_package,10);
1239 --
1240 l_max_possible_amt := p_mx_cvg_wcfn_amt;
1241 l_mn_amt := p_mn_cvg_rqd_amt;
1242 l_mx_amt := p_mx_cvg_alwd_amt;
1243 --bug#3772179
1244 if ((l_mx_amt is null) and ((p_mx_cvg_incr_alwd_amt is not null) or (p_mx_cvg_wcfn_amt is not null) ) )then --Bug 5679097
1245 l_mx_amt := p_crnt_bnft_amt + nvl(p_mx_cvg_incr_alwd_amt,0); /* Bug 3828288 */ -- Bug 5637851
1246 end if;
1247 p_mx_cvg_wout_ctfn_val := l_mx_amt;
1248 --
1249 --Bug 3695079
1250 --l_max_possible_amt amount should be the min of p_mx_cvg_wcfn_amt and p_mx_cvg_incr_wcf_alwd_amt
1251 --p_mx_cvg_incr_wcf_alwd_amt is defined otherwise we need to take only p_mx_cvg_wcfn_amt
1252 --
1253 hr_utility.set_location ('l_max_possible_amt '||l_max_possible_amt,111);
1254 hr_utility.set_location ('p_mx_cvg_incr_wcf_alwd_amt '||p_mx_cvg_incr_wcf_alwd_amt,111);
1255 if p_mx_cvg_incr_wcf_alwd_amt IS NOT NULL then
1256 --
1257 if l_max_possible_amt IS NULL OR
1258 nvl(l_max_possible_amt,0) > (p_mx_cvg_incr_wcf_alwd_amt + nvl(p_crnt_bnft_amt,0)) then
1259 l_max_possible_amt := p_mx_cvg_incr_wcf_alwd_amt + nvl(p_crnt_bnft_amt,0);
1260 hr_utility.set_location ('l_max_possible_amt inside '||l_max_possible_amt,111);
1261 end if;
1262 --
1263 end if;
1264 --
1265 open fetch_person_id; -- Bug 5331889
1266 fetch fetch_person_id into l_person_id;
1267 close fetch_person_id;
1268 --
1269 if p_mn_cvg_rl is not NULL then
1270 --
1271 l_mn_outputs := benutils.formula
1272 (p_formula_id => p_mn_cvg_rl,
1273 p_effective_date => p_effective_date,
1274 p_assignment_id => p_assignment_id,
1275 p_organization_id => p_organization_id,
1276 p_business_group_id => p_business_group_id,
1277 p_pgm_id => p_pgm_id,
1278 p_pl_id => p_pl_id,
1279 p_pl_typ_id => p_pl_typ_id,
1280 p_opt_id => p_opt_id,
1281 p_ler_id => p_ler_id,
1282 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
1283 -- FONM
1284 p_param1 => 'BEN_IV_RT_STRT_DT',
1285 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
1286 p_param2 => 'BEN_IV_CVG_STRT_DT',
1287 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt),
1288 p_param3 => 'BEN_IV_PERSON_ID', -- Bug 5331889
1289 p_param3_value => to_char(l_person_id),
1290 p_jurisdiction_code => p_jurisdiction_code);
1291 --
1292 if l_mn_outputs(l_mn_outputs.first).value is not null then
1293 --
1294 l_mn_amt := fnd_number.canonical_to_number(l_mn_outputs(l_mn_outputs.first).value);
1295 --
1296 --Bug 4644489
1297 p_rstrn_mn_cvg_rqd_amt := l_mn_amt;
1298 -- Returing the mn_cvg_rqd_amt as defined by the rule
1299 --End Bug 4644489
1300 end if;
1301 --
1302 end if;
1303 --
1304 if p_mx_cvg_rl is not NULL then
1305 --
1306 l_mx_outputs := benutils.formula
1307 (p_formula_id => p_mx_cvg_rl,
1308 p_effective_date => p_effective_date,
1309 p_assignment_id => p_assignment_id,
1310 p_organization_id => p_organization_id,
1311 p_business_group_id => p_business_group_id,
1312 p_pgm_id => p_pgm_id,
1313 p_pl_id => p_pl_id,
1314 p_pl_typ_id => p_pl_typ_id,
1315 p_opt_id => p_opt_id,
1316 p_ler_id => p_ler_id,
1317 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
1318 -- FONM
1319 p_param1 => 'BEN_IV_RT_STRT_DT',
1320 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
1321 p_param2 => 'BEN_IV_CVG_STRT_DT',
1322 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt),
1323 p_param3 => 'BEN_IV_PERSON_ID', -- Bug 5331889
1324 p_param3_value => to_char(l_person_id),
1325 p_jurisdiction_code => p_jurisdiction_code);
1326 --
1327 if l_mx_outputs(l_mx_outputs.first).value is not null then
1328 --
1329 l_mx_amt := fnd_number.canonical_to_number(l_mx_outputs(l_mx_outputs.first).value);
1330 --
1331 /* Start of Changes for WWBUG: 2054078: added */
1332 p_mx_cvg_wout_ctfn_val := l_mx_amt;
1333 /* Ended of Changes for WWBUG: 2054078: added */
1334 --
1335 end if;
1336 --
1337 end if;
1338 --
1339
1340 hr_utility.set_location ('Plan PL_ID -> '||p_pl_id ,33);
1341 hr_utility.set_location ('p_mx_cvg_wcfn_amt -> '||p_mx_cvg_wcfn_amt ,33);
1342 hr_utility.set_location ('p_mx_cvg_wcfn_mlt_num -> '||p_mx_cvg_wcfn_mlt_num ,33);
1343 hr_utility.set_location ('p_mx_cvg_mlt_incr_num -> '||p_mx_cvg_mlt_incr_num ,33);
1344 hr_utility.set_location ('p_mx_cvg_mlt_incr_wcf_num -> '||p_mx_cvg_mlt_incr_wcf_num ,33);
1345 hr_utility.set_location ('p_mx_cvg_incr_alwd_amt -> '||p_mx_cvg_incr_alwd_amt ,33);
1346 hr_utility.set_location ('p_mx_cvg_incr_wcf_alwd_amt -> '||p_mx_cvg_incr_wcf_alwd_amt,33);
1347 hr_utility.set_location ('p_mx_cvg_rl -> '||p_mx_cvg_rl ,33);
1348 hr_utility.set_location ('p_mn_cvg_rl -> '||p_mn_cvg_rl ,33);
1349 hr_utility.set_location ('p_combined_val -> '||p_combined_val ,33);
1350 hr_utility.set_location ('p_crnt_bnft_amt -> '||p_crnt_bnft_amt ,33);
1351 hr_utility.set_location ('p_ordr_num -> '||p_ordr_num ,33);
1352 hr_utility.set_location ('p_crnt_ordr_num -> '||p_crnt_ordr_num ,33);
1353 --Bug No:4436573 Debugging purpose
1354 hr_utility.set_location ('p_cvg_mlt_cd -> '||p_cvg_mlt_cd ,33);
1355 --End Bug No:4436573
1356 --
1357 if p_combined_val is null then
1358 --
1359 p_ctfn_rqd := 'N';
1360 p_write_rec := true;
1361 --
1362 elsif p_combined_val > l_max_possible_amt then
1363 --
1364 p_ctfn_rqd := 'N';
1365 p_write_rec := false;
1366 --
1367 elsif p_ordr_num > p_mx_cvg_wcfn_mlt_num then
1368 --
1369 p_ctfn_rqd := 'N';
1370 p_write_rec := false;
1371 --
1372 elsif p_combined_val < l_mn_amt then
1373 --
1374 p_ctfn_rqd := 'N';
1375 p_write_rec := false;
1376 --
1377 elsif p_crnt_bnft_amt is null and
1378 p_crnt_ordr_num is null then
1379 --
1380 p_ctfn_rqd := 'N';
1381 p_write_rec := true;
1382 --
1383 elsif (p_combined_val - nvl(p_crnt_bnft_amt,0))
1384 > p_mx_cvg_incr_wcf_alwd_amt then
1385 --
1386 p_ctfn_rqd := 'N';
1387 p_write_rec := false;
1388 --
1389 elsif (p_ordr_num - nvl(p_crnt_ordr_num,0)) > p_mx_cvg_mlt_incr_wcf_num then
1390 --
1391 p_ctfn_rqd := 'N';
1392 p_write_rec := false;
1393 --
1394 elsif (p_combined_val - nvl(p_crnt_bnft_amt,0))
1395 <= p_mx_cvg_incr_alwd_amt then
1396 --
1397 p_ctfn_rqd := 'N';
1398 p_write_rec := true;
1399 --
1400 elsif (p_ordr_num - nvl(p_crnt_ordr_num,0)) <= p_mx_cvg_mlt_incr_num then
1401 --
1402 p_ctfn_rqd := 'N';
1403 p_write_rec := true;
1404 --
1405 elsif (p_combined_val - nvl(p_crnt_bnft_amt,0))
1406 <= p_mx_cvg_incr_wcf_alwd_amt then
1407 --
1408 hr_utility.set_location(' IK1 p_combined_val - nvl(p_crnt_bnft_amt,0))'||(p_combined_val - nvl(p_crnt_bnft_amt,0)),99);
1409 hr_utility.set_location('IK1 p_mx_cvg_incr_wcf_alwd_amt'||p_mx_cvg_incr_wcf_alwd_amt,99);
1410 p_ctfn_rqd := 'Y';
1411 p_write_rec := true;
1412 --
1413 elsif (p_ordr_num - nvl(p_crnt_ordr_num,0))<= p_mx_cvg_mlt_incr_wcf_num then
1414 --
1415 p_ctfn_rqd := 'Y';
1416 p_write_rec := true;
1417 --
1418 else
1419 --
1420 p_ctfn_rqd := 'N';
1421 p_write_rec := true;
1422 --
1423 end if;
1424 --
1425 if p_write_rec then
1426 hr_utility.set_location (' p_write_rec ',10);
1427 end if ;
1428
1429 hr_utility.set_location (' p_no_mx_cvg_amt_apls_flag'|| p_no_mx_cvg_amt_apls_flag,10);
1430
1431 -- This Certification condition is not based on increases,
1432 -- but based on a fixed amount. (Bug 1142060)
1433 -- no max flag is validated for # 2736519
1434 --
1435 -- Bug 3132792 if certifications is already provided for a benefit amount
1436 -- we don't need certifications upto that amount.
1437 -- Max without cert 50,000. Max with Cert is 100,000.
1438 -- In the first life event customer provided a certification for the
1439 -- benefit amount of 75,000. Now we need certification only for the
1440 -- amount more than 75,000 even if there are no increases defined by
1441 -- the customer.
1442 --
1443 hr_utility.set_location ('IK l_mx_amt '||l_mx_amt,20);
1444 hr_utility.set_location ('IK p_crnt_bnft_amt '||p_crnt_bnft_amt,20);
1445 --
1446 if p_entr_val_at_enrt_flag = 'N' then
1447 --
1448 l_mx_amt := greatest(l_mx_amt,nvl(p_crnt_bnft_amt,0));
1449 --
1450 end if;
1451 --
1452 if p_write_rec and
1453 ( p_combined_val > l_mx_amt or p_no_mx_cvg_amt_apls_flag = 'Y') then
1454 --
1455 hr_utility.set_location ('IK I am Here'||p_combined_val,99);
1456 hr_utility.set_location ('IK l_mx_amt'||l_mx_amt ,99);
1457 p_check_received:=true;
1458 p_ctfn_rqd := 'Y';
1459 --
1460 end if;
1461 --
1462 hr_utility.set_location ('p_ctfn_rqd '||p_ctfn_rqd,09);
1463 --
1464 if p_write_rec and p_entr_val_at_enrt_flag = 'Y' and
1465 (l_mx_amt < l_max_possible_amt
1466 or l_max_possible_amt is not null)
1467 then
1468 hr_utility.set_location ('IK ENTRVALENRT case',99);
1469 p_ctfn_rqd := 'Y';
1470 end if;
1471 --
1472 if p_cvg_mlt_cd = 'ERL' then
1473 l_pln_lbr_itms := p_mx_cvg_wcfn_amt ||p_mx_cvg_wcfn_mlt_num || p_mx_cvg_mlt_incr_num;
1474 l_pln_lbr_itms := l_pln_lbr_itms || p_mx_cvg_mlt_incr_wcf_num || p_mx_cvg_incr_alwd_amt;
1475 l_pln_lbr_itms := l_pln_lbr_itms || p_mx_cvg_incr_wcf_alwd_amt || p_mn_cvg_rqd_amt;
1476 l_pln_lbr_itms := l_pln_lbr_itms || p_mx_cvg_alwd_amt || p_mx_cvg_rl ||p_mn_cvg_rl ;
1477 --
1478 IF l_pln_lbr_itms is not null then
1479 p_ctfn_rqd := 'Y';
1480 ELSE
1481 p_ctfn_rqd :='N';
1482 END if;
1483 --
1484 END if;
1485 --
1486 hr_utility.set_location ('p_ctfn_rqd '||p_ctfn_rqd,10);
1487 hr_utility.set_location ('Leaving '||l_package,10);
1488 --
1489 END chk_bnft_ctfn;
1490 --
1491 ------------------------------------------------------------------------------
1492 --
1493 PROCEDURE main
1494 (p_calculate_only_mode in boolean
1495 ,p_elig_per_elctbl_chc_id IN number
1496 ,p_effective_date IN date
1497 ,p_lf_evt_ocrd_dt IN date
1498 ,p_perform_rounding_flg IN boolean
1499 --
1500 ,p_enb_valrow out nocopy ben_determine_coverage.ENBValType
1501 )
1502 is
1503 --
1504 l_package varchar2(80) := g_package||'.main';
1505 l_object_version_number number;
1506 l_value number;
1507 l_compensation_value number;
1508 l_dummy_number number;
1509 l_dummy_char varchar2(30);
1510 l_combined_val number;
1511 l_calculated_val number;
1512 l_vr_val number;
1513 l_vr_trtmt_cd varchar2(30);
1514 l_outputs ff_exec.outputs_t;
1515 l_dflt_flag varchar2(30) := 'N';
1516 i number;
1517 l_incr_r_decr_cd varchar2(15);
1518 l_order_number number := 1;
1519 l_crnt_ordr_num number := null;
1520 l_bnft_amt number := null;
1521 l_write_rec boolean := true;
1522 l_ctfn_rqd varchar2(15) := 'N';
1523 l_ctfn_rqd2 varchar2(15) := 'N';
1524 l_elctbl_chc_ctfn_id number;
1525 l_rstrn_found boolean := false;
1526 l_oipl_id varchar2(30);
1527 l_business_group_id varchar2(30);
1528 l_pl_id varchar2(30);
1529 l_ler_id varchar2(30);
1530 l_ler_bnft_rstrn_id varchar2(30);
1531 l_person_id varchar2(30);
1532 l_enrt_bnft_id number;
1533 l_dflt_val number;
1534 l_dflt_enrt_cd varchar2(30);
1535 l_dflt_enrt_rl number;
1536 l_jurisdiction_code varchar2(30);
1537 l_effective_date date;
1538 -- FONM
1539 l_fonm_cvg_strt_dt date;
1540 l_perform_rounding_flg boolean := p_perform_rounding_flg;
1541 l_ultmt_upr_lmt number ;
1542 l_ultmt_lwr_lmt number ;
1543 l_ultmt_upr_lmt_calc_rl number ;
1544 l_ultmt_lwr_lmt_calc_rl number ;
1545 l_vapro_exist varchar2(30) ;
1546 l_cvg_amount number ;
1547 l_vr_ann_mn_elcn_val number;
1548 l_vr_ann_mx_elcn_val number;
1549 l_mn_elcn_val number;
1550 l_mx_elcn_val number;
1551 l_incrmnt_elcn_val number;
1552 l_dflt_elcn_val number;
1553 l_interim_bnft_val number; /*ENH*/
1554 l_upr_val number;
1555 l_lwr_val number;
1556 l_upr_outputs ff_exec.outputs_t;
1557 l_lwr_outputs ff_exec.outputs_t;
1558 l_ult_lwr_outputs ff_exec.outputs_t;
1559 --
1560 /* Start of Changes for WWBUG: 2054078 */
1561 l_mx_cvg_wout_ctfn_val number;
1562 /* End of Changes for WWBUG: 2054078 */
1563 --
1564 l_inst_count pls_integer;
1565
1566 --Bug 4644489
1567 l_rstrn_mn_cvg_rqd_amt number;
1568 --End Bug 4644489
1569
1570 -- 5529258
1571 l_dflt_to_asn_pndg_ctfn_cd ben_pl_f.DFLT_TO_ASN_PNDG_CTFN_CD%type;
1572 l_INTERIM_ELCTBL_CHC_ID number;
1573 l_INTERIM_BNFT_AMT number;
1574
1575 -- ends 5529258
1576 --
1577 cursor c_epe is
1578 select pil.person_id,
1579 epe.prtt_enrt_rslt_id, --5529258
1580 epe.pgm_id,
1581 epe.pl_id,
1582 epe.pl_typ_id,
1583 epe.oipl_id,
1584 epe.plip_id,
1585 epe.ptip_id,
1586 epe.dflt_flag,
1587 pil.per_in_ler_id,
1588 pil.ler_id,
1589 epe.business_group_id,
1590 epe.crntly_enrd_flag,
1591 epe.elctbl_flag,
1592 epe.object_version_number
1593 from ben_elig_per_elctbl_chc epe,
1594 ben_per_in_ler pil
1595 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
1596 and epe.per_in_ler_id = pil.per_in_ler_id ;
1597 --
1598 --bug 1895846 to check for the pending work flow or suspended enrollment results
1599 --
1600 cursor c_epe_in_pndg is
1601 select null
1602 from ben_elig_per_elctbl_chc epe,
1603 ben_per_in_ler pil
1604 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
1605 and epe.per_in_ler_id = pil.per_in_ler_id
1606 and nvl(epe.in_pndg_wkflow_flag,'N') <> 'N' ;
1607 --
1608 l_dummy varchar2(30):= null ;
1609
1610 l_epe c_epe%rowtype;
1611 --
1612 -- FONM
1613 cursor c_opt(rqd_oipl_id number, cv_effective_date date) is
1614 select opt_id
1615 from ben_oipl_f
1616 where oipl_id = rqd_oipl_id
1617 and cv_effective_date -- nvl(p_lf_evt_ocrd_dt,p_effective_date)
1618 between effective_start_date
1619 and effective_end_date;
1620 --
1621 l_opt c_opt%rowtype;
1622 --
1623
1624
1625 cursor c_ler_rstrn(cv_effective_date date) is -- FONM
1626 select rstrn.ler_bnft_rstrn_id,
1627 rstrn.pl_id,
1628 rstrn.cvg_incr_r_decr_only_cd,
1629 rstrn.mx_cvg_wcfn_amt,
1630 rstrn.mx_cvg_wcfn_mlt_num,
1631 rstrn.mx_cvg_mlt_incr_num,
1632 rstrn.mx_cvg_mlt_incr_wcf_num,
1633 rstrn.mx_cvg_incr_alwd_amt,
1634 rstrn.mx_cvg_incr_wcf_alwd_amt,
1635 rstrn.mn_cvg_amt mn_cvg_rqd_amt,
1636 rstrn.mx_cvg_alwd_amt,
1637 rstrn.mx_cvg_rl,
1638 rstrn.mn_cvg_rl,
1639 rstrn.no_mn_cvg_incr_apls_flag no_mn_cvg_amt_apls_flag,
1640 rstrn.no_mx_cvg_amt_apls_flag no_mx_cvg_amt_apls_flag,
1641 rstrn.dflt_to_asn_pndg_ctfn_cd, /*ENH*/
1642 rstrn.dflt_to_asn_pndg_ctfn_rl -- 5529258
1643 from ben_ler_bnft_rstrn_f rstrn
1644 where rstrn.ler_id = l_ler_id
1645 and rstrn.pl_id = l_pl_id
1646 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1647 between rstrn.effective_start_date
1648 and rstrn.effective_end_date;
1649 --
1650 cursor c_pl_rstrn(cv_effective_date date) is -- FONM
1651 select null ler_bnft_rstrn_id,
1652 pln.pl_id,
1653 pln.cvg_incr_r_decr_only_cd,
1654 pln.mx_cvg_wcfn_amt,
1655 pln.mx_cvg_wcfn_mlt_num,
1656 pln.mx_cvg_mlt_incr_num,
1657 pln.mx_cvg_mlt_incr_wcf_num,
1658 pln.mx_cvg_incr_alwd_amt,
1659 pln.mx_cvg_incr_wcf_alwd_amt,
1660 pln.mn_cvg_rqd_amt,
1661 pln.mx_cvg_alwd_amt,
1662 pln.mx_cvg_rl,
1663 pln.mn_cvg_rl,
1664 pln.no_mn_cvg_amt_apls_flag,
1665 pln.no_mx_cvg_amt_apls_flag,
1666 pln.dflt_to_asn_pndg_ctfn_cd, /*ENH*/
1667 pln.dflt_to_asn_pndg_ctfn_rl --5529258
1668 from ben_pl_f pln
1669 where pln.pl_id = l_pl_id
1670 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1671 between pln.effective_start_date
1672 and pln.effective_end_date;
1673 --
1674 l_rstrn c_ler_rstrn%rowtype;
1675 --
1676 cursor c_ler_rstrn_ctfn(cv_effective_date date) is -- FONM
1677 select ctfn.rqd_flag,
1678 ctfn.enrt_ctfn_typ_cd,
1679 ctfn.ctfn_rqd_when_rl,
1680 lbr.ctfn_determine_cd
1681 from ben_ler_bnft_rstrn_ctfn_f ctfn, ben_ler_bnft_rstrn_f lbr -- Bug 5887665
1682 where ctfn.ler_bnft_rstrn_id = l_ler_bnft_rstrn_id
1683 and ctfn.ler_bnft_rstrn_id = lbr.ler_bnft_rstrn_id
1684 and ctfn.business_group_id = l_business_group_id
1685 and lbr.business_group_id = l_business_group_id
1686 and cv_effective_date
1687 between lbr.effective_start_date
1688 and lbr.effective_end_date
1689 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1690 between ctfn.effective_start_date
1691 and ctfn.effective_end_date;
1692 --
1693 cursor c_pl_rstrn_ctfn(cv_effective_date date) is -- FONM
1694 select ctfn.rqd_flag,
1695 ctfn.enrt_ctfn_typ_cd,
1696 ctfn.ctfn_rqd_when_rl,
1697 pln.ctfn_determine_cd
1698 from ben_bnft_rstrn_ctfn_f ctfn, ben_pl_f pln -- Bug 5887675
1699 where ctfn.pl_id = l_pl_id
1700 and ctfn.pl_id = pln.pl_id
1701 and ctfn.business_group_id = l_business_group_id
1702 and pln.business_group_id = l_business_group_id
1703 and cv_effective_date
1704 between pln.effective_start_date
1705 and pln.effective_end_date
1706 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1707 between ctfn.effective_start_date
1708 and ctfn.effective_end_date;
1709 --
1710 l_cvg ben_cvg_cache.g_epeplncvg_cache;
1711 --
1712 cursor c_asg(cv_effective_date date) is -- FONM
1713 select asg.assignment_id,asg.organization_id
1714 from per_all_assignments_f asg
1715 where asg.person_id = l_epe.person_id
1716 and asg.primary_flag = 'Y'
1717 and asg.assignment_type <> 'C'
1718 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1719 between asg.effective_start_date
1720 and asg.effective_end_date
1721 order by decode(asg.assignment_type, 'E',1,'B',2,3);
1722 --
1723 l_asg c_asg%rowtype;
1724 --
1725 cursor c_state (cv_effective_date date) is -- FONM
1726 select region_2
1727 from hr_locations_all loc,
1728 per_all_assignments_f asg
1729 where loc.location_id = asg.location_id
1730 and asg.person_id = l_epe.person_id
1731 and asg.primary_flag = 'Y'
1732 and asg.assignment_type <> 'C'
1733 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1734 between asg.effective_start_date
1735 and asg.effective_end_date
1736 order by decode(asg.assignment_type, 'E',1,'B',2,3);
1737 --
1738 l_state c_state%rowtype;
1739 --
1740 -- bug 2560721 - added another return value from the cursor c_current_enrt to determine
1741 -- if the person is previously enrolled or New enrollment, becos bnft_amt and bnft_ordr_num
1742 -- can both be null even if the person is enrolled. This might occur when the coverage is
1743 -- not defined for the plan during his previous enrollment.
1744 --
1745 l_current_enrt_present char;
1746 --
1747 cursor c_current_enrt(cv_effective_date date) is -- FONM
1748 select bnft_ordr_num,
1749 bnft_amt,
1750 'Y'
1751 from ben_prtt_enrt_rslt_f
1752 where business_group_id = l_business_group_id
1753 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1754 between enrt_cvg_strt_dt
1755 and enrt_cvg_thru_dt
1756 and enrt_cvg_thru_dt <= effective_end_date
1757 and prtt_enrt_rslt_stat_cd is null
1758 and sspndd_flag = 'N'
1759 and l_person_id = person_id
1760 and l_pl_id = pl_id
1761 and ((l_oipl_id is null and oipl_id is null) or
1762 l_oipl_id = oipl_id)
1763 order by decode(sspndd_flag,'Y',1,2) ; --CF Changes
1764 --
1765 cursor c_current_enrt_sspndd(cv_effective_date date) is -- FONM
1766 select bnft_ordr_num,
1767 bnft_amt,
1768 'Y'
1769 from ben_prtt_enrt_rslt_f
1770 where business_group_id = l_business_group_id
1771 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1772 between enrt_cvg_strt_dt
1773 and enrt_cvg_thru_dt
1774 and enrt_cvg_thru_dt <= effective_end_date
1775 and prtt_enrt_rslt_stat_cd is null
1776 and sspndd_flag = 'Y'
1777 and l_person_id = person_id
1778 and l_pl_id = pl_id
1779 and ((l_oipl_id is null and oipl_id is null) or
1780 l_oipl_id = oipl_id)
1781 order by decode(sspndd_flag,'Y',1,2) ; --CF Changes
1782 --
1783 l_current_enrt_sspndd c_current_enrt_sspndd%rowtype;
1784 --
1785 /*ENH*/
1786 cursor c_current_enrt_in_pl_typ(c_pl_typ_id number,cv_effective_date date) is -- FONM
1787 select pl_id,oipl_id
1788 from ben_prtt_enrt_rslt_f
1789 where business_group_id = l_business_group_id
1790 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1791 between enrt_cvg_strt_dt
1792 and enrt_cvg_thru_dt
1793 and enrt_cvg_thru_dt <= effective_end_date
1794 and sspndd_flag = 'N'
1795 and prtt_enrt_rslt_stat_cd is null
1796 and l_person_id = person_id
1797 and c_pl_typ_id = pl_typ_id ;
1798 --
1799 cursor c_current_enrt_in_pln( c_pl_id number,cv_effective_date date ) is -- FONM
1800 select pl_id,oipl_id
1801 from ben_prtt_enrt_rslt_f
1802 where business_group_id = l_business_group_id
1803 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1804 between enrt_cvg_strt_dt
1805 and enrt_cvg_thru_dt
1806 and enrt_cvg_thru_dt <= effective_end_date
1807 and sspndd_flag = 'N'
1808 and prtt_enrt_rslt_stat_cd is null
1809 and l_person_id = person_id
1810 and c_pl_id = pl_id ;
1811 --
1812 cursor c_current_enrt_in_oipl( c_oipl_id number, cv_effective_date date ) is -- FONM
1813 select pl_id,oipl_id
1814 from ben_prtt_enrt_rslt_f
1815 where business_group_id = l_business_group_id
1816 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1817 between enrt_cvg_strt_dt
1818 and enrt_cvg_thru_dt
1819 and enrt_cvg_thru_dt <= effective_end_date
1820 and sspndd_flag = 'N'
1821 and prtt_enrt_rslt_stat_cd is null
1822 and l_person_id = person_id
1823 and c_oipl_id = oipl_id ;
1824 --
1825 -- CF Changes
1826 cursor c_current_enb(c_pl_id number,c_oipl_id number, cv_effective_date date ) is -- FONM
1827 select
1828 pen.bnft_amt,
1829 enb.*
1830 from ben_prtt_enrt_rslt_f pen,
1831 ben_enrt_bnft enb,
1832 ben_elig_per_elctbl_chc epe,
1833 ben_per_in_ler pil
1834 where pen.business_group_id = l_business_group_id
1835 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1836 between pen.enrt_cvg_strt_dt
1837 and pen.enrt_cvg_thru_dt
1838 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
1839 and pen.prtt_enrt_rslt_stat_cd is null
1840 and pen.sspndd_flag = 'N' ---CF Changes
1841 and l_person_id = pen.person_id
1842 and c_pl_id = pen.pl_id
1843 and ((c_oipl_id is null and pen.oipl_id is null) or
1844 c_oipl_id = pen.oipl_id)
1845 and pen.prtt_enrt_rslt_id = enb.prtt_enrt_rslt_id
1846 and pen.bnft_ordr_num = enb.ordr_num
1847 and enb.elig_per_elctbl_chc_id = epe.elig_per_elctbl_chc_id
1848 and epe.per_in_ler_id = pil.per_in_ler_id
1849 and pil.per_in_ler_stat_cd = 'PROCD'
1850 and pil.person_id = l_person_id ;
1851 --
1852 l_current_enb c_current_enb%rowtype;
1853 --
1854 cursor c_clf(p_comp_lvl_fctr_id in number) is
1855 select clf.comp_src_cd,
1856 clf.name
1857 from ben_comp_lvl_fctr clf
1858 where p_comp_lvl_fctr_id = clf.comp_lvl_fctr_id;
1859 --
1860 l_clf c_clf%rowtype;
1861 --
1862 l_not_found boolean;
1863 --
1864 l_commit number;
1865 l_val number;
1866 --
1867 l_check_received boolean:=false;
1868 l_ctfn_received varchar2(30) := 'N';
1869 l_interim_cd varchar2(30) := 'DF' ; /*ENH I am defaulting to Default Val */
1870 l_current_level_cd varchar2(30) := null;
1871 l_create_current_enb boolean := false ;
1872 l_current_plan_id number := null;
1873 l_current_oipl_id number := null;
1874
1875 --
1876 cursor c_ctfn_received(
1877 p_pgm_id in number,
1878 p_pl_id in number,
1879 p_enrt_ctfn_typ_cd in varchar2,
1880 p_person_id in number,
1881 cv_effective_date in date ) is -- FONM
1882 select 'Y'
1883 from
1884 ben_prtt_enrt_rslt_f pen,
1885 ben_prtt_enrt_actn_f pea,
1886 ben_per_in_ler pil,
1887 ben_prtt_enrt_ctfn_prvdd_f ecp
1888 where
1889 -- pen
1890 pen.person_id=p_person_id
1891 and pen.business_group_id = l_business_group_id
1892 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date) between
1893 between pen.effective_start_date and pen.effective_end_date
1894 and pen.pl_id=p_pl_id
1895 and nvl(pen.pgm_id,-1)=nvl(p_pgm_id,-1)
1896 and pen.prtt_enrt_rslt_stat_cd is null
1897 -- pea
1898 and pea.prtt_enrt_rslt_id=pen.prtt_enrt_rslt_id
1899 and pea.business_group_id=pen.business_group_id
1900 and pea.pl_bnf_id is null
1901 and pea.elig_cvrd_dpnt_id is null
1902 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1903 between pea.effective_start_date
1904 and pea.effective_end_date
1905 -- pil
1906 and pil.per_in_ler_id=pea.per_in_ler_id
1907 and pil.business_group_id=pea.business_group_id
1908 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT')
1909 -- ecp
1910 and ecp.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
1911 and ecp.prtt_enrt_actn_id=pea.prtt_enrt_actn_id
1912 and ecp.enrt_ctfn_recd_dt is not null
1913 and ecp.business_group_id = pen.business_group_id
1914 and cv_effective_date -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date)
1915 between ecp.effective_start_date
1916 and ecp.effective_end_date
1917 and ecp.enrt_ctfn_typ_cd=p_enrt_ctfn_typ_cd
1918 --Bug 3132792 only if the benefit amount is more that the combined value
1919 -- we need to return 'Y' for the certification received flag
1920 and pen.bnft_amt >= l_combined_val
1921 ;
1922 l_tot_val number;
1923 --Unrestricted enh
1924 cursor c_unrest(p_ler_id number) is
1925 select 'Y'
1926 from ben_ler_f ler
1927 where ler.typ_cd = 'SCHEDDU'
1928 and ler.ler_id = p_ler_id
1929 and p_effective_date between ler.effective_start_date
1930 and ler.effective_end_date;
1931 --
1932 -- Bug 3828288
1933 l_mx_val_wcfn number;
1934 l_mx_val_wo_cfn number;
1935 l_ccm_max_val number;
1936 l_cvg_rstn_max_incr_wout_cert number;
1937 l_cvg_rstn_max_incr_with_cert number;
1938 l_cvg_rstn_max_wout_cert number;
1939 l_cvg_rstn_max_with_cert number;
1940 -- Bug 3828288
1941 --
1942 procedure write_ctfn is
1943 begin
1944 --
1945 -- ctfn's at the option level are written in benchctf.pkb
1946 -- don't write them at the bnft level too. Bug 1277371.
1947 --
1948 hr_utility.set_location('IK l_combined_val '||l_combined_val,20);
1949 hr_utility.set_location('IK l_enrt_bnft_id '||l_enrt_bnft_id,20);
1950 hr_utility.set_location('IK p_elig_per_elctbl_chc_id '||p_elig_per_elctbl_chc_id,20);
1951 --
1952 if l_ler_bnft_rstrn_id is not null then
1953 for l_ctfn in c_ler_rstrn_ctfn(nvl(l_fonm_cvg_strt_dt,l_effective_date)) loop -- FONM
1954 l_ctfn_received:='N';
1955 if l_check_received then
1956 open c_ctfn_received(
1957 p_pgm_id =>l_epe.pgm_id,
1958 p_pl_id =>l_epe.pl_id,
1959 p_enrt_ctfn_typ_cd =>l_ctfn.enrt_ctfn_typ_cd,
1960 p_person_id =>l_epe.person_id,
1961 cv_effective_date =>nvl(l_fonm_cvg_strt_dt, l_effective_date) -- FONM
1962 );
1963 fetch c_ctfn_received into l_ctfn_received;
1964 close c_ctfn_received;
1965 end if;
1966 if l_ctfn_received='N' then
1967 ben_determine_chc_ctfn.write_ctfn
1968 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
1969 p_enrt_bnft_id => l_enrt_bnft_id,
1970 p_enrt_ctfn_typ_cd => l_ctfn.enrt_ctfn_typ_cd,
1971 p_rqd_flag => l_ctfn.rqd_flag,
1972 p_ctfn_rqd_when_rl => l_ctfn.ctfn_rqd_when_rl,
1973 p_business_group_id => l_epe.business_group_id,
1974 p_effective_date => l_effective_date, -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date),
1975 p_assignment_id => l_asg.assignment_id,
1976 p_organization_id => l_asg.organization_id,
1977 p_jurisdiction_code => l_jurisdiction_code,
1978 p_pgm_id => l_epe.pgm_id,
1979 p_pl_id => l_epe.pl_id,
1980 p_pl_typ_id => l_epe.pl_typ_id,
1981 p_opt_id => l_opt.opt_id,
1982 p_ler_id => l_epe.ler_id,
1983 p_ctfn_determine_cd => l_ctfn.ctfn_determine_cd); -- Bug 5887665
1984 end if;
1985 end loop;
1986 --
1987 else
1988 hr_utility.set_location('IK Else Write CTFN',99);
1989 --
1990 for l_ctfn in c_pl_rstrn_ctfn ( nvl(l_fonm_cvg_strt_dt, l_effective_date)) loop -- FONM
1991 l_ctfn_received:='N';
1992 if l_check_received then
1993 hr_utility.set_location('IK Check ctfn TRUE',89);
1994 open c_ctfn_received(
1995 p_pgm_id =>l_epe.pgm_id,
1996 p_pl_id =>l_epe.pl_id,
1997 p_enrt_ctfn_typ_cd =>l_ctfn.enrt_ctfn_typ_cd,
1998 p_person_id =>l_epe.person_id,
1999 cv_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date) -- FONM
2000 );
2001 fetch c_ctfn_received into l_ctfn_received;
2002 close c_ctfn_received;
2003 end if;
2004 if l_ctfn_received='N' then
2005 --
2006 hr_utility.set_location('IK l_ctfn_received=N',99) ;
2007 --
2008 ben_determine_chc_ctfn.write_ctfn
2009 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
2010 p_enrt_bnft_id => l_enrt_bnft_id,
2011 p_enrt_ctfn_typ_cd => l_ctfn.enrt_ctfn_typ_cd,
2012 p_rqd_flag => l_ctfn.rqd_flag,
2013 p_ctfn_rqd_when_rl => l_ctfn.ctfn_rqd_when_rl,
2014 p_business_group_id => l_epe.business_group_id,
2015 p_effective_date => l_effective_date, -- FONM nvl(p_lf_evt_ocrd_dt,p_effective_date),
2016 p_assignment_id => l_asg.assignment_id,
2017 p_organization_id => l_asg.organization_id,
2018 p_jurisdiction_code => l_jurisdiction_code,
2019 p_pgm_id => l_epe.pgm_id,
2020 p_pl_id => l_epe.pl_id,
2021 p_pl_typ_id => l_epe.pl_typ_id,
2022 p_opt_id => l_opt.opt_id,
2023 p_ler_id => l_epe.ler_id,
2024 p_ctfn_determine_cd => l_ctfn.ctfn_determine_cd); -- Bug 5887665
2025 end if;
2026 end loop;
2027 end if;
2028
2029 end write_ctfn;
2030 --
2031 BEGIN
2032 --
2033 hr_utility.set_location ('Entering '||l_package,10);
2034 --
2035 --
2036 -- Bug 1895846
2037 open c_epe_in_pndg ;
2038 --
2039 fetch c_epe_in_pndg into l_dummy ;
2040 if c_epe_in_pndg%found then
2041 --
2042 hr_utility.set_location ('Suspended or Pending work flow records exist ' , 10);
2043 hr_utility.set_location ('Leaving '||l_package,10);
2044 close c_epe_in_pndg ;
2045 return ;
2046 --
2047 end if;
2048 close c_epe_in_pndg ;
2049 --
2050 -- put a row in fnd_sessions
2051 --
2052 g_old_val := hr_api.g_number; /*0;changed for 3497676 */
2053
2054 /* when the 1st coverage is calculated as 0, the enrt bnft row was not
2055 being created because g_old_val is initialised to 0 */
2056 --
2057 -- Edit to insure that the input p_effective_date has a value
2058 --
2059 If (p_effective_date is null) then
2060 --
2061 fnd_message.set_name('BEN','BEN_91837_BENCVRGE_INPT_EFFDT');
2062 fnd_message.set_token('PACKAGE',l_package);
2063 fnd_message.set_token('ELIG_PER_ELCTBL_CHC_ID',
2064 to_char(p_elig_per_elctbl_chc_id));
2065 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
2066 fnd_message.raise_error;
2067 --
2068 end if;
2069 --
2070 -- Edit to insure that the input p_elig_per_elctbl_chc_id has a value
2071 --
2072 If (p_elig_per_elctbl_chc_id is null) then
2073 --
2074 fnd_message.set_name('BEN','BEN_91838_BENCVRGE_INPT_EC');
2075 fnd_message.set_token('PACKAGE',l_package);
2076 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
2077 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
2078 fnd_message.raise_error;
2079 --
2080 end if;
2081 --
2082 -- Deduce effective date
2083 --
2084 if p_lf_evt_ocrd_dt is not null then
2085 --
2086 l_effective_date := p_lf_evt_ocrd_dt;
2087 --
2088 else
2089 --
2090 l_effective_date := p_effective_date;
2091 --
2092 end if;
2093 -- FONM
2094 if ben_manage_life_events.fonm = 'Y' then
2095 --
2096 l_fonm_cvg_strt_dt := ben_manage_life_events.g_fonm_cvg_strt_dt;
2097 --
2098 end if;
2099 --
2100 -- put a row into fnd_sessions
2101 --
2102 dt_fndate.change_ses_date
2103 (p_ses_date => p_effective_date,
2104 p_commit => l_commit);
2105 --
2106 l_not_found := false;
2107 --
2108 -- Walk the comp object tree for the electable choice and get
2109 -- the appropriate coverage details
2110 --
2111 hr_utility.set_location ('pl_id '||ben_epe_cache.g_currcobjepe_row.pl_id,10);
2112 hr_utility.set_location ('elig choice id'||p_elig_per_elctbl_chc_id,11);
2113 ben_cvg_cache.epecobjtree_getcvgdets
2114 (p_epe_id => p_elig_per_elctbl_chc_id
2115 ,p_epe_pl_id => ben_epe_cache.g_currcobjepe_row.pl_id
2116 ,p_epe_plip_id => ben_epe_cache.g_currcobjepe_row.plip_id
2117 ,p_epe_oipl_id => ben_epe_cache.g_currcobjepe_row.oipl_id
2118 ,p_effective_date => nvl(l_fonm_cvg_strt_dt, l_effective_date) -- FONM need to use new date
2119 --
2120 ,p_cvg_set => l_cvg
2121 );
2122 --
2123 /* if l_cvg.count = 0 then
2124 --
2125 return;
2126 --
2127 end if;
2128 */
2129 --
2130 hr_utility.set_location ('open c_epe ',10);
2131 open c_epe;
2132 --
2133 fetch c_epe into l_epe;
2134 --
2135 if c_epe%notfound then
2136 --
2137 close c_epe;
2138 fnd_message.set_name('BEN','BEN_91839_BENCVRGE_EPE_NF');
2139 fnd_message.set_token('PACKAGE',l_package);
2140 fnd_message.set_token('ELIG_PER_ELCTBL_CHC_ID',
2141 to_char(p_elig_per_elctbl_chc_id));
2142 fnd_message.raise_error;
2143 --
2144 end if;
2145 --
2146 close c_epe;
2147 hr_utility.set_location ('close c_epe ',10);
2148 hr_utility.set_location ('pl_id'||l_epe.pl_id,10);
2149 if p_calculate_only_mode then
2150 ben_cvg_cache.epecobjtree_getcvgdets
2151 (p_epe_id => p_elig_per_elctbl_chc_id
2152 ,p_epe_pl_id => l_epe.pl_id
2153 ,p_epe_plip_id => l_epe.plip_id
2154 ,p_epe_oipl_id => l_epe.oipl_id
2155 ,p_effective_date => nvl(l_fonm_cvg_strt_dt, l_effective_date) -- FONM need to pass new date
2156 ,p_cvg_set => l_cvg
2157 );
2158 end if;
2159 --
2160 if l_cvg.count = 0 then
2161 --
2162 -- Bug 4954541 - For unrestricted, if no coverage found, then we should delete ENB record
2163 -- which we would have reused otherwise. If we dont delete ENB, then the rate
2164 -- gets tied to the ENB (which gets deleted later in bebmures.clear_cache()
2165 -- This leads to dangling ECR.
2166 --
2167 l_dummy := null;
2168 open c_unrest(l_epe.ler_id);
2169 fetch c_unrest into l_dummy;
2170 close c_unrest;
2171 --
2172 if l_dummy = 'Y'
2173 then
2174 --
2175 hr_utility.set_location('No Coverage For EPE_ID = ' || p_elig_per_elctbl_chc_id, 8787);
2176 l_enrt_bnft_id := ben_manage_unres_life_events.enb_exists(p_elig_per_elctbl_chc_id,1);
2177 hr_utility.set_location('l_enrt_bnft_id = ' || l_enrt_bnft_id, 8787);
2178 --
2179 IF l_enrt_bnft_id is not null
2180 THEN
2181 --
2182 delete from ben_enrt_Bnft
2183 where elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id;
2184 --
2185 END IF;
2186 --
2187 end if;
2188 --
2189 return;
2190 --
2191 end if;
2192 --
2193 l_person_id := l_epe.person_id;
2194 --
2195 if l_cvg(0).cvg_mlt_cd is null then
2196 --
2197 fnd_message.set_name('BEN','BEN_91840_BENCVRGE_MLT_CD_RQD');
2198 fnd_message.set_token('PACKAGE',l_package);
2199 fnd_message.set_token('PERSON_ID',to_char(l_epe.person_id));
2200 fnd_message.set_token('PGM_ID',to_char(l_epe.pgm_id));
2201 fnd_message.set_token('PL_ID',to_char(l_epe.pl_id));
2202 fnd_message.set_token('PL_TYP_ID',to_char(l_epe.pl_typ_id));
2203 fnd_message.set_token('OIPL_ID',to_char(l_epe.oipl_id));
2204 fnd_message.set_token('PLIP_ID',to_char(l_epe.plip_id));
2205 fnd_message.set_token('PTIP_ID',to_char(l_epe.ptip_id));
2206 fnd_message.set_token('ELIG_PER_ELCTBL_CHC_ID',
2207 to_char(p_elig_per_elctbl_chc_id));
2208 fnd_message.raise_error;
2209 --
2210 end if;
2211 --
2212 if l_cvg(0).cvg_mlt_cd in ('FLFX','CL','FLPCLRNG','CLPFLRNG','FLFXPCL') then
2213 --
2214 if l_cvg(0).val is null and l_cvg(0).entr_val_at_enrt_flag = 'N' then
2215 --
2216 fnd_message.set_name('BEN','BEN_91841_BENCVRGE_VAL_RQD');
2217 fnd_message.set_token('PACKAGE',l_package);
2218 fnd_message.set_token('PERSON_ID',to_char(l_epe.person_id));
2219 fnd_message.set_token('CALC_MTHD',l_cvg(0).cvg_mlt_cd);
2220 fnd_message.set_token('PGM_ID',to_char(l_epe.pgm_id));
2221 fnd_message.set_token('PL_ID',to_char(l_epe.pl_id));
2222 fnd_message.set_token('PL_TYP_ID',to_char(l_epe.pl_typ_id));
2223 fnd_message.set_token('OIPL_ID',to_char(l_epe.oipl_id));
2224 fnd_message.set_token('PLIP_ID',to_char(l_epe.plip_id));
2225 fnd_message.set_token('PTIP_ID',to_char(l_epe.ptip_id));
2226 fnd_message.raise_error;
2227 --
2228 end if;
2229 --
2230 end if;
2231 --
2232 if l_cvg(0).cvg_mlt_cd in ('CLRNG','FLPCLRNG','CLPFLRNG','FLRNG') then
2233 --
2234 if l_cvg(0).mn_val is null or
2235 l_cvg(0).mx_val is null or
2236 l_cvg(0).incrmt_val is null then
2237 --
2238 fnd_message.set_name('BEN','BEN_91842_BENCVRGE_MX_MN_INC_R');
2239 fnd_message.set_token('PACKAGE',l_package);
2240 fnd_message.set_token('PERSON_ID',to_char(l_epe.person_id));
2241 fnd_message.set_token('CALC_MTHD',l_cvg(0).cvg_mlt_cd);
2242 fnd_message.set_token('PGM_ID',to_char(l_epe.pgm_id));
2243 fnd_message.set_token('PL_ID',to_char(l_epe.pl_id));
2244 fnd_message.set_token('PL_TYP_ID',to_char(l_epe.pl_typ_id));
2245 fnd_message.set_token('OIPL_ID',to_char(l_epe.oipl_id));
2246 fnd_message.set_token('PLIP_ID',to_char(l_epe.plip_id));
2247 fnd_message.set_token('PTIP_ID',to_char(l_epe.ptip_id));
2248 fnd_message.raise_error;
2249 --
2250 end if;
2251 --
2252 end if;
2253 --
2254 if l_cvg(0).cvg_mlt_cd in ('CL','CLRNG','FLFXPCL','FLPCLRNG','CLPFLRNG') then
2255 --
2256 if l_cvg(0).comp_lvl_fctr_id is null then
2257 --
2258 fnd_message.set_name('BEN','BEN_91843_BENCVRGE_NULL_CLF');
2259 fnd_message.set_token('PACKAGE',l_package);
2260 fnd_message.set_token('PERSON_ID',to_char(l_epe.person_id));
2261 fnd_message.set_token('CALC_MTHD',l_cvg(0).cvg_mlt_cd);
2262 fnd_message.set_token('PGM_ID',to_char(l_epe.pgm_id));
2263 fnd_message.set_token('PL_ID',to_char(l_epe.pl_id));
2264 fnd_message.set_token('PL_TYP_ID',to_char(l_epe.pl_typ_id));
2265 fnd_message.set_token('OIPL_ID',to_char(l_epe.oipl_id));
2266 fnd_message.set_token('PLIP_ID',to_char(l_epe.plip_id));
2267 fnd_message.set_token('PTIP_ID',to_char(l_epe.ptip_id));
2268 fnd_message.raise_error;
2269 --
2270 end if;
2271 --
2272 ben_derive_factors.determine_compensation
2273 (p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
2274 p_person_id => l_epe.person_id,
2275 p_pgm_id => l_epe.pgm_id ,
2276 p_pl_id => l_epe.pl_id,
2277 p_oipl_id => l_epe.oipl_id,
2278 p_per_in_ler_id => l_epe.per_in_ler_id,
2279 p_business_group_id => l_epe.business_group_id,
2280 p_perform_rounding_flg => true,
2281 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
2282 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
2283 p_calc_bal_to_date => null ,
2284 p_cal_for => 'R',
2285 p_value => l_compensation_value,
2286 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt);
2287 --
2288 if l_compensation_value is null /*or l_compensation_value = 0 commented for 3497676 */ then
2289 --
2290 open c_clf(l_cvg(0).comp_lvl_fctr_id);
2291 fetch c_clf into l_clf;
2292 close c_clf;
2293
2294 --
2295 fnd_message.set_name('BEN','BEN_92488_BENCVRGE_INVALID_VAL');
2296 fnd_message.set_token('PERSON_ID',l_epe.person_id);
2297 /*
2298 if l_clf.comp_src_cd = 'STTDCOMP' then
2299
2300 fnd_message.set_token('COMP_CODE',' stated Salary, '||l_clf.name);
2301
2302 elsif l_clf.comp_src_cd = 'BALTYP' then
2303
2304 fnd_message.set_token('COMP_CODE',' benefits balance, '||l_clf.name);
2305
2306 elsif l_clf.comp_src_cd = 'BNFTBALTYP' then
2307
2308 fnd_message.set_token('COMP_CODE',' defined balance, '||l_clf.name);
2309
2310 end if;
2311 */
2312 --
2313 fnd_message.set_token('COMP_FCTR',hr_general.decode_lookup
2314 ( p_lookup_type => 'BEN_COMP_SRC' ,
2315 p_lookup_code => l_clf.comp_src_cd
2316 )
2317 );
2318
2319 fnd_message.set_token('COMP_CODE',l_clf.name);
2320 fnd_message.set_token('PACKAGE',l_package);
2321 raise ben_manage_life_events.g_record_error;
2322 --
2323 end if;
2324 --
2325 end if;
2326 --
2327 hr_utility.set_location (' BDVR_MN ',10);
2328
2329 ben_determine_variable_rates.main -- FONM procedure have to take care of it
2330 (p_person_id => l_epe.person_id,
2331 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
2332 p_cvg_amt_calc_mthd_id => l_cvg(0).cvg_amt_calc_mthd_id,
2333 p_effective_date => p_effective_date,
2334 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
2335 p_val => l_vr_val, -- output
2336 p_mn_elcn_val => l_mn_elcn_val ,
2337 p_mx_elcn_val => l_mx_elcn_val,
2338 p_incrmnt_elcn_val => l_incrmnt_elcn_val,
2339 p_dflt_elcn_val => l_dflt_elcn_val , -- in coverage
2340 p_tx_typ_cd => l_dummy_char,
2341 p_acty_typ_cd => l_dummy_char,
2342 p_vrbl_rt_trtmt_cd => l_vr_trtmt_cd,
2343 p_ann_mn_elcn_val => l_vr_ann_mn_elcn_val,
2344 p_ann_mx_elcn_val => l_vr_ann_mx_elcn_val,
2345 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
2346 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
2347 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
2348 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl ); -- output
2349 hr_utility.set_location (' Dn BDVR_MN ',10);
2350 -- this variabl intialisation used to chek whether the benefit crossed the max limit
2351 -- in benefit write. if the vapro defined then then ultimate level is used
2352 -- if there is no vapro then benefit level used for the validation bug:1433393
2353
2354 hr_utility.set_location(' treatment code ' || l_vr_trtmt_cd ||' ' || l_vr_val , 999);
2355
2356 if l_vr_val is not null or l_vr_trtmt_cd is not null then
2357 l_vapro_exist := 'Y' ;
2358 --- Tilak : this code is not validating whether the enter at enrollemt is defined
2359 --- in either side ,(Coverage,VAPRO), this just work on the treatment code
2360 --- the User has to make sure both the side has the same setup like enter at enrollemt
2361 --
2362 if l_vr_trtmt_cd = 'RPLC' then
2363 l_perform_rounding_flg := false;
2364 l_mn_elcn_val := nvl(l_mn_elcn_val,l_cvg(0).mn_val) ;
2365 l_mx_elcn_val := nvl(l_mx_elcn_val,l_cvg(0).mx_val) ;
2366 l_incrmnt_elcn_val := nvl(l_incrmnt_elcn_val,l_cvg(0).incrmt_val );
2367 l_dflt_elcn_val := nvl(l_dflt_elcn_val , l_cvg(0).dflt_val );
2368
2369 elsif l_vr_trtmt_cd = 'ADDTO' then
2370
2371 l_mn_elcn_val := nvl(l_mn_elcn_val,0)+ nvl(l_cvg(0).mn_val,0) ;
2372 l_mx_elcn_val := nvl(l_mx_elcn_val,0)+ nvl(l_cvg(0).mx_val,0) ;
2373 l_incrmnt_elcn_val := nvl(l_incrmnt_elcn_val,0)+ nvl(l_cvg(0).incrmt_val,0);
2374 l_dflt_elcn_val := nvl(l_dflt_elcn_val,0)+ nvl(l_cvg(0).dflt_val,0 );
2375 elsif l_vr_trtmt_cd = 'SF' then
2376 l_mn_elcn_val := nvl(l_cvg(0).mn_val,0)-nvl(l_mn_elcn_val,0) ;
2377 l_mx_elcn_val := nvl(l_cvg(0).mx_val,0)-nvl(l_mx_elcn_val,0) ;
2378 l_incrmnt_elcn_val := nvl(l_cvg(0).incrmt_val,0)-nvl(l_incrmnt_elcn_val,0);
2379 l_dflt_elcn_val := nvl(l_cvg(0).dflt_val,0 )-nvl(l_dflt_elcn_val,0);
2380 elsif l_vr_trtmt_cd = 'MB' then
2381 -- here the code doesnt bother to check values are defined in both
2382 -- coverage and vapro, if the value are not defined either side
2383 -- multiply will return 0 , consider as setup error
2384
2385 l_mn_elcn_val := nvl(l_cvg(0).mn_val,0)*nvl(l_mn_elcn_val,0) ;
2386 l_mx_elcn_val := nvl(l_cvg(0).mx_val,0)*nvl(l_mx_elcn_val,0) ;
2387 l_incrmnt_elcn_val := nvl(l_cvg(0).incrmt_val,0)*nvl(l_incrmnt_elcn_val,0);
2388 l_dflt_elcn_val := nvl(l_cvg(0).dflt_val,0 )*nvl(l_dflt_elcn_val,0);
2389 else
2390 l_mn_elcn_val := l_cvg(0).mn_val ;
2391 l_mx_elcn_val := l_cvg(0).mx_val ;
2392 l_dflt_elcn_val := l_cvg(0).dflt_val ;
2393 l_incrmnt_elcn_val := l_cvg(0).incrmt_val ;
2394 end if;
2395 else
2396 l_mn_elcn_val := l_cvg(0).mn_val ;
2397 l_mx_elcn_val := l_cvg(0).mx_val ;
2398 l_dflt_elcn_val := l_cvg(0).dflt_val ;
2399 l_incrmnt_elcn_val := l_cvg(0).incrmt_val ;
2400
2401 ---
2402 end if ;
2403
2404 hr_utility.set_location('min max ' || l_mn_elcn_val ||' ' || l_mx_elcn_val|| ' '|| l_vapro_exist , 999);
2405 --
2406 l_ccm_max_val := l_mx_elcn_val; /* Bug 3828288 */
2407 --
2408 --Bug 6054310 -- This condition should only be there for NSVU
2409 --l_vr_val := nvl(l_vr_val, l_dflt_elcn_val); /* 5933576 - When vr_val is null, then set it to default val */
2410 --Bug 6054310
2411 --
2412 open c_asg(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date)));
2413 fetch c_asg into l_asg;
2414 close c_asg;
2415
2416 open c_state(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date)));
2417 fetch c_state into l_state;
2418 close c_state;
2419
2420 -- if l_state.region_2 is not null then
2421 -- l_jurisdiction_code :=
2422 -- pay_mag_utils.lookup_jurisdiction_code
2423 -- (p_state => l_state.region_2);
2424 -- end if;
2425
2426 hr_utility.set_location ('l_ler_id '||l_ler_id,55);
2427 hr_utility.set_location ('l_pl_id '||l_pl_id,55);
2428 hr_utility.set_location ('l_oipl_id '||l_oipl_id,55);
2429 hr_utility.set_location ('l_business_group_id '||l_business_group_id,55);
2430 hr_utility.set_location ('l_cvg(0).bnft_or_option_rstrctn_cd '||
2431 l_cvg(0).bnft_or_option_rstrctn_cd,33);
2432
2433 l_pl_id := l_epe.pl_id;
2434 l_ler_id := l_epe.ler_id;
2435 l_oipl_id := l_epe.oipl_id;
2436 l_business_group_id := l_epe.business_group_id;
2437 --
2438 -- We fetch Restrictions of both types 'BNFT' and 'OPT' as we always want
2439 -- to check the min/max benefit amount, even if the restriction says
2440 -- "Option Restriction Applies". (1198549)
2441 --
2442 open c_ler_rstrn( nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
2443 fetch c_ler_rstrn into l_rstrn;
2444 if c_ler_rstrn%notfound then
2445 hr_utility.set_location ('c_ler_rstrn not found ',33);
2446 close c_ler_rstrn;
2447
2448 open c_pl_rstrn( nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM;
2449 fetch c_pl_rstrn into l_rstrn;
2450
2451 if c_pl_rstrn%notfound then
2452 hr_utility.set_location ('c_pl_rstrn not found ',33);
2453 l_rstrn_found := false;
2454 else
2455 hr_utility.set_location ('c_pl_rstrn found ',33);
2456 hr_utility.set_location ('l_rstrn.ler_bnft_rstrn_id '||l_rstrn.ler_bnft_rstrn_id,33);
2457 l_rstrn_found := true;
2458 end if;
2459 close c_pl_rstrn;
2460 else
2461 hr_utility.set_location ('c_ler_rstrn found ',33);
2462 hr_utility.set_location ('l_rstrn.ler_bnft_rstrn_id '||l_rstrn.ler_bnft_rstrn_id,33);
2463 l_ler_bnft_rstrn_id := l_rstrn.ler_bnft_rstrn_id;
2464 l_rstrn_found := true;
2465 close c_ler_rstrn;
2466 end if;
2467 --
2468 /*
2469 l_cvg_rstn_max_wout_cert := l_rstrn.mx_cvg_alwd_amt; Bug 3828288
2470 l_cvg_rstn_max_with_cert := l_rstrn.mx_cvg_wcfn_amt; Bug 3828288
2471 */
2472 --
2473 /* Supriya Starts bug 5529258 */
2474
2475 l_DFLT_TO_ASN_PNDG_CTFN_CD := l_rstrn.dflt_to_asn_pndg_ctfn_cd;
2476
2477 If (l_DFLT_TO_ASN_PNDG_CTFN_CD = 'RL') then
2478
2479 if l_epe.oipl_id is not null
2480 then
2481
2482 open c_opt(l_epe.oipl_id, nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
2483 fetch c_opt into l_opt;
2484 close c_opt;
2485 end if;
2486
2487
2488
2489 l_dflt_to_asn_pndg_ctfn_cd :=
2490 ben_sspndd_enrollment.get_dflt_to_asn_pndg_ctfn_cd
2491 (p_dflt_to_asn_pndg_ctfn_rl => l_rstrn.dflt_to_asn_pndg_ctfn_rl
2492 ,p_person_id => l_epe.person_id
2493 ,p_per_in_ler_id => l_epe.per_in_ler_id
2494 ,p_assignment_id => l_asg.assignment_id
2495 ,p_organization_id => l_asg.organization_id
2496 ,p_business_group_id => l_epe.business_group_id
2497 ,p_pgm_id => l_epe.pgm_id
2498 ,p_pl_id => l_epe.pl_id
2499 ,p_pl_typ_id => l_epe.pl_typ_id
2500 ,p_opt_id => l_opt.opt_id
2501 ,p_ler_id => l_epe.ler_id
2502 ,p_jurisdiction_code => l_jurisdiction_code -- not needed just dummy
2503 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2504 ,p_effective_date => p_effective_date
2505 ,p_prtt_enrt_rslt_id => l_epe.prtt_enrt_rslt_id
2506 ,p_interim_epe_id => l_interim_elctbl_chc_id
2507 ,p_interim_bnft_amt => l_interim_bnft_amt
2508 );
2509
2510 hr_utility.set_location(' l_dflt_to_asn_pndg_ctfn_cd ' || l_dflt_to_asn_pndg_ctfn_cd,99095);
2511
2512 IF l_interim_elctbl_chc_id IS NOT NULL THEN
2513 --
2514 l_dflt_to_asn_pndg_ctfn_cd := null;
2515 hr_utility.set_location(' l_dflt_to_asn_pndg_ctfn_cd ' || l_dflt_to_asn_pndg_ctfn_cd,99096);
2516 --
2517 END IF;
2518 --
2519 l_rstrn.dflt_to_asn_pndg_ctfn_cd := l_DFLT_TO_ASN_PNDG_CTFN_CD ;
2520
2521 hr_utility.set_location('SSARAKR l_dflt_to_asn_pndg_ctfn_cd ' || l_rstrn.dflt_to_asn_pndg_ctfn_cd,99097);
2522
2523 End if;
2524
2525 /* Supriya Ends bug 5529258 */
2526
2527 if l_rstrn_found and l_rstrn.cvg_incr_r_decr_only_cd is not null then
2528 l_incr_r_decr_cd := l_rstrn.cvg_incr_r_decr_only_cd;
2529 else
2530 l_incr_r_decr_cd := l_cvg(0).cvg_incr_r_decr_only_cd;
2531 end if;
2532
2533 hr_utility.set_location ('l_incr_r_decr_cd '||l_incr_r_decr_cd,33);
2534 --
2535 -- We check increases only if the restriction code is 'BNFT', so make
2536 -- the "increases" values nulll.
2537 --
2538 if l_rstrn_found and
2539 (l_cvg(0).bnft_or_option_rstrctn_cd is null or
2540 l_cvg(0).bnft_or_option_rstrctn_cd = 'OPT') then
2541 --
2542 l_rstrn.mx_cvg_mlt_incr_num := null;
2543 l_rstrn.mx_cvg_mlt_incr_wcf_num := null;
2544 l_rstrn.mx_cvg_incr_alwd_amt := null;
2545 l_rstrn.mx_cvg_incr_wcf_alwd_amt := null;
2546 --
2547 end if;
2548 --
2549 hr_utility.set_location (' open c_current_enrt ',10);
2550 open c_current_enrt(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM;
2551 fetch c_current_enrt into l_crnt_ordr_num,
2552 l_bnft_amt,
2553 l_current_enrt_present;
2554 close c_current_enrt;
2555 --
2556 if NVL(l_current_enrt_present,'N') = 'N' then
2557 --
2558 open c_current_enrt_sspndd(nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date)));
2559 fetch c_current_enrt_sspndd into l_current_enrt_sspndd ;
2560 close c_current_enrt_sspndd;
2561 --
2562 end if;
2563 -- get the dflt_enrt_cd/rule
2564 --
2565 ben_enrolment_requirements.determine_dflt_enrt_cd(
2566 p_oipl_id =>l_epe.oipl_id,
2567 p_plip_id =>l_epe.plip_id,
2568 p_pl_id =>l_epe.pl_id,
2569 p_ptip_id =>l_epe.ptip_id,
2570 p_pgm_id =>l_epe.pgm_id,
2571 p_ler_id =>l_epe.ler_id,
2572 p_dflt_enrt_cd =>l_dflt_enrt_cd,
2573 p_dflt_enrt_rl =>l_dflt_enrt_rl,
2574 p_business_group_id =>l_epe.business_group_id,
2575 p_effective_date => nvl(l_fonm_cvg_strt_dt, l_effective_date) -- FONM how this is used.
2576 );
2577
2578 --- the dflt_enrt_cd is rule and global variable g_dflt_elcn_val has got value
2579 --- then use the value for l_dflt_elcn_val
2580 if l_dflt_enrt_cd = 'RL' and ben_enrolment_requirements.g_dflt_elcn_val is not null then
2581 l_dflt_elcn_val:=ben_enrolment_requirements.g_dflt_elcn_val;
2582 --- once the value used nullify the value
2583 hr_utility.set_location ('formula default='||ben_enrolment_requirements.g_dflt_elcn_val,744);
2584 ben_enrolment_requirements.g_dflt_elcn_val := null ;
2585 end if ;
2586 --
2587 -- if this choice is a default and dflt_enrt_cd says
2588 -- keep same coverage then use the current benefit amount
2589 -- as the default.
2590 --
2591 if (l_dflt_enrt_cd in ('NSDCS','NNCS') and
2592 l_epe.dflt_flag='Y' and
2593 l_bnft_amt is not null) then
2594 hr_utility.set_location ('dflt_val='||l_bnft_amt,10);
2595 l_dflt_elcn_val:= l_bnft_amt;
2596 end if;
2597 --
2598 l_cvg_amount := l_bnft_amt;
2599 hr_utility.set_location (' Dn EPE ELSIFs ',10);
2600 if l_cvg(0).cvg_mlt_cd = 'FLFX' then
2601 --
2602 l_ctfn_rqd := 'N';
2603 l_write_rec := true;
2604 --
2605 l_val := round_val(
2606 p_val => l_cvg(0).val,
2607 p_effective_date => p_effective_date,
2608 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
2609 p_rndg_cd => l_cvg(0).rndg_cd,
2610 p_rndg_rl => l_cvg(0).rndg_rl
2611 );
2612 l_cvg_amount := l_val ;
2613 --
2614 ---bug validate the limit for benefir amount
2615 hr_utility.set_location ('limit_checks ' ,10);
2616 benutils.limit_checks
2617 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
2618 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
2619 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
2620 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
2621 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
2622 p_assignment_id => l_asg.assignment_id,
2623 p_organization_id => l_asg.organization_id,
2624 p_business_group_id => l_epe.business_group_id,
2625 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
2626 p_pgm_id => l_epe.pgm_id,
2627 p_pl_id => l_epe.pl_id,
2628 p_pl_typ_id => l_epe.pl_typ_id,
2629 p_opt_id => l_opt.opt_id,
2630 p_ler_id => l_epe.ler_id,
2631 p_val => l_val,
2632 p_state => l_state.region_2);
2633
2634 hr_utility.set_location (' CMC FLFX ',10);
2635 --
2636 ben_determine_coverage.combine_with_variable_val
2637 (p_vr_val => l_vr_val,
2638 p_val => l_val,
2639 p_vr_trtmt_cd => l_vr_trtmt_cd,
2640 p_combined_val => l_combined_val);
2641 --
2642 --rtagarra
2643 --
2644 hr_utility.set_location ('l_dflt_enrt_cd'||l_dflt_enrt_cd,353235);
2645 hr_utility.set_location ('FLAG' || l_cvg(0).entr_val_at_enrt_flag,23542345);
2646 hr_utility.set_location ('l_bnft_amt ' ||l_bnft_amt,34534);
2647 hr_utility.set_location ('l_combined_val ' || l_combined_val,345345);
2648 --
2649 if l_dflt_enrt_cd in ('NSDCS','NNCS','NDCSEDR','NNCSEDR') and l_cvg(0).entr_val_at_enrt_flag = 'Y' then
2650 --
2651 hr_utility.set_location ('INSIDE 1 IF',53453245);
2652 --
2653 if l_bnft_amt is not null then
2654 --
2655 hr_utility.set_location ('INSIDE 2 IF',53453245);
2656 if l_bnft_amt between l_cvg(0).mn_val and l_cvg(0).mx_val then
2657 --
2658 hr_utility.set_location ('INSIDE 3 IF',53453245);
2659 l_combined_val := l_bnft_amt ;
2660 --
2661 end if;
2662 --
2663 end if;
2664 --
2665 end if;
2666 --rtagarra
2667 if l_rstrn_found then
2668 --
2669 ben_determine_coverage.chk_bnft_ctfn
2670 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
2671 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
2672 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
2673 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
2674 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
2675 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
2676 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
2677 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
2678 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
2679 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
2680 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
2681 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
2682 p_combined_val => l_combined_val,
2683 p_crnt_bnft_amt => l_bnft_amt,
2684 p_ordr_num => l_order_number,
2685 p_crnt_ordr_num => l_crnt_ordr_num,
2686 p_ctfn_rqd => l_ctfn_rqd,
2687 p_write_rec => l_write_rec,
2688 p_effective_date => nvl(p_lf_evt_ocrd_dt,
2689 p_effective_date),
2690 p_assignment_id => l_asg.assignment_id,
2691 p_organization_id => l_asg.organization_id,
2692 p_business_group_id => l_epe.business_group_id,
2693 p_pgm_id => l_epe.pgm_id,
2694 p_pl_id => l_epe.pl_id,
2695 p_pl_typ_id => l_epe.pl_typ_id,
2696 p_opt_id => l_opt.opt_id,
2697 p_ler_id => l_epe.ler_id,
2698 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
2699 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
2700 p_jurisdiction_code => l_jurisdiction_code,
2701 p_check_received => l_check_received,
2702 /* Start of Changes for WWBUG: 2054708 added parameter */
2703 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
2704 /* End of Changes for WWBUG: 2054708 added parameter */
2705 --Bug 4644489
2706 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
2707 --End Bug 4644489
2708 --
2709 end if;
2710 --
2711 --BUG 4627840 -- We are ignoring the rule here.
2712 --
2713 hr_utility.set_location(' l_rstrn.mx_cvg_alwd_amt '||l_rstrn.mx_cvg_alwd_amt,189);
2714 hr_utility.set_location(' l_mx_cvg_wout_ctfn_val '||l_mx_cvg_wout_ctfn_val,189);
2715 hr_utility.set_location(' l_rstrn.mx_cvg_wcfn_amt '||l_rstrn.mx_cvg_wcfn_amt,189);
2716 --
2717 l_cvg_rstn_max_wout_cert := nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val);
2718 l_cvg_rstn_max_with_cert := l_rstrn.mx_cvg_wcfn_amt;
2719 --
2720 /* if already enrolled, check there is any increases restriction */
2721 if l_write_rec then
2722 if l_bnft_amt is not null then
2723 --BUG 4223840
2724
2725 --Bug 5236985 Added the l_cvg_rstn_max_with_cert not null condition
2726 --This necessary if the l_rstrn.mx_cvg_wcfn_amt is made null in the subsequent life events
2727 if l_cvg(0).entr_val_at_enrt_flag = 'Y' and l_bnft_amt > l_cvg_rstn_max_wout_cert and l_cvg_rstn_max_with_cert is not null then
2728 l_cvg_rstn_max_wout_cert := l_bnft_amt ;
2729 hr_utility.set_location('l_bnft_amt '||l_bnft_amt,188);
2730 hr_utility.set_location('l_cvg_rstn_max_wout_cert '||l_cvg_rstn_max_wout_cert,188);
2731 end if;
2732 --
2733 if l_rstrn.mx_cvg_incr_alwd_amt is not null then
2734 l_cvg_rstn_max_wout_cert := l_bnft_amt + l_rstrn.mx_cvg_incr_alwd_amt;
2735 l_cvg_rstn_max_incr_wout_cert := l_bnft_amt + l_rstrn.mx_cvg_incr_alwd_amt; /* Bug 3828288 */
2736 end if;
2737 if l_rstrn.mx_cvg_incr_wcf_alwd_amt is not null then
2738 l_rstrn.mx_cvg_wcfn_amt := l_bnft_amt + l_rstrn.mx_cvg_incr_wcf_alwd_amt ;
2739 l_cvg_rstn_max_incr_with_cert := l_bnft_amt + l_rstrn.mx_cvg_incr_wcf_alwd_amt ; /* Bug 3828288 */
2740 end if;
2741 end if;
2742 end if;
2743 hr_utility.set_location('crtfn ' || l_rstrn.mx_cvg_wcfn_amt,199);
2744 hr_utility.set_location('min val ' || l_mn_elcn_val,199);
2745 hr_utility.set_location('max val ' || l_mx_elcn_val,199);
2746 --
2747 if l_write_rec then
2748 --
2749 -- Bug 3828288
2750 -- For Flat Amount Calc Method consider
2751 -- Max Amount (L_MX_VAL_WO_CFN) as minimum of
2752 -- (1) P_CCM_MAX_VAL - Coverage Calc Method Max Value
2753 -- (2) P_CVG_RSTN_MAX_WOUT_CERT - Plan Coverage Restrictions - Max ,
2754 -- (3) P_CVG_RSTN_MAX_INCR_WOUT_CERT - Current + Plan Coverage Restriction Max Increase
2755 -- Max Amount With Certification (L_MX_VAL_WCFN) as minimum of
2756 -- (1) P_CCM_MAX_VAL - Coverage Calc Method Max Value
2757 -- (2) P_CVG_RSTN_MAX_WITH_CERT - Plan Coverage Restrictions - Max with Certification ,
2758 -- (3) P_CVG_RSTN_MAX_INCR_WITH_CERT - Current + Plan Coverage Restriction Max Increase with Certification
2759 --
2760 --bug#4256191 least of ultmt_upr_lmt, max value passed
2761 if l_ultmt_upr_lmt_calc_rl is not null then
2762 --
2763 l_upr_outputs := benutils.formula
2764 (p_formula_id => l_ultmt_upr_lmt_calc_rl,
2765 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
2766 p_assignment_id => l_asg.assignment_id,
2767 p_organization_id => l_asg.organization_id,
2768 p_business_group_id => l_epe.business_group_id,
2769 p_pgm_id => l_epe.pgm_id,
2770 p_pl_id => l_epe.pl_id,
2771 p_pl_typ_id => l_epe.pl_typ_id,
2772 p_opt_id => l_opt.opt_id,
2773 p_ler_id => l_epe.ler_id,
2774 -- FONM
2775 p_param1 => 'BEN_IV_RT_STRT_DT',
2776 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
2777 p_param2 => 'BEN_IV_CVG_STRT_DT',
2778 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt),
2779 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id);
2780 --
2781 if l_upr_outputs(l_upr_outputs.first).value is not null then
2782 --
2783 l_ultmt_upr_lmt := fnd_number.canonical_to_number(l_upr_outputs(l_upr_outputs.first).value);
2784 --
2785 end if;
2786 --
2787
2788 end if;
2789 get_least_value ( p_ccm_max_val =>
2790 least(l_ccm_max_val,nvl(l_ultmt_upr_lmt,l_ccm_max_val)),
2791 p_cvg_rstn_max_incr_with_cert => nvl(l_cvg_rstn_max_incr_with_cert,l_cvg_rstn_max_incr_wout_cert),/* bug 4275929 ::max_incr_with_cert= max_incr_wout_certificate when max_incr_with_certificate is NUll */
2792 p_cvg_rstn_max_with_cert => nvl(l_cvg_rstn_max_with_cert,l_cvg_rstn_max_wout_cert),/* bug 4275929 :: max_with_certificate= max_wout_certificate when max_with_certificate is NUll */
2793 p_cvg_rstn_max_incr_wout_cert => l_cvg_rstn_max_incr_wout_cert,
2794 p_cvg_rstn_max_wout_cert => l_cvg_rstn_max_wout_cert,
2795 p_mx_val_wcfn => l_mx_val_wcfn,
2796 p_mx_val_wo_cfn => l_mx_val_wo_cfn
2797 );
2798 hr_utility.set_location('l_ultmt_lwr_lmt_calc_rl = ' || l_ultmt_lwr_lmt_calc_rl, 9999);
2799 if l_ultmt_lwr_lmt_calc_rl is not null then
2800 --
2801 l_ult_lwr_outputs := benutils.formula
2802 (p_formula_id => l_ultmt_lwr_lmt_calc_rl,
2803 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
2804 p_assignment_id => l_asg.assignment_id,
2805 p_organization_id => l_asg.organization_id,
2806 p_business_group_id => l_epe.business_group_id,
2807 p_pgm_id => l_epe.pgm_id,
2808 p_pl_id => l_epe.pl_id,
2809 p_pl_typ_id => l_epe.pl_typ_id,
2810 p_opt_id => l_opt.opt_id,
2811 p_ler_id => l_epe.ler_id,
2812 -- FONM
2813 p_param1 => 'BEN_IV_RT_STRT_DT',
2814 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
2815 p_param2 => 'BEN_IV_CVG_STRT_DT',
2816 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt),
2817 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id);
2818 --
2819 if l_ult_lwr_outputs(l_ult_lwr_outputs.first).value is not null then
2820 --
2821 l_ultmt_lwr_lmt := fnd_number.canonical_to_number(l_ult_lwr_outputs(l_ult_lwr_outputs.first).value);
2822 --
2823 end if;
2824 --
2825 end if;
2826
2827 l_mn_elcn_val :=
2828 greatest(l_mn_elcn_val, greatest(nvl(l_rstrn_mn_cvg_rqd_amt,l_mn_elcn_val),nvl(l_ultmt_lwr_lmt,l_mn_elcn_val)));
2829
2830 --Bug 4644489
2831 --Write to the Benifts record the minimum coverage value as max(cvg_restrn_mn_amnt,cvg_calc_method)
2832 -- if (l_rstrn_mn_cvg_rqd_amt > l_mn_elcn_val) then
2833 -- l_mn_elcn_val := l_rstrn_mn_cvg_rqd_amt;
2834 -- end if;
2835 --End Bug 4644489
2836 hr_utility.set_location('l_mn_elcn_val = ' || l_mn_elcn_val, 9999);
2837 hr_utility.set_location('l_ultmt_lwr_lmt = ' || l_ultmt_lwr_lmt, 9999);
2838 hr_utility.set_location('l_rstrn_mn_cvg_rqd_amt = ' || l_rstrn_mn_cvg_rqd_amt, 9999);
2839 hr_utility.set_location('l_mx_val_wcfn = ' || l_mx_val_wcfn, 9999);
2840 hr_utility.set_location('l_mx_val_wo_cfn = ' || l_mx_val_wo_cfn, 9999);
2841 -- Bug 3828288
2842 hr_utility.set_location('l_combined_val = ' || l_combined_val, 9999);
2843 hr_utility.set_location('l_cvg_amount = ' || l_cvg_amount, 9999);
2844 hr_utility.set_location('l_dflt_elcn_val = ' || l_dflt_elcn_val, 9999);
2845 --
2846 ben_determine_coverage.write_coverage
2847 (p_calculate_only_mode => p_calculate_only_mode,
2848 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
2849 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
2850 p_val => l_combined_val,
2851 p_dflt_flag => l_epe.dflt_flag,
2852 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
2853 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
2854 p_business_group_id => l_cvg(0).business_group_id,
2855 p_effective_date => p_effective_date,
2856 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
2857 p_person_id => l_epe.person_id,
2858 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
2859 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
2860 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
2861 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
2862 p_rndg_cd => l_cvg(0).rndg_cd,
2863 p_rndg_rl => l_cvg(0).rndg_rl,
2864 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
2865 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
2866 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
2867 /* Code Prior To 3828288 Fix
2868 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt,l_mx_elcn_val),--mx withctfn,vapro
2869 */
2870 p_mx_val => l_mx_val_wcfn, /* Bug 3828288 */
2871 /*
2872 CODE PRIOR TO WWBUG: 2054078
2873 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
2874 */
2875 /* Start of Changes for WWBUG: 2054078 */
2876 /* Code Prior To 3828288 Fix
2877 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
2878 */
2879 p_mx_wout_ctfn_val => l_mx_val_wo_cfn, /* Bug 3828288 */
2880 /* End of Changes for WWBUG: 2054078 */
2881 p_mn_val => l_mn_elcn_val,
2882 p_incrmt_val => l_incrmnt_elcn_val,
2883 p_dflt_val => l_dflt_elcn_val,
2884 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
2885 p_perform_rounding_flg => l_perform_rounding_flg,
2886 p_ordr_num => l_order_number,
2887 p_ctfn_rqd_flag => l_ctfn_rqd,
2888 p_enrt_bnft_id => l_enrt_bnft_id,
2889 p_enb_valrow => p_enb_valrow,
2890 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
2891 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
2892 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
2893 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
2894 p_bnft_amount => l_cvg_amount,
2895 p_vapro_exist => l_vapro_exist
2896 );
2897 --
2898 if l_ctfn_rqd = 'Y' then
2899 --
2900 write_ctfn;
2901 --
2902 end if;
2903
2904
2905 hr_utility.set_location('benefit row'||l_cvg(0).bnft_or_option_rstrctn_cd,111);
2906 hr_utility.set_location('oipl id '||l_epe.oipl_id,111);
2907
2908 if l_rstrn_found and l_cvg(0).bnft_or_option_rstrctn_cd = 'BNFT' and
2909 l_cvg(0).entr_val_at_enrt_flag = 'Y' then
2910 -- if l_epe.oipl_id is null then /*ENH*/
2911 -- This is required only for enter value at enrollment case
2912 -- ENH We need to populate the right bnft_amout depending on the
2913 -- Interim Codes Min,Next Lower and Default Codes defined at the
2914 -- Plan Level . We will determine
2915 --
2916 l_interim_cd := substr(l_rstrn.dflt_to_asn_pndg_ctfn_cd,4,2) ;
2917 l_current_level_cd := substr(l_rstrn.dflt_to_asn_pndg_ctfn_cd,2,2);
2918 --
2919 l_current_plan_id := null ;
2920 l_current_oipl_id := null ;
2921 l_create_current_enb := false ;
2922 --
2923 if l_current_level_cd = 'AS' then
2924 --
2925 open c_current_enrt_in_pl_typ(l_epe.pl_typ_id,
2926 nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date))) ; -- FONM
2927 fetch c_current_enrt_in_pl_typ into l_current_plan_id,l_current_oipl_id ;
2928 if c_current_enrt_in_pl_typ%found then
2929 l_create_current_enb := true ;
2930 end if;
2931 close c_current_enrt_in_pl_typ;
2932 --
2933 elsif l_current_level_cd = 'SE' then
2934 open c_current_enrt_in_pln(l_epe.pl_id, nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))) ; -- FONM
2935 fetch c_current_enrt_in_pln into l_current_plan_id,l_current_oipl_id ;
2936 if c_current_enrt_in_pln%found then
2937 l_create_current_enb := true ;
2938 end if;
2939 close c_current_enrt_in_pln;
2940 elsif l_current_level_cd = 'SO' then
2941 -- Bug 2543071 changed the l_epe.pl_id to l_epe.oipl_id and added
2942 -- the if condition.
2943 if l_epe.oipl_id is not null then
2944 open c_current_enrt_in_oipl(l_epe.oipl_id, nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))) ; -- FONM
2945 fetch c_current_enrt_in_oipl into l_current_plan_id,l_current_oipl_id ;
2946 if c_current_enrt_in_oipl%found then
2947 l_create_current_enb := true ;
2948 end if;
2949 close c_current_enrt_in_oipl;
2950 end if;
2951 end if;
2952 ---------------
2953 hr_utility.set_location (' open c_current_enrt ',10);
2954 --open c_current_enrt_in_pln(l_epe.pl_id) ;
2955 -- fetch c_current_enrt_in_pln into l_current_plan_id,l_current_oipl_id ;
2956 --
2957 -- if c_current_enrt_in_pln%found then
2958 if l_create_current_enb then
2959 -- Take the current case
2960 l_interim_cd := substr(l_rstrn.dflt_to_asn_pndg_ctfn_cd,4,2);
2961 else
2962 -- Take the new case
2963 l_interim_cd := substr(l_rstrn.dflt_to_asn_pndg_ctfn_cd,7,2);
2964 end if;
2965 --
2966 if l_interim_cd = 'MN' then
2967 l_interim_bnft_val := l_mn_elcn_val ;
2968 elsif l_interim_cd = 'NL' then
2969 l_interim_bnft_val := nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val) ;
2970 elsif l_interim_cd = 'DF' then
2971 l_interim_bnft_val := l_dflt_elcn_val ;
2972 else -- for Same and Nothing we need not populate this amount
2973 l_interim_bnft_val := null ; -- l_dflt_elcn_val ;
2974 end if ;
2975 --close c_current_enrt_in_pln;
2976 --
2977 hr_utility.set_location('interim row',111);
2978 --CF Changes
2979 --
2980 if l_current_plan_id = l_epe.pl_id and
2981 nvl(l_current_oipl_id,-1) = nvl(l_epe.oipl_id,-1) then
2982 --
2983 open c_current_enb(l_epe.pl_id,l_epe.oipl_id,
2984 nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date))) ;
2985 fetch c_current_enb into l_current_enb ;
2986 --
2987 close c_current_enb ;
2988 --
2989 end if;
2990 --
2991 l_enrt_bnft_id := null;
2992 open c_unrest(l_epe.ler_id);
2993 fetch c_unrest into l_dummy;
2994 close c_unrest;
2995 if l_dummy = 'Y' then
2996 l_enrt_bnft_id := ben_manage_unres_life_events.enb_exists
2997 (p_elig_per_elctbl_chc_id,0);
2998 end if;
2999 if not p_calculate_only_mode then
3000 --
3001 if l_enrt_bnft_id is not null then
3002 --
3003 ben_manage_unres_life_events.update_enrt_bnft
3004 (p_dflt_flag => 'N',
3005 p_val_has_bn_prortd_flag => 'N', -- change when prorating
3006 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3007 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3008 p_val => l_interim_bnft_val, -- l_rstrn.mx_cvg_alwd_amt, /*ENH */
3009 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3010 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3011 p_prtt_enrt_rslt_id => null,
3012 p_business_group_id => l_cvg(0).business_group_id,
3013 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3014 p_program_application_id => fnd_global.prog_appl_id,
3015 p_program_id => fnd_global.conc_program_id,
3016 p_request_id => fnd_global.conc_request_id,
3017 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
3018 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
3019 p_crntly_enrld_flag => 'N',
3020 p_ctfn_rqd_flag => 'N',
3021 p_entr_val_at_enrt_flag => 'N',
3022 p_mx_val => null, -- max with ctfn
3023 p_mx_wout_ctfn_val => null, -- max without ctfn
3024 p_mn_val => null,
3025 p_incrmt_val => null,
3026 p_dflt_val => null,
3027 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3028 p_mx_wo_ctfn_flag => 'Y',
3029 p_program_update_date => sysdate,
3030 p_enrt_bnft_id => l_enrt_bnft_id,
3031 p_ordr_num => 0);
3032 --
3033 else
3034 --
3035 ben_enrt_bnft_api.create_enrt_bnft
3036 (p_validate => false,
3037 p_dflt_flag => 'N',
3038 p_val_has_bn_prortd_flag => 'N', -- change when prorating
3039 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3040 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3041 p_val => l_interim_bnft_val, -- l_rstrn.mx_cvg_alwd_amt, /*ENH */
3042 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3043 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3044 p_prtt_enrt_rslt_id => l_current_enb.prtt_enrt_rslt_id , -- CF null,
3045 p_business_group_id => l_cvg(0).business_group_id,
3046 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3047 p_program_application_id => fnd_global.prog_appl_id,
3048 p_program_id => fnd_global.conc_program_id,
3049 p_request_id => fnd_global.conc_request_id,
3050 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
3051 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
3052 p_crntly_enrld_flag => 'N',
3053 p_ctfn_rqd_flag => 'N',
3054 p_entr_val_at_enrt_flag => 'N',
3055 p_mx_val => null, -- max with ctfn
3056 p_mx_wout_ctfn_val => null, -- max without ctfn
3057 p_mn_val => null,
3058 p_incrmt_val => null,
3059 p_dflt_val => null,
3060 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3061 p_mx_wo_ctfn_flag => 'Y',
3062 p_program_update_date => sysdate,
3063 p_enrt_bnft_id => l_enrt_bnft_id,
3064 p_object_version_number => l_object_version_number,
3065 p_ordr_num => 0);
3066 --
3067 end if;
3068 --
3069 end if;
3070 --
3071 end if;
3072 --
3073 l_current_enb := null ;
3074 --
3075 else
3076 --
3077 -- Update the electable choice to be not electable
3078 --
3079 if l_epe.elctbl_flag='Y' then
3080 --
3081 -- Check for calculate only mode
3082 --
3083 if not p_calculate_only_mode then
3084 --
3085 ben_elig_per_elc_chc_api.update_perf_elig_per_elc_chc(
3086 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3087 p_elctbl_flag => 'N',
3088 p_dflt_flag => 'N',
3089 p_object_version_number => l_epe.object_version_number,
3090 p_effective_date => p_effective_date,
3091 p_program_application_id => fnd_global.prog_appl_id,
3092 p_program_id => fnd_global.conc_program_id,
3093 p_request_id => fnd_global.conc_request_id,
3094 p_program_update_date => sysdate
3095 );
3096 --
3097 -- If enrolled will deenroll.
3098 --
3099 ben_newly_ineligible.main(
3100 p_person_id => l_epe.person_id,
3101 p_pgm_id => l_epe.pgm_id,
3102 p_pl_id => l_epe.pl_id,
3103 p_oipl_id => l_epe.oipl_id,
3104 p_business_group_id => l_epe.business_group_id,
3105 p_ler_id => l_epe.ler_id,
3106 p_effective_date => p_effective_date -- FONM proc take care of it.
3107 );
3108 --
3109 end if;
3110 l_epe.elctbl_flag:='N';
3111 hr_utility.set_location('Electable choice was made not electable by bencvrge',29);
3112 end if;
3113 ben_determine_coverage.write_coverage
3114 (p_calculate_only_mode => p_calculate_only_mode,
3115 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3116 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3117 p_val => l_combined_val,
3118 p_dflt_flag => l_epe.dflt_flag,
3119 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3120 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3121 p_business_group_id => l_cvg(0).business_group_id,
3122 p_effective_date => p_effective_date,
3123 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3124 p_person_id => l_epe.person_id,
3125 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3126 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3127 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3128 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3129 p_rndg_cd => l_cvg(0).rndg_cd,
3130 p_rndg_rl => l_cvg(0).rndg_rl,
3131 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
3132 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
3133 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
3134 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_mx_elcn_val), -- mx with ctfn
3135 /*
3136 CODE PRIOR TO WWBUG: 2054078
3137 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
3138 */
3139 /* Start of Changes for WWBUG: 2054078 */
3140 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
3141 /* End of Changes for WWBUG: 2054078 */
3142 p_mn_val => l_mn_elcn_val,
3143 p_incrmt_val => l_incrmnt_elcn_val,
3144 p_dflt_val => l_dflt_elcn_val,
3145 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3146 p_perform_rounding_flg => l_perform_rounding_flg,
3147 p_ordr_num => l_order_number,
3148 p_ctfn_rqd_flag => l_ctfn_rqd,
3149 p_enrt_bnft_id => l_enrt_bnft_id,
3150 p_enb_valrow => p_enb_valrow,
3151 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
3152 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
3153 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
3154 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
3155 p_bnft_amount => l_cvg_amount,
3156 p_vapro_exist => l_vapro_exist
3157 );
3158 --
3159 end if;
3160 --
3161 elsif l_cvg(0).cvg_mlt_cd = 'CL' then
3162 --
3163 l_ctfn_rqd := 'N';
3164 l_write_rec := true;
3165 --
3166 hr_utility.set_location (' CMC CL ',10);
3167 benutils.rt_typ_calc
3168 (p_val => l_cvg(0).val,
3169 p_val_2 => l_compensation_value,
3170 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3171 p_calculated_val => l_calculated_val);
3172 --
3173 l_val := round_val(
3174 p_val => l_calculated_val,
3175 p_effective_date => p_effective_date,
3176 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3177 p_rndg_cd => l_cvg(0).rndg_cd,
3178 p_rndg_rl => l_cvg(0).rndg_rl
3179 );
3180 --
3181 l_cvg_amount := l_val ;
3182 ---bug validate the limit for benefir amount
3183 hr_utility.set_location ('limit_checks ',10);
3184 benutils.limit_checks
3185 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3186 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3187 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3188 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3189 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3190 p_assignment_id => l_asg.assignment_id,
3191 p_organization_id => l_asg.organization_id,
3192 p_business_group_id => l_epe.business_group_id,
3193 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3194 p_pgm_id => l_epe.pgm_id,
3195 p_pl_id => l_epe.pl_id,
3196 p_pl_typ_id => l_epe.pl_typ_id,
3197 p_opt_id => l_opt.opt_id,
3198 p_ler_id => l_epe.ler_id,
3199 p_val => l_val,
3200 p_state => l_state.region_2);
3201
3202 ---
3203 hr_utility.set_location (' rndg is'||l_val,10);
3204 ben_determine_coverage.combine_with_variable_val
3205 (p_vr_val => l_vr_val,
3206 p_val => l_val,
3207 p_vr_trtmt_cd => l_vr_trtmt_cd,
3208 p_combined_val => l_combined_val);
3209 --
3210 hr_utility.set_location (' varb is'||l_combined_val,10);
3211 --
3212 if l_rstrn_found then
3213 --
3214 ben_determine_coverage.chk_bnft_ctfn
3215 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
3216 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
3217 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
3218 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
3219 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
3220 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
3221 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
3222 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
3223 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
3224 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
3225 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
3226 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
3227 p_combined_val => l_combined_val,
3228 p_crnt_bnft_amt => l_bnft_amt,
3229 p_ordr_num => l_order_number,
3230 p_crnt_ordr_num => l_crnt_ordr_num,
3231 p_ctfn_rqd => l_ctfn_rqd,
3232 p_write_rec => l_write_rec,
3233 p_effective_date => nvl(p_lf_evt_ocrd_dt,
3234 p_effective_date),
3235 p_assignment_id => l_asg.assignment_id,
3236 p_organization_id => l_asg.organization_id,
3237 p_business_group_id => l_epe.business_group_id,
3238 p_pgm_id => l_epe.pgm_id,
3239 p_pl_id => l_epe.pl_id,
3240 p_pl_typ_id => l_epe.pl_typ_id,
3241 p_opt_id => l_opt.opt_id,
3242 p_ler_id => l_epe.ler_id,
3243 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3244 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
3245 p_jurisdiction_code => l_jurisdiction_code,
3246 p_check_received => l_check_received,
3247 /* Start of Changes for WWBUG: 2054078 added parameter */
3248 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
3249 /* End of Changes for WWBUG: 2054078 added parameter */
3250 --Bug 4644489
3251 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
3252 --End Bug 4644489
3253 --
3254 end if;
3255 --
3256 if l_write_rec then
3257 --
3258 ben_determine_coverage.write_coverage
3259 (p_calculate_only_mode => p_calculate_only_mode,
3260 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3261 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3262 p_val => l_combined_val,
3263 p_dflt_flag => l_epe.dflt_flag,
3264 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3265 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3266 p_business_group_id => l_cvg(0).business_group_id,
3267 p_effective_date => p_effective_date,
3268 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3269 p_person_id => l_epe.person_id,
3270 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3271 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3272 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3273 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3274 p_rndg_cd => l_cvg(0).rndg_cd,
3275 p_rndg_rl => l_cvg(0).rndg_rl,
3276 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
3277 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
3278 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
3279 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
3280 /*
3281 CODE PRIOR TO WWBUG: 2054078
3282 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
3283 */
3284 /* Start of Changes for WWBUG: 2054078 */
3285 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
3286 /* End of Changes for WWBUG: 2054078 */
3287 p_mn_val => l_cvg(0).mn_val,
3288 p_incrmt_val => l_cvg(0).incrmt_val,
3289 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3290 p_dflt_val => NVL(l_dflt_elcn_val,l_cvg(0).dflt_val),
3291 p_perform_rounding_flg => l_perform_rounding_flg,
3292 p_ordr_num => l_order_number,
3293 p_ctfn_rqd_flag => l_ctfn_rqd,
3294 p_enrt_bnft_id => l_enrt_bnft_id,
3295 p_enb_valrow => p_enb_valrow,
3296 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
3297 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
3298 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
3299 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
3300 p_bnft_amount => l_cvg_amount,
3301 p_vapro_exist => l_vapro_exist
3302 );
3303 --
3304 if l_ctfn_rqd = 'Y'
3305 and not p_calculate_only_mode
3306 then
3307 --
3308 write_ctfn;
3309 --
3310 end if;
3311 --
3312 else
3313 --
3314 -- Update the electable choice to be not electable
3315 --
3316 if l_epe.elctbl_flag='Y' then
3317 --
3318 if not p_calculate_only_mode then
3319 --
3320 ben_elig_per_elc_chc_api.update_perf_elig_per_elc_chc(
3321 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3322 p_elctbl_flag => 'N',
3323 p_dflt_flag => 'N',
3324 p_object_version_number => l_epe.object_version_number,
3325 p_effective_date => p_effective_date,
3326 p_program_application_id => fnd_global.prog_appl_id,
3327 p_program_id => fnd_global.conc_program_id,
3328 p_request_id => fnd_global.conc_request_id,
3329 p_program_update_date => sysdate
3330 );
3331 --
3332 -- If enrolled will deenroll.
3333 --
3334 ben_newly_ineligible.main(
3335 p_person_id => l_epe.person_id,
3336 p_pgm_id => l_epe.pgm_id,
3337 p_pl_id => l_epe.pl_id,
3338 p_oipl_id => l_epe.oipl_id,
3339 p_business_group_id => l_epe.business_group_id,
3340 p_ler_id => l_epe.ler_id,
3341 p_effective_date => p_effective_date
3342 );
3343 --
3344 end if;
3345 --
3346 l_epe.elctbl_flag:='N';
3347 hr_utility.set_location('Electable choice was made not electable by bencvrge',29);
3348 end if;
3349 ben_determine_coverage.write_coverage
3350 (p_calculate_only_mode => p_calculate_only_mode,
3351 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3352 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3353 p_val => l_combined_val,
3354 p_dflt_flag => l_epe.dflt_flag,
3355 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3356 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3357 p_business_group_id => l_cvg(0).business_group_id,
3358 p_effective_date => p_effective_date,
3359 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3360 p_person_id => l_epe.person_id,
3361 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3362 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3363 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3364 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3365 p_rndg_cd => l_cvg(0).rndg_cd,
3366 p_rndg_rl => l_cvg(0).rndg_rl,
3367 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
3368 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
3369 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
3370 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
3371 /*
3372 CODE PRIOR TO WWBUG: 2054078
3373 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
3374 */
3375 /* Start of Changes for WWBUG: 2054078 */
3376 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
3377 /* End of Changes for WWBUG: 2054078 */
3378 p_mn_val => l_cvg(0).mn_val,
3379 p_incrmt_val => l_cvg(0).incrmt_val,
3380 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3381 p_dflt_val => l_cvg(0).dflt_val,
3382 p_perform_rounding_flg => l_perform_rounding_flg,
3383 p_ordr_num => l_order_number,
3384 p_ctfn_rqd_flag => l_ctfn_rqd,
3385 p_enrt_bnft_id => l_enrt_bnft_id,
3386 p_enb_valrow => p_enb_valrow,
3387 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
3388 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
3389 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
3390 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
3391 p_bnft_amount => l_cvg_amount,
3392 p_vapro_exist => l_vapro_exist
3393 );
3394 --
3395 end if;
3396 --
3397 elsif l_cvg(0).cvg_mlt_cd = 'FLRNG' then
3398 --
3399 hr_utility.set_location (' CMC FLRNG ',10);
3400 --
3401 hr_utility.set_location ('l_cvg-0.mx_val '||l_cvg(0).mx_val,33);
3402 hr_utility.set_location ('l_cvg-0.mn_val '||l_cvg(0).mn_val,33);
3403 --
3404 if l_cvg(0).lwr_lmt_calc_rl is not NULL then
3405 --
3406 l_lwr_outputs := benutils.formula
3407 (p_formula_id => l_cvg(0).lwr_lmt_calc_rl,
3408 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3409 p_assignment_id => l_asg.assignment_id,
3410 p_organization_id => l_asg.organization_id,
3411 p_business_group_id => l_epe.business_group_id,
3412 p_pgm_id => l_epe.pgm_id,
3413 p_pl_id => l_epe.pl_id,
3414 p_pl_typ_id => l_epe.pl_typ_id,
3415 p_opt_id => l_opt.opt_id,
3416 p_ler_id => l_epe.ler_id,
3417 -- FONM
3418 p_param1 => 'BEN_IV_RT_STRT_DT',
3419 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
3420 p_param2 => 'BEN_IV_CVG_STRT_DT',
3421 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt),
3422 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id);
3423 l_lwr_val := fnd_number.canonical_to_number(l_lwr_outputs(l_lwr_outputs.first).value);
3424 --
3425 elsif l_cvg(0).lwr_lmt_val is not null then
3426 l_lwr_val := l_cvg(0).lwr_lmt_val;
3427 end if;
3428
3429 if l_cvg(0).upr_lmt_calc_rl is not NULL then
3430 --
3431 l_upr_outputs := benutils.formula
3432 (p_formula_id => l_cvg(0).upr_lmt_calc_rl,
3433 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3434 p_assignment_id => l_asg.assignment_id,
3435 p_organization_id => l_asg.organization_id,
3436 p_business_group_id => l_epe.business_group_id,
3437 p_pgm_id => l_epe.pgm_id,
3438 p_pl_id => l_epe.pl_id,
3439 p_pl_typ_id => l_epe.pl_typ_id,
3440 p_opt_id => l_opt.opt_id,
3441 p_ler_id => l_epe.ler_id,
3442 -- FONM
3443 p_param1 => 'BEN_IV_RT_STRT_DT',
3444 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
3445 p_param2 => 'BEN_IV_CVG_STRT_DT',
3446 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt),
3447 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id);
3448 l_upr_val := fnd_number.canonical_to_number(l_upr_outputs(l_upr_outputs.first).value);
3449 --
3450 elsif l_cvg(0).upr_lmt_val is not null then
3451 l_upr_val := l_cvg(0).upr_lmt_val;
3452 end if;
3453
3454 i := nvl(l_lwr_val,l_cvg(0).mn_val);
3455
3456 hr_utility.set_location ('l_lwr_val :'||l_lwr_val,32);
3457 hr_utility.set_location ('l_upr_val :'||l_upr_val,32);
3458
3459 while i <= nvl(l_upr_val,l_cvg(0).mx_val) loop
3460 --
3461 hr_utility.set_location ('i = '||i,33);
3462 --
3463 l_ctfn_rqd := 'N';
3464 l_write_rec := true;
3465 --
3466 if l_incr_r_decr_cd is null or
3467 ((l_incr_r_decr_cd='INCRO' and
3468 l_order_number > nvl(l_crnt_ordr_num,0)) or
3469 (l_incr_r_decr_cd='EQINCR' and
3470 l_order_number >= nvl(l_crnt_ordr_num,0)) or
3471 (l_incr_r_decr_cd='DECRO' and
3472 l_order_number < nvl(l_crnt_ordr_num,0)) or
3473 (l_incr_r_decr_cd='EQDECR' and
3474 l_order_number <= nvl(l_crnt_ordr_num,0)) or
3475 -- Start of 3806262
3476 l_incr_r_decr_cd='INCRCTF' or
3477 --and l_order_number > nvl(l_crnt_ordr_num,0)) or -- Bug 6164688
3478 l_incr_r_decr_cd='DECRCTF'
3479 --and l_order_number < nvl(l_crnt_ordr_num,0)) -- Bug 6164688
3480 ) then
3481 -- End of 3806262
3482 l_val := round_val(
3483 p_val => i,
3484 p_effective_date => p_effective_date,
3485 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3486 p_rndg_cd => l_cvg(0).rndg_cd,
3487 p_rndg_rl => l_cvg(0).rndg_rl
3488 );
3489 l_cvg_amount := l_val ;
3490 --validate the limit for benefir amount
3491 hr_utility.set_location ('limit_checks ',10);
3492 benutils.limit_checks
3493 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3494 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3495 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3496 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3497 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3498 p_assignment_id => l_asg.assignment_id,
3499 p_organization_id => l_asg.organization_id,
3500 p_business_group_id => l_epe.business_group_id,
3501 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3502 p_pgm_id => l_epe.pgm_id,
3503 p_pl_id => l_epe.pl_id,
3504 p_pl_typ_id => l_epe.pl_typ_id,
3505 p_opt_id => l_opt.opt_id,
3506 p_ler_id => l_epe.ler_id,
3507 p_val => l_val,
3508 p_state => l_state.region_2);
3509
3510 --
3511 ben_determine_coverage.combine_with_variable_val
3512 (p_vr_val => l_vr_val,
3513 p_val => l_val,
3514 p_vr_trtmt_cd => l_vr_trtmt_cd,
3515 p_combined_val => l_combined_val);
3516 --
3517 if (l_dflt_enrt_cd in ('NSDCS','NNCS') and
3518 -- i <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
3519 l_combined_val <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or -- Bug 6068097
3520 (l_dflt_enrt_cd in ('NSDCS','NNCS') and
3521 l_crnt_ordr_num <> l_order_number) then
3522 l_dflt_flag := 'N';
3523
3524 elsif (l_dflt_enrt_cd in ('NSDCS','NNCS')
3525 -- and i = nvl(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
3526 and l_combined_val = nvl(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or -- Bug 6068097
3527 (l_dflt_enrt_cd in ('NSDCS','NNCS')
3528 and l_crnt_ordr_num = l_order_number) then
3529 l_dflt_flag := 'Y';
3530 --
3531 --
3532 -- bug fix 2560721
3533 -- for New Enrollments the bnft row corresponding to dflt_val should have
3534 -- the dflt_flag set to Y, when default enrollment code is 'NSDCS'.
3535 -- l_current_enrt_present will be null if the enrollment is New, refer to
3536 -- c_current_enrt cursor above
3537 --
3538 elsif l_dflt_enrt_cd in ('NSDCS') and
3539 nvl(l_current_enrt_present,'N') = 'N' and
3540 i = l_cvg(0).dflt_val then
3541 --
3542 l_dflt_flag := 'Y';
3543 --
3544 --
3545 -- end fix 2560721
3546 --
3547 elsif l_dflt_enrt_cd not in ('NSDCS','NNCS') and
3548 i = l_cvg(0).dflt_val then
3549 --
3550 l_dflt_flag := 'Y';
3551 --
3552 else
3553 l_dflt_flag := 'N';
3554
3555 end if;
3556
3557 if l_rstrn_found then
3558
3559 ben_determine_coverage.chk_bnft_ctfn
3560 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
3561 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
3562 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
3563 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
3564 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
3565 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
3566 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
3567 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
3568 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
3569 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
3570 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
3571 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
3572 p_combined_val => l_combined_val,
3573 p_crnt_bnft_amt => l_bnft_amt,
3574 p_ordr_num => l_order_number,
3575 p_crnt_ordr_num => l_crnt_ordr_num,
3576 p_ctfn_rqd => l_ctfn_rqd,
3577 p_write_rec => l_write_rec,
3578 p_effective_date => nvl(p_lf_evt_ocrd_dt,
3579 p_effective_date),
3580 p_assignment_id => l_asg.assignment_id,
3581 p_organization_id => l_asg.organization_id,
3582 p_business_group_id => l_epe.business_group_id,
3583 p_pgm_id => l_epe.pgm_id,
3584 p_pl_id => l_epe.pl_id,
3585 p_pl_typ_id => l_epe.pl_typ_id,
3586 p_opt_id => l_opt.opt_id,
3587 p_ler_id => l_epe.ler_id,
3588 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3589 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
3590 p_jurisdiction_code => l_jurisdiction_code,
3591 p_check_received => l_check_received,
3592 /* Start of Changes for WWBUG: 2054078 */
3593 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
3594 /* End of Changes for WWBUG: 2054078 */
3595 --Bug 4644489
3596 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
3597 --End Bug 4644489
3598 --
3599 end if;
3600 --
3601 if l_write_rec then
3602 --
3603 hr_utility.set_location('Writing coverage ',35);
3604 --
3605 ben_determine_coverage.write_coverage
3606 (p_calculate_only_mode => p_calculate_only_mode,
3607 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3608 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3609 p_val => l_combined_val,
3610 p_dflt_flag => l_dflt_flag,
3611 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3612 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3613 p_business_group_id => l_cvg(0).business_group_id,
3614 p_effective_date => p_effective_date,
3615 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3616 p_person_id => l_epe.person_id,
3617 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3618 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3619 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3620 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3621 p_rndg_cd => l_cvg(0).rndg_cd,
3622 p_rndg_rl => l_cvg(0).rndg_rl,
3623 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
3624 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
3625 p_entr_val_at_enrt_flag => 'N',--l_cvg(0).entr_val_at_enrt_flag,
3626 --Bug 5573274
3627 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
3628 /*
3629 CODE PRIOR TO WWBUG: 2054078
3630 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
3631 */
3632 /* Start of Changes for WWBUG: 2054078 */
3633 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
3634 /* End of Changes for WWBUG: 2054078 */
3635 --End Bug 5573274
3636 p_mn_val => null, --l_cvg(0).mn_val,
3637 p_incrmt_val => null, --l_cvg(0).incrmt_val,
3638 p_dflt_val => null, --l_cvg(0).dflt_val,
3639 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3640 p_perform_rounding_flg => l_perform_rounding_flg,
3641 p_ordr_num => l_order_number,
3642 p_ctfn_rqd_flag => l_ctfn_rqd,
3643 p_enrt_bnft_id => l_enrt_bnft_id,
3644 p_enb_valrow => p_enb_valrow,
3645 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
3646 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
3647 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
3648 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
3649 p_bnft_amount => l_cvg_amount,
3650 p_vapro_exist => l_vapro_exist
3651 );
3652 --
3653 if l_ctfn_rqd = 'Y'
3654 and not p_calculate_only_mode
3655 then
3656 --
3657 write_ctfn;
3658 --
3659 end if;
3660 --
3661 end if;
3662 --
3663 -- if l_vr_trtmt_cd is RPLC treat as FLFX
3664 --
3665 if l_vr_trtmt_cd = 'RPLC' then
3666 --
3667 exit;
3668 --
3669 end if;
3670
3671 end if;
3672 --
3673 i := i + l_cvg(0).incrmt_val;
3674 l_order_number := l_order_number + 1;
3675 --
3676 end loop;
3677 --
3678 elsif l_cvg(0).cvg_mlt_cd = 'CLRNG' then
3679 --
3680 hr_utility.set_location (' CMC CLRNG ',10);
3681 i := l_cvg(0).mn_val;
3682 --
3683 while i <= l_cvg(0).mx_val loop
3684 --
3685 l_ctfn_rqd := 'N';
3686 l_write_rec := true;
3687 --
3688 if l_incr_r_decr_cd is null or
3689 ((l_incr_r_decr_cd='INCRO' and
3690 l_order_number > nvl(l_crnt_ordr_num,0)) or
3691 (l_incr_r_decr_cd='EQINCR' and
3692 l_order_number >= nvl(l_crnt_ordr_num,0)) or
3693 (l_incr_r_decr_cd='DECRO' and
3694 l_order_number < nvl(l_crnt_ordr_num,0)) or
3695 (l_incr_r_decr_cd='EQDECR' and
3696 l_order_number <= nvl(l_crnt_ordr_num,0))) then
3697 --
3698 benutils.rt_typ_calc
3699 (p_val => i,
3700 p_val_2 => l_compensation_value,
3701 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3702 p_calculated_val => l_calculated_val);
3703 --
3704 l_val := round_val(
3705 p_val => l_calculated_val,
3706 p_effective_date => p_effective_date,
3707 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3708 p_rndg_cd => l_cvg(0).rndg_cd,
3709 p_rndg_rl => l_cvg(0).rndg_rl
3710 );
3711 l_cvg_amount := l_val ;
3712 --validate the limit for benefir amount
3713 hr_utility.set_location ('limit_checks ',10);
3714 benutils.limit_checks
3715 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3716 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3717 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3718 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3719 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3720 p_assignment_id => l_asg.assignment_id,
3721 p_organization_id => l_asg.organization_id,
3722 p_business_group_id => l_epe.business_group_id,
3723 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3724 p_pgm_id => l_epe.pgm_id,
3725 p_pl_id => l_epe.pl_id,
3726 p_pl_typ_id => l_epe.pl_typ_id,
3727 p_opt_id => l_opt.opt_id,
3728 p_ler_id => l_epe.ler_id,
3729 p_val => l_val,
3730 p_state => l_state.region_2);
3731
3732 ben_determine_coverage.combine_with_variable_val
3733 (p_vr_val => l_vr_val,
3734 p_val => l_val,
3735 p_vr_trtmt_cd => l_vr_trtmt_cd,
3736 p_combined_val => l_combined_val);
3737 --
3738 if (l_dflt_enrt_cd in ('NSDCS','NNCS')
3739 -- and i <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
3740 and l_combined_val <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or --Bug 6068097
3741 (l_dflt_enrt_cd in ('NSDCS','NNCS') and l_crnt_ordr_num <> l_order_number)
3742 then
3743 l_dflt_flag := 'N';
3744
3745 elsif (l_dflt_enrt_cd in ('NSDCS','NNCS')
3746 -- and i = NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
3747 and l_combined_val = NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or --Bug 6068097
3748 (l_dflt_enrt_cd in ('NSDCS','NNCS') and l_crnt_ordr_num = l_order_number)
3749 then
3750 l_dflt_flag := 'Y';
3751
3752 elsif l_dflt_enrt_cd not in ('NSDCS','NNCS') and
3753 i = l_cvg(0).dflt_val then
3754
3755 l_dflt_flag := 'Y';
3756
3757 else
3758
3759 l_dflt_flag := 'N';
3760
3761 end if;
3762
3763 if l_rstrn_found then
3764 --
3765 ben_determine_coverage.chk_bnft_ctfn
3766 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
3767 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
3768 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
3769 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
3770 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
3771 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
3772 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
3773 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
3774 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
3775 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
3776 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
3777 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
3778 p_combined_val => l_combined_val,
3779 p_crnt_bnft_amt => l_bnft_amt,
3780 p_ordr_num => l_order_number,
3781 p_crnt_ordr_num => l_crnt_ordr_num,
3782 p_ctfn_rqd => l_ctfn_rqd,
3783 p_write_rec => l_write_rec,
3784 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3785 p_assignment_id => l_asg.assignment_id,
3786 p_organization_id => l_asg.organization_id,
3787 p_business_group_id => l_epe.business_group_id,
3788 p_pgm_id => l_epe.pgm_id,
3789 p_pl_id => l_epe.pl_id,
3790 p_pl_typ_id => l_epe.pl_typ_id,
3791 p_opt_id => l_opt.opt_id,
3792 p_ler_id => l_epe.ler_id,
3793 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3794 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
3795 p_jurisdiction_code => l_jurisdiction_code,
3796 p_check_received => l_check_received,
3797 /* Start of Changes for WWBUG: 2054078 added parameter */
3798 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
3799 /* End of Changes for WWBUG: 2054078 added parameter */
3800 --Bug 4644489
3801 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
3802 --End Bug 4644489
3803 --
3804 end if;
3805 --
3806 if l_write_rec then
3807 --
3808 if l_epe.oipl_id is not null then
3809 --
3810 open c_opt(l_epe.oipl_id,
3811 nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
3812 --
3813 fetch c_opt into l_opt;
3814 --
3815 close c_opt;
3816 --
3817 end if;
3818 --
3819 ben_determine_coverage.write_coverage
3820 (p_calculate_only_mode => p_calculate_only_mode,
3821 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3822 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3823 p_val => l_combined_val,
3824 p_dflt_flag => l_dflt_flag,
3825 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3826 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3827 p_business_group_id => l_cvg(0).business_group_id,
3828 p_effective_date => p_effective_date,
3829 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3830 p_person_id => l_epe.person_id,
3831 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3832 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3833 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3834 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3835 p_rndg_cd => l_cvg(0).rndg_cd,
3836 p_rndg_rl => l_cvg(0).rndg_rl,
3837 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
3838 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
3839 p_entr_val_at_enrt_flag => 'N',--l_cvg(0).entr_val_at_enrt_flag,
3840 p_mx_val => null,--l_cvg(0).mx_val,
3841 p_mx_wout_ctfn_val => null, --l_rstrn.mx_cvg_alwd_amt
3842 p_mn_val => null,--l_cvg(0).mn_val,
3843 p_dflt_val => null,--l_dflt_val,
3844 p_incrmt_val => null,--l_cvg(0).incrmt_val,
3845 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3846 p_perform_rounding_flg => l_perform_rounding_flg,
3847 p_ordr_num => l_order_number,
3848 p_ctfn_rqd_flag => l_ctfn_rqd,
3849 p_enrt_bnft_id => l_enrt_bnft_id,
3850 p_enb_valrow => p_enb_valrow,
3851 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
3852 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
3853 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
3854 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
3855 p_bnft_amount => l_cvg_amount,
3856 p_vapro_exist => l_vapro_exist
3857 );
3858
3859 if l_ctfn_rqd = 'Y'
3860 and not p_calculate_only_mode
3861 then
3862 --
3863 write_ctfn;
3864 --
3865 end if;
3866 --
3867 end if;
3868 --
3869 -- if l_vr_trtmt_cd is RPLC treat as FLFX
3870 --
3871 if l_vr_trtmt_cd = 'RPLC' then
3872 --
3873 exit;
3874 --
3875 end if;
3876 --
3877 end if;
3878 --
3879 i := i + l_cvg(0).incrmt_val;
3880 l_order_number := l_order_number + 1;
3881 --
3882 end loop;
3883 --
3884 elsif l_cvg(0).cvg_mlt_cd = 'FLFXPCL' then
3885 hr_utility.set_location (' CMC FLFXPCL ',10);
3886 --
3887 l_ctfn_rqd := 'N';
3888 l_write_rec := true;
3889 --
3890 benutils.rt_typ_calc
3891 (p_val => l_cvg(0).mn_val,
3892 p_val_2 => l_compensation_value,
3893 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
3894 p_calculated_val => l_calculated_val);
3895 --
3896 hr_utility.set_location (' l_calculated_val ' || l_calculated_val,10);
3897 hr_utility.set_location (' l_cvg(0).val '|| l_cvg(0).val,10);
3898 --
3899 l_calculated_val := l_calculated_val + l_cvg(0).val;
3900 --
3901 l_val := round_val(
3902 p_val => l_calculated_val,
3903 p_effective_date => p_effective_date,
3904 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3905 p_rndg_cd => l_cvg(0).rndg_cd,
3906 p_rndg_rl => l_cvg(0).rndg_rl
3907 );
3908 l_cvg_amount := l_val ;
3909 --validate the limit for benefir amount
3910 hr_utility.set_location ('limit_checks ',10);
3911
3912 l_tot_val := l_val ;
3913 --
3914 hr_utility.set_location (' l_tot_val ' || l_tot_val,10);
3915 --
3916 benutils.limit_checks
3917 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3918 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
3919 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
3920 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
3921 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
3922 p_assignment_id => l_asg.assignment_id,
3923 p_organization_id => l_asg.organization_id,
3924 p_business_group_id => l_epe.business_group_id,
3925 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3926 p_pgm_id => l_epe.pgm_id,
3927 p_pl_id => l_epe.pl_id,
3928 p_pl_typ_id => l_epe.pl_typ_id,
3929 p_opt_id => l_opt.opt_id,
3930 p_ler_id => l_epe.ler_id,
3931 p_val => l_tot_val, -- 3095224,
3932 p_state => l_state.region_2);
3933
3934 ben_determine_coverage.combine_with_variable_val
3935 (p_vr_val => l_vr_val,
3936 p_val => l_tot_val, -- 3095224 l_val+l_cvg(0).val,
3937 p_vr_trtmt_cd => l_vr_trtmt_cd,
3938 p_combined_val => l_combined_val);
3939 --
3940 if l_rstrn_found then
3941 --
3942 ben_determine_coverage.chk_bnft_ctfn
3943 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
3944 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
3945 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
3946 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
3947 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
3948 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
3949 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
3950 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
3951 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
3952 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
3953 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
3954 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
3955 p_combined_val => l_combined_val,
3956 p_crnt_bnft_amt => l_bnft_amt,
3957 p_ordr_num => l_order_number,
3958 p_crnt_ordr_num => l_crnt_ordr_num,
3959 p_ctfn_rqd => l_ctfn_rqd,
3960 p_write_rec => l_write_rec,
3961 p_effective_date => nvl(p_lf_evt_ocrd_dt,
3962 p_effective_date),
3963 p_assignment_id => l_asg.assignment_id,
3964 p_organization_id => l_asg.organization_id,
3965 p_business_group_id => l_epe.business_group_id,
3966 p_pgm_id => l_epe.pgm_id,
3967 p_pl_id => l_epe.pl_id,
3968 p_pl_typ_id => l_epe.pl_typ_id,
3969 p_opt_id => l_opt.opt_id,
3970 p_ler_id => l_epe.ler_id,
3971 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3972 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
3973 p_jurisdiction_code => l_jurisdiction_code,
3974 p_check_received => l_check_received,
3975 /* Start of Changes for WWBUG: 2054078 added parameter */
3976 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
3977 /* End of Changes for WWBUG: 2054078 added parameter */
3978 --Bug 4644489
3979 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
3980 --End Bug 4644489
3981 --
3982 end if;
3983 --
3984 if l_write_rec then
3985 --
3986 ben_determine_coverage.write_coverage
3987 (p_calculate_only_mode => p_calculate_only_mode,
3988 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
3989 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
3990 p_val => l_combined_val,
3991 p_dflt_flag => l_epe.dflt_flag, --BUG 4449437
3992 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
3993 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
3994 p_business_group_id => l_cvg(0).business_group_id,
3995 p_effective_date => p_effective_date,
3996 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
3997 p_person_id => l_epe.person_id,
3998 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
3999 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4000 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4001 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4002 p_rndg_cd => l_cvg(0).rndg_cd,
4003 p_rndg_rl => l_cvg(0).rndg_rl,
4004 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4005 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4006 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4007 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
4008 /* CODE PRIOR TO WWBUG: 2054078
4009 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
4010 */
4011 /* Start of Changes for WWBUG: 2054078 */
4012 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
4013 /* End of Changes for WWBUG: 2054078 */
4014 p_mn_val => null, -- l_cvg(0).mn_val, Commented for bug 3102355
4015 p_dflt_val => l_cvg(0).dflt_val,
4016 p_incrmt_val => l_cvg(0).incrmt_val,
4017 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4018 p_perform_rounding_flg => l_perform_rounding_flg,
4019 p_ordr_num => l_order_number,
4020 p_ctfn_rqd_flag => l_ctfn_rqd,
4021 p_enrt_bnft_id => l_enrt_bnft_id,
4022 p_enb_valrow => p_enb_valrow ,
4023 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4024 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4025 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4026 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4027 p_bnft_amount => l_cvg_amount,
4028 p_vapro_exist => l_vapro_exist
4029 );
4030 --
4031 if l_ctfn_rqd = 'Y'
4032 and not p_calculate_only_mode
4033 then
4034 --
4035 write_ctfn;
4036 --
4037 end if;
4038 --
4039 else
4040 --
4041 -- Update the electable choice to be not electable
4042 --
4043 if l_epe.elctbl_flag='Y' then
4044 --
4045 if not p_calculate_only_mode then
4046 --
4047 ben_elig_per_elc_chc_api.update_perf_elig_per_elc_chc(
4048 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4049 p_elctbl_flag => 'N',
4050 p_dflt_flag => 'N',
4051 p_object_version_number => l_epe.object_version_number,
4052 p_effective_date => p_effective_date,
4053 p_program_application_id => fnd_global.prog_appl_id,
4054 p_program_id => fnd_global.conc_program_id,
4055 p_request_id => fnd_global.conc_request_id,
4056 p_program_update_date => sysdate
4057 );
4058 --
4059 -- If enrolled will deenroll.
4060 --
4061 ben_newly_ineligible.main(
4062 p_person_id => l_epe.person_id,
4063 p_pgm_id => l_epe.pgm_id,
4064 p_pl_id => l_epe.pl_id,
4065 p_oipl_id => l_epe.oipl_id,
4066 p_business_group_id => l_epe.business_group_id,
4067 p_ler_id => l_epe.ler_id,
4068 p_effective_date => p_effective_date
4069 );
4070 --
4071 end if;
4072 l_epe.elctbl_flag:='N';
4073 hr_utility.set_location('Electable choice was made not electable by bencvrge',29);
4074 end if;
4075 ben_determine_coverage.write_coverage
4076 (p_calculate_only_mode => p_calculate_only_mode,
4077 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
4078 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
4079 p_val => l_combined_val,
4080 p_dflt_flag => l_dflt_flag,
4081 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
4082 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4083 p_business_group_id => l_cvg(0).business_group_id,
4084 p_effective_date => p_effective_date,
4085 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4086 p_person_id => l_epe.person_id,
4087 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4088 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4089 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4090 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4091 p_rndg_cd => l_cvg(0).rndg_cd,
4092 p_rndg_rl => l_cvg(0).rndg_rl,
4093 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4094 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4095 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4096 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
4097 /*
4098 CODE PRIOR TO WWBUG: 2054078
4099 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
4100 */
4101 /* Start of Changes for WWBUG: 2054078 */
4102 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
4103 /* End of Changes for WWBUG: 2054078 */
4104 p_mn_val => null, -- l_cvg(0).mn_val, For Bug 3102355
4105 p_dflt_val => l_cvg(0).dflt_val,
4106 p_incrmt_val => l_cvg(0).incrmt_val,
4107 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4108 p_perform_rounding_flg => l_perform_rounding_flg,
4109 p_ordr_num => l_order_number,
4110 p_ctfn_rqd_flag => l_ctfn_rqd,
4111 p_enrt_bnft_id => l_enrt_bnft_id,
4112 p_enb_valrow => p_enb_valrow ,
4113 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4114 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4115 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4116 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4117 p_bnft_amount => l_cvg_amount,
4118 p_vapro_exist => l_vapro_exist
4119 );
4120 --
4121 end if;
4122 --
4123 elsif l_cvg(0).cvg_mlt_cd = 'FLPCLRNG' then
4124 hr_utility.set_location (' CMC FLPCLRNG ',10);
4125 --
4126 i := l_cvg(0).mn_val;
4127 --
4128 while i <= l_cvg(0).mx_val loop
4129 --
4130 l_ctfn_rqd := 'N';
4131 l_write_rec := true;
4132 --
4133 if l_incr_r_decr_cd is null or
4134 ((l_incr_r_decr_cd='INCRO' and
4135 l_order_number > nvl(l_crnt_ordr_num,0)) or
4136 (l_incr_r_decr_cd='EQINCR' and
4137 l_order_number >= nvl(l_crnt_ordr_num,0)) or
4138 (l_incr_r_decr_cd='DECRO' and
4139 l_order_number < nvl(l_crnt_ordr_num,0)) or
4140 (l_incr_r_decr_cd='EQDECR' and
4141 l_order_number <= nvl(l_crnt_ordr_num,0))) then
4142 --
4143 benutils.rt_typ_calc
4144 (p_val => i,
4145 p_val_2 => l_compensation_value,
4146 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4147 p_calculated_val => l_calculated_val);
4148 --_
4149 l_val := round_val(
4150 p_val => l_calculated_val,
4151 p_effective_date => p_effective_date,
4152 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4153 p_rndg_cd => l_cvg(0).rndg_cd,
4154 p_rndg_rl => l_cvg(0).rndg_rl
4155 );
4156 l_cvg_amount := l_val ;
4157 --validate the limit for benefir amount
4158
4159 l_tot_val := l_val+l_cvg(0).val; -- 3095224
4160
4161
4162 hr_utility.set_location ('limit_checks ',10);
4163 benutils.limit_checks
4164 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4165 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4166 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4167 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4168 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4169 p_assignment_id => l_asg.assignment_id,
4170 p_organization_id => l_asg.organization_id,
4171 p_business_group_id => l_epe.business_group_id,
4172 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4173 p_pgm_id => l_epe.pgm_id,
4174 p_pl_id => l_epe.pl_id,
4175 p_pl_typ_id => l_epe.pl_typ_id,
4176 p_opt_id => l_opt.opt_id,
4177 p_ler_id => l_epe.ler_id,
4178 p_val => l_tot_val , -- 3095224 l_val,
4179 p_state => l_state.region_2);
4180
4181
4182
4183 ben_determine_coverage.combine_with_variable_val
4184 (p_vr_val => l_vr_val,
4185 p_val => l_tot_val, -- 3095224 l_val+l_cvg(0).val,
4186 p_vr_trtmt_cd => l_vr_trtmt_cd,
4187 p_combined_val => l_combined_val);
4188 --
4189 if (l_dflt_enrt_cd in ('NSDCS','NNCS')
4190 -- and i <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
4191 and l_combined_val <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or -- Bug 6068097
4192 (l_dflt_enrt_cd in ('NSDCS','NNCS') and l_crnt_ordr_num <> l_order_number)
4193 then
4194 l_dflt_flag := 'N';
4195
4196 elsif (l_dflt_enrt_cd in ('NSDCS','NNCS')
4197 -- and i = NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
4198 and l_combined_val = NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or -- Bug 6068097
4199 (l_dflt_enrt_cd in ('NSDCS','NNCS') and l_crnt_ordr_num = l_order_number)
4200 then
4201
4202 l_dflt_flag := 'Y';
4203
4204 elsif l_dflt_enrt_cd not in ('NSDCS','NNCS') and
4205 i = l_cvg(0).dflt_val then
4206
4207 l_dflt_flag := 'Y';
4208
4209 else
4210
4211 l_dflt_flag := 'N';
4212
4213 end if;
4214
4215 if l_rstrn_found then
4216 --
4217 ben_determine_coverage.chk_bnft_ctfn
4218 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
4219 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
4220 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
4221 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
4222 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
4223 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
4224 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
4225 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
4226 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
4227 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
4228 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
4229 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
4230 p_combined_val => l_combined_val,
4231 p_crnt_bnft_amt => l_bnft_amt,
4232 p_ordr_num => l_order_number,
4233 p_crnt_ordr_num => l_crnt_ordr_num,
4234 p_ctfn_rqd => l_ctfn_rqd,
4235 p_write_rec => l_write_rec,
4236 p_effective_date => nvl(p_lf_evt_ocrd_dt,
4237 p_effective_date),
4238 p_assignment_id => l_asg.assignment_id,
4239 p_organization_id => l_asg.organization_id,
4240 p_business_group_id => l_epe.business_group_id,
4241 p_pgm_id => l_epe.pgm_id,
4242 p_pl_id => l_epe.pl_id,
4243 p_pl_typ_id => l_epe.pl_typ_id,
4244 p_opt_id => l_opt.opt_id,
4245 p_ler_id => l_epe.ler_id,
4246 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4247 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4248 p_jurisdiction_code => l_jurisdiction_code,
4249 p_check_received => l_check_received,
4250 /* Start of Changes for WWBUG: 2054078 */
4251 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
4252 /* End of Changes for WWBUG: 2054078 */
4253 --Bug 4644489
4254 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
4255 --End Bug 4644489
4256 --
4257 end if;
4258 --
4259 if l_write_rec then
4260 --
4261 if l_epe.oipl_id is not null then
4262 --
4263 open c_opt(l_epe.oipl_id, nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
4264 --
4265 fetch c_opt into l_opt;
4266 --
4267 close c_opt;
4268 --
4269 end if;
4270 --
4271 ben_determine_coverage.write_coverage
4272 (p_calculate_only_mode => p_calculate_only_mode,
4273 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
4274 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
4275 p_val => l_combined_val,
4276 p_dflt_flag => l_dflt_flag,
4277 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
4278 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4279 p_business_group_id => l_cvg(0).business_group_id,
4280 p_effective_date => p_effective_date,
4281 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4282 p_person_id => l_epe.person_id,
4283 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4284 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4285 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4286 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4287 p_rndg_cd => l_cvg(0).rndg_cd,
4288 p_rndg_rl => l_cvg(0).rndg_rl,
4289 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4290 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4291 p_entr_val_at_enrt_flag => 'N',--l_cvg(0).entr_val_at_enrt_flag,
4292 p_mx_val => null,--l_cvg(0).mx_val,
4293 p_mx_wout_ctfn_val => null, --l_rstrn.mx_cvg_alwd_amt
4294 p_mn_val => null,--l_cvg(0).mn_val,
4295 p_incrmt_val => null,--l_cvg(0).incrmt_val,
4296 p_dflt_val => null,--l_dflt_val,
4297 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4298 p_perform_rounding_flg => l_perform_rounding_flg,
4299 p_ordr_num => l_order_number,
4300 p_ctfn_rqd_flag => l_ctfn_rqd,
4301 p_enrt_bnft_id => l_enrt_bnft_id,
4302 p_enb_valrow => p_enb_valrow,
4303 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4304 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4305 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4306 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4307 p_bnft_amount => l_cvg_amount,
4308 p_vapro_exist => l_vapro_exist
4309 );
4310 --
4311 if l_ctfn_rqd = 'Y'
4312 and not p_calculate_only_mode
4313 then
4314 --
4315 write_ctfn;
4316 --
4317 end if;
4318 --
4319 end if;
4320 --
4321 -- if l_vr_trtmt_cd is RPLC treat as FLFX
4322 --
4323 if l_vr_trtmt_cd = 'RPLC' then
4324 --
4325 exit;
4326 --
4327 end if;
4328 --
4329 end if;
4330 --
4331 i := i + l_cvg(0).incrmt_val;
4332 l_order_number := l_order_number + 1;
4333 --
4334 end loop;
4335 --
4336 elsif l_cvg(0).cvg_mlt_cd = 'CLPFLRNG' then
4337 hr_utility.set_location (' CMC CLPFLRNG ',10);
4338 --
4339 benutils.rt_typ_calc
4340 (p_val => l_cvg(0).val,
4341 p_val_2 => l_compensation_value,
4342 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4343 p_calculated_val => l_calculated_val);
4344 --
4345 l_val := round_val(
4346 p_val => l_calculated_val,
4347 p_effective_date => p_effective_date,
4348 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4349 p_rndg_cd => l_cvg(0).rndg_cd,
4350 p_rndg_rl => l_cvg(0).rndg_rl
4351 );
4352 i := l_cvg(0).mn_val;
4353 l_cvg_amount := l_val ;
4354
4355 /* moved the limit check to inside the loop to enforce the limit on compensation + range
4356 --validate the limit for benefir amount
4357 hr_utility.set_location ('limit_checks ',10);
4358 benutils.limit_checks
4359 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4360 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4361 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4362 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4363 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4364 p_assignment_id => l_asg.assignment_id,
4365 p_organization_id => l_asg.organization_id,
4366 p_business_group_id => l_epe.business_group_id,
4367 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4368 p_pgm_id => l_epe.pgm_id,
4369 p_pl_id => l_epe.pl_id,
4370 p_pl_typ_id => l_epe.pl_typ_id,
4371 p_opt_id => l_opt.opt_id,
4372 p_ler_id => l_epe.ler_id,
4373 p_val => l_val,
4374 p_state => l_state.region_2);
4375 */
4376
4377 --
4378 while i <= l_cvg(0).mx_val loop
4379 --
4380 l_ctfn_rqd := 'N';
4381 l_write_rec := true;
4382 --
4383 if l_incr_r_decr_cd is null or
4384 ((l_incr_r_decr_cd='INCRO' and
4385 l_order_number > nvl(l_crnt_ordr_num,0)) or
4386 (l_incr_r_decr_cd='EQINCR' and
4387 l_order_number >= nvl(l_crnt_ordr_num,0)) or
4388 (l_incr_r_decr_cd='DECRO' and
4389 l_order_number < nvl(l_crnt_ordr_num,0)) or
4390 (l_incr_r_decr_cd='EQDECR' and
4391 l_order_number <= nvl(l_crnt_ordr_num,0))) then
4392 --bug#2708285 - limit checked for the compensation plus flat amount
4393 l_tot_val := l_val + i;
4394 benutils.limit_checks
4395 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4396 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4397 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4398 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4399 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4400 p_assignment_id => l_asg.assignment_id,
4401 p_organization_id => l_asg.organization_id,
4402 p_business_group_id => l_epe.business_group_id,
4403 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4404 p_pgm_id => l_epe.pgm_id,
4405 p_pl_id => l_epe.pl_id,
4406 p_pl_typ_id => l_epe.pl_typ_id,
4407 p_opt_id => l_opt.opt_id,
4408 p_ler_id => l_epe.ler_id,
4409 p_val => l_tot_val,
4410 p_state => l_state.region_2);
4411
4412
4413
4414 ben_determine_coverage.combine_with_variable_val
4415 (p_vr_val => l_vr_val,
4416 p_val => l_tot_val, --l_val+i,
4417 p_vr_trtmt_cd => l_vr_trtmt_cd,
4418 p_combined_val => l_combined_val);
4419 --
4420 if (l_dflt_enrt_cd in ('NSDCS','NNCS')
4421 -- and i <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
4422 and l_combined_val <> NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or -- Bug 6068097
4423 (l_dflt_enrt_cd in ('NSDCS','NNCS') and l_crnt_ordr_num <> l_order_number)
4424 then
4425 l_dflt_flag := 'N';
4426
4427 elsif (l_dflt_enrt_cd in ('NSDCS','NNCS')
4428 -- and i = NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or
4429 and l_combined_val = NVL(l_bnft_amt,l_current_enrt_sspndd.bnft_amt)) or -- Bug 6068097
4430 (l_dflt_enrt_cd in ('NSDCS','NNCS') and l_crnt_ordr_num = l_order_number)
4431 then
4432
4433 l_dflt_flag := 'Y';
4434
4435 elsif l_dflt_enrt_cd not in ('NSDCS','NNCS') and
4436 i = l_cvg(0).dflt_val then
4437
4438 l_dflt_flag := 'Y';
4439
4440 else
4441
4442 l_dflt_flag := 'N';
4443
4444 end if;
4445
4446 if l_rstrn_found then
4447 --
4448 ben_determine_coverage.chk_bnft_ctfn
4449 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
4450 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
4451 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
4452 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
4453 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
4454 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
4455 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
4456 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
4457 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
4458 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
4459 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
4460 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
4461 p_combined_val => l_combined_val,
4462 p_crnt_bnft_amt => l_bnft_amt,
4463 p_ordr_num => l_order_number,
4464 p_crnt_ordr_num => l_crnt_ordr_num,
4465 p_ctfn_rqd => l_ctfn_rqd,
4466 p_write_rec => l_write_rec,
4467 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4468 p_assignment_id => l_asg.assignment_id,
4469 p_organization_id => l_asg.organization_id,
4470 p_business_group_id => l_epe.business_group_id,
4471 p_pgm_id => l_epe.pgm_id,
4472 p_pl_id => l_epe.pl_id,
4473 p_pl_typ_id => l_epe.pl_typ_id,
4474 p_opt_id => l_opt.opt_id,
4475 p_ler_id => l_epe.ler_id,
4476 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4477 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4478 p_jurisdiction_code => l_jurisdiction_code,
4479 p_check_received => l_check_received,
4480 /* Start of Changes for WWBUG: 2054078: added parameter */
4481 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
4482 /* End of Changes for WWBUG: 2054078: added parameter */
4483 --Bug 4644489
4484 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
4485 --End Bug 4644489
4486 --
4487 end if;
4488
4489 if l_write_rec then
4490 if l_epe.oipl_id is not null then
4491 open c_opt(l_epe.oipl_id, nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
4492 fetch c_opt into l_opt;
4493 close c_opt;
4494 end if;
4495
4496 ben_determine_coverage.write_coverage
4497 (p_calculate_only_mode => p_calculate_only_mode,
4498 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
4499 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
4500 p_val => l_combined_val,
4501 p_dflt_flag => l_dflt_flag,
4502 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
4503 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4504 p_business_group_id => l_cvg(0).business_group_id,
4505 p_effective_date => p_effective_date,
4506 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4507 p_person_id => l_epe.person_id,
4508 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4509 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4510 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4511 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4512 p_rndg_cd => l_cvg(0).rndg_cd,
4513 p_rndg_rl => l_cvg(0).rndg_rl,
4514 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4515 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4516 p_entr_val_at_enrt_flag => 'N',--l_cvg(0).entr_val_at_enrt_flag,
4517 p_mx_val => null,--l_cvg(0).mx_val,
4518 p_mx_wout_ctfn_val => null, --l_rstrn.mx_cvg_alwd_amt
4519 p_mn_val => null,--l_cvg(0).mn_val,
4520 p_dflt_val => null,--l_dflt_val,
4521 p_incrmt_val => null,--l_cvg(0).incrmt_val,
4522 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4523 p_perform_rounding_flg => l_perform_rounding_flg,
4524 p_ordr_num => l_order_number,
4525 p_ctfn_rqd_flag => l_ctfn_rqd,
4526 p_enrt_bnft_id => l_enrt_bnft_id,
4527 p_enb_valrow => p_enb_valrow,
4528 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4529 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4530 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4531 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4532 p_bnft_amount => l_cvg_amount,
4533 p_vapro_exist => l_vapro_exist
4534 );
4535
4536 if l_ctfn_rqd = 'Y'
4537 and not p_calculate_only_mode
4538 then
4539 write_ctfn;
4540 end if;
4541
4542 end if;
4543 --
4544 -- if l_vr_trtmt_cd is RPLC treat as FLFX
4545 --
4546 if l_vr_trtmt_cd = 'RPLC' then
4547 exit;
4548 end if;
4549
4550 end if;
4551 i := i + l_cvg(0).incrmt_val;
4552 l_order_number := l_order_number + 1;
4553
4554 end loop;
4555
4556 elsif l_cvg(0).cvg_mlt_cd = 'SAAEAR' then
4557 hr_utility.set_location (' CMC SAAEAR ',10);
4558 l_ctfn_rqd := 'N';
4559 l_write_rec := true;
4560
4561 ben_determine_coverage.write_coverage
4562 (p_calculate_only_mode => p_calculate_only_mode,
4563 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
4564 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
4565 p_val => null,
4566 p_dflt_flag => l_epe.dflt_flag,
4567 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
4568 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4569 p_business_group_id => l_cvg(0).business_group_id,
4570 p_effective_date => p_effective_date,
4571 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4572 p_person_id => l_epe.person_id,
4573 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4574 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4575 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4576 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4577 p_rndg_cd => l_cvg(0).rndg_cd,
4578 p_rndg_rl => l_cvg(0).rndg_rl,
4579 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4580 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4581 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4582 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
4583 /*
4584 CODE PRIOR TO WWBUG: 2054078
4585 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
4586 */
4587 /* Start of Changes for WWBUG: 2054078 */
4588 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
4589 /* End of Changes for WWBUG: 2054078 */
4590 p_mn_val => l_cvg(0).mn_val,
4591 p_dflt_val => l_cvg(0).dflt_val,
4592 p_incrmt_val => l_cvg(0).incrmt_val,
4593 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4594 p_perform_rounding_flg => l_perform_rounding_flg,
4595 p_ordr_num => l_order_number,
4596 p_ctfn_rqd_flag => l_ctfn_rqd,
4597 p_enrt_bnft_id => l_enrt_bnft_id,
4598 p_enb_valrow => p_enb_valrow,
4599 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4600 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4601 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4602 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4603 p_bnft_amount => l_cvg_amount,
4604 p_vapro_exist => l_vapro_exist
4605 );
4606 --
4607 elsif l_cvg(0).cvg_mlt_cd = 'NSVU' then
4608 --
4609 hr_utility.set_location (' CMC NSVU ',10);
4610 --
4611 l_ctfn_rqd := 'N';
4612 l_write_rec := true;
4613 --
4614 --Bug 6054310
4615 l_vr_val := nvl(l_vr_val, l_dflt_elcn_val);
4616 --
4617 --Bug 6054310
4618 ben_determine_coverage.combine_with_variable_val
4619 (p_vr_val => l_vr_val,
4620 p_val => l_cvg(0).val, -- 5933576 Removed l_calculated_val from here
4621 p_vr_trtmt_cd => l_vr_trtmt_cd,
4622 p_combined_val => l_combined_val);
4623 --
4624 if l_combined_val is null or l_combined_val = 0 then
4625 --
4626 fnd_message.set_name('BEN','BEN_91841_BENCVRGE_VAL_RQD');
4627 fnd_message.set_token('PACKAGE',l_package);
4628 fnd_message.set_token('PERSON_ID',to_char(l_epe.person_id));
4629 fnd_message.set_token('CALC_MTHD',l_cvg(0).cvg_mlt_cd);
4630 fnd_message.set_token('PGM_ID',to_char(l_epe.pgm_id));
4631 fnd_message.set_token('PL_ID',to_char(l_epe.pl_id));
4632 fnd_message.set_token('PL_TYP_ID',to_char(l_epe.pl_typ_id));
4633 fnd_message.set_token('OIPL_ID',to_char(l_epe.oipl_id));
4634 fnd_message.set_token('PLIP_ID',to_char(l_epe.plip_id));
4635 fnd_message.set_token('PTIP_ID',to_char(l_epe.ptip_id));
4636 fnd_message.raise_error;
4637 --
4638 end if;
4639 --
4640 --Bug 5933576 Adding chk_bnft_ctfn for NSVU as well
4641 --
4642 if l_rstrn_found then
4643 --
4644 ben_determine_coverage.chk_bnft_ctfn
4645 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
4646 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
4647 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
4648 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
4649 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
4650 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
4651 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
4652 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
4653 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
4654 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
4655 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
4656 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
4657 p_combined_val => l_combined_val,
4658 p_crnt_bnft_amt => l_bnft_amt,
4659 p_ordr_num => l_order_number,
4660 p_crnt_ordr_num => l_crnt_ordr_num,
4661 p_ctfn_rqd => l_ctfn_rqd,
4662 p_write_rec => l_write_rec,
4663 p_effective_date => nvl(p_lf_evt_ocrd_dt, p_effective_date),
4664 p_assignment_id => l_asg.assignment_id,
4665 p_organization_id => l_asg.organization_id,
4666 p_business_group_id => l_epe.business_group_id,
4667 p_pgm_id => l_epe.pgm_id,
4668 p_pl_id => l_epe.pl_id,
4669 p_pl_typ_id => l_epe.pl_typ_id,
4670 p_opt_id => l_opt.opt_id,
4671 p_ler_id => l_epe.ler_id,
4672 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4673 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4674 p_jurisdiction_code => l_jurisdiction_code,
4675 p_check_received => l_check_received,
4676 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
4677 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
4678 --
4679 end if;
4680 --
4681 if l_write_rec then
4682 --
4683 ben_determine_coverage.write_coverage
4684 (p_calculate_only_mode => p_calculate_only_mode,
4685 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
4686 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
4687 p_val => l_combined_val,
4688 p_dflt_flag => l_epe.dflt_flag,
4689 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
4690 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4691 p_business_group_id => l_cvg(0).business_group_id,
4692 p_effective_date => p_effective_date,
4693 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4694 p_person_id => l_epe.person_id,
4695 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4696 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4697 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4698 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4699 p_rndg_cd => l_cvg(0).rndg_cd,
4700 p_rndg_rl => l_cvg(0).rndg_rl,
4701 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4702 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4703 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4704 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
4705 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
4706 p_mn_val => l_cvg(0).mn_val,
4707 p_dflt_val => l_cvg(0).dflt_val,
4708 p_incrmt_val => l_cvg(0).incrmt_val,
4709 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4710 p_perform_rounding_flg => l_perform_rounding_flg,
4711 p_ordr_num => l_order_number,
4712 p_ctfn_rqd_flag => l_ctfn_rqd,
4713 p_enrt_bnft_id => l_enrt_bnft_id,
4714 p_enb_valrow => p_enb_valrow,
4715 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4716 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4717 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4718 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4719 p_bnft_amount => l_cvg_amount,
4720 p_vapro_exist => l_vapro_exist
4721 );
4722 --
4723 if l_ctfn_rqd = 'Y' and not p_calculate_only_mode then
4724 --
4725 write_ctfn;
4726 --
4727 end if;
4728 --
4729 else
4730 --
4731 -- Update the electable choice to be not electable
4732 --
4733 if l_epe.elctbl_flag='Y' then
4734 --
4735 if not p_calculate_only_mode then
4736 --
4737 ben_elig_per_elc_chc_api.update_perf_elig_per_elc_chc(
4738 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4739 p_elctbl_flag => 'N',
4740 p_dflt_flag => 'N',
4741 p_object_version_number => l_epe.object_version_number,
4742 p_effective_date => p_effective_date,
4743 p_program_application_id => fnd_global.prog_appl_id,
4744 p_program_id => fnd_global.conc_program_id,
4745 p_request_id => fnd_global.conc_request_id,
4746 p_program_update_date => sysdate
4747 );
4748 --
4749 -- If enrolled will deenroll.
4750 --
4751 ben_newly_ineligible.main(
4752 p_person_id => l_epe.person_id,
4753 p_pgm_id => l_epe.pgm_id,
4754 p_pl_id => l_epe.pl_id,
4755 p_oipl_id => l_epe.oipl_id,
4756 p_business_group_id => l_epe.business_group_id,
4757 p_ler_id => l_epe.ler_id,
4758 p_effective_date => p_effective_date
4759 );
4760 --
4761 end if;
4762 --
4763 l_epe.elctbl_flag:='N';
4764 hr_utility.set_location('Electable choice was made not electable by bencvrge',29);
4765 end if;
4766 ben_determine_coverage.write_coverage
4767 (p_calculate_only_mode => p_calculate_only_mode,
4768 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
4769 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
4770 p_val => l_combined_val,
4771 p_dflt_flag => l_epe.dflt_flag,
4772 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
4773 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4774 p_business_group_id => l_cvg(0).business_group_id,
4775 p_effective_date => p_effective_date,
4776 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4777 p_person_id => l_epe.person_id,
4778 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4779 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4780 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4781 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4782 p_rndg_cd => l_cvg(0).rndg_cd,
4783 p_rndg_rl => l_cvg(0).rndg_rl,
4784 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4785 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4786 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4787 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
4788 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
4789 p_mn_val => l_cvg(0).mn_val,
4790 p_incrmt_val => l_cvg(0).incrmt_val,
4791 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4792 p_dflt_val => l_cvg(0).dflt_val,
4793 p_perform_rounding_flg => l_perform_rounding_flg,
4794 p_ordr_num => l_order_number,
4795 p_ctfn_rqd_flag => l_ctfn_rqd,
4796 p_enrt_bnft_id => l_enrt_bnft_id,
4797 p_enb_valrow => p_enb_valrow,
4798 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4799 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4800 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4801 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4802 p_bnft_amount => l_cvg_amount,
4803 p_vapro_exist => l_vapro_exist
4804 );
4805 --
4806 end if;
4807 --
4808 --End Bug 5933576
4809 --
4810 elsif l_cvg(0).cvg_mlt_cd in ('RL','ERL') then
4811 hr_utility.set_location (' CMC RL ',10);
4812 --
4813 if l_epe.oipl_id is not null and l_opt.opt_id is null
4814 then
4815 open c_opt(l_epe.oipl_id, nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date))); -- FONM
4816 fetch c_opt into l_opt;
4817 close c_opt;
4818 end if;
4819 --
4820 l_ctfn_rqd := 'N';
4821 l_write_rec := true;
4822 --
4823 -- Call formula initialise routine
4824 --
4825 l_outputs := benutils.formula
4826 (p_formula_id => l_cvg(0).val_calc_rl,
4827 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4828 p_business_group_id => l_epe.business_group_id,
4829 p_assignment_id => l_asg.assignment_id,
4830 p_organization_id => l_asg.organization_id,
4831 p_pgm_id => l_epe.pgm_id,
4832 p_pl_id => l_epe.pl_id,
4833 p_pl_typ_id => l_epe.pl_typ_id,
4834 p_opt_id => l_opt.opt_id,
4835 p_ler_id => l_epe.ler_id,
4836 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4837 -- FONM
4838 p_param1 => 'BEN_IV_RT_STRT_DT',
4839 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
4840 p_param2 => 'BEN_IV_CVG_STRT_DT',
4841 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt),
4842 p_jurisdiction_code => l_jurisdiction_code);
4843 --
4844 l_value := fnd_number.canonical_to_number(l_outputs(l_outputs.first).value);
4845 --
4846 l_val := round_val(
4847 p_val => l_value,
4848 p_effective_date => p_effective_date,
4849 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4850 p_rndg_cd => l_cvg(0).rndg_cd,
4851 p_rndg_rl => l_cvg(0).rndg_rl
4852 );
4853 l_cvg_amount := l_val ;
4854 --validate the limit for benefir amount
4855 hr_utility.set_location ('limit_checks ',10);
4856 benutils.limit_checks
4857 (p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4858 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4859 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4860 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4861 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4862 p_assignment_id => l_asg.assignment_id,
4863 p_organization_id => l_asg.organization_id,
4864 p_business_group_id => l_epe.business_group_id,
4865 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4866 p_pgm_id => l_epe.pgm_id,
4867 p_pl_id => l_epe.pl_id,
4868 p_pl_typ_id => l_epe.pl_typ_id,
4869 p_opt_id => l_opt.opt_id,
4870 p_ler_id => l_epe.ler_id,
4871 p_val => l_val,
4872 p_state => l_state.region_2);
4873
4874
4875
4876
4877 ben_determine_coverage.combine_with_variable_val
4878 (p_vr_val => l_vr_val,
4879 p_val => l_val,
4880 p_vr_trtmt_cd => l_vr_trtmt_cd,
4881 p_combined_val => l_combined_val);
4882 --
4883
4884 if l_rstrn_found then
4885 --
4886 ben_determine_coverage.chk_bnft_ctfn
4887 (p_mx_cvg_wcfn_amt => l_rstrn.mx_cvg_wcfn_amt,
4888 p_mx_cvg_wcfn_mlt_num => l_rstrn.mx_cvg_wcfn_mlt_num,
4889 p_mx_cvg_mlt_incr_num => l_rstrn.mx_cvg_mlt_incr_num,
4890 p_mx_cvg_mlt_incr_wcf_num => l_rstrn.mx_cvg_mlt_incr_wcf_num,
4891 p_mx_cvg_incr_alwd_amt => l_rstrn.mx_cvg_incr_alwd_amt,
4892 p_mx_cvg_incr_wcf_alwd_amt => l_rstrn.mx_cvg_incr_wcf_alwd_amt,
4893 p_mn_cvg_rqd_amt => l_rstrn.mn_cvg_rqd_amt,
4894 p_mx_cvg_alwd_amt => l_rstrn.mx_cvg_alwd_amt,
4895 p_mx_cvg_rl => l_rstrn.mx_cvg_rl,
4896 p_mn_cvg_rl => l_rstrn.mn_cvg_rl,
4897 p_no_mn_cvg_amt_apls_flag => l_rstrn.no_mn_cvg_amt_apls_flag,
4898 p_no_mx_cvg_amt_apls_flag => l_rstrn.no_mx_cvg_amt_apls_flag,
4899 p_combined_val => l_combined_val,
4900 p_crnt_bnft_amt => l_bnft_amt,
4901 p_ordr_num => l_order_number,
4902 p_crnt_ordr_num => l_crnt_ordr_num,
4903 p_ctfn_rqd => l_ctfn_rqd,
4904 p_write_rec => l_write_rec,
4905 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4906 p_assignment_id => l_asg.assignment_id,
4907 p_organization_id => l_asg.organization_id,
4908 p_business_group_id => l_epe.business_group_id,
4909 p_pgm_id => l_epe.pgm_id,
4910 p_pl_id => l_epe.pl_id,
4911 p_pl_typ_id => l_epe.pl_typ_id,
4912 p_opt_id => l_opt.opt_id,
4913 p_ler_id => l_epe.ler_id,
4914 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4915 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4916 p_jurisdiction_code => l_jurisdiction_code,
4917 p_check_received => l_check_received,
4918 p_mx_cvg_wout_ctfn_val => l_mx_cvg_wout_ctfn_val,
4919 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4920 --Bug 4644489
4921 p_rstrn_mn_cvg_rqd_amt => l_rstrn_mn_cvg_rqd_amt);
4922 --End Bug 4644489
4923 --
4924 end if;
4925 --
4926 ben_determine_coverage.write_coverage
4927 (p_calculate_only_mode => p_calculate_only_mode,
4928 p_bndry_perd_cd => l_cvg(0).bndry_perd_cd,
4929 p_bnft_typ_cd => l_cvg(0).bnft_typ_cd,
4930 p_val => l_combined_val,
4931 p_dflt_flag => l_epe.dflt_flag,
4932 p_nnmntry_uom => l_cvg(0).nnmntry_uom,
4933 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
4934 p_business_group_id => l_cvg(0).business_group_id,
4935 p_effective_date => p_effective_date,
4936 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4937 p_person_id => l_epe.person_id,
4938 p_lwr_lmt_val => l_cvg(0).lwr_lmt_val,
4939 p_lwr_lmt_calc_rl => l_cvg(0).lwr_lmt_calc_rl,
4940 p_upr_lmt_val => l_cvg(0).upr_lmt_val,
4941 p_upr_lmt_calc_rl => l_cvg(0).upr_lmt_calc_rl,
4942 p_rndg_cd => l_cvg(0).rndg_cd,
4943 p_rndg_rl => l_cvg(0).rndg_rl,
4944 p_comp_lvl_fctr_id => l_cvg(0).comp_lvl_fctr_id,
4945 p_cvg_mlt_cd => l_cvg(0).cvg_mlt_cd,
4946 p_entr_val_at_enrt_flag => l_cvg(0).entr_val_at_enrt_flag,
4947 p_mx_val => nvl(l_rstrn.mx_cvg_wcfn_amt, l_cvg(0).mx_val), -- mx with ctfn
4948 /*
4949 CODE PRIOR TO WWBUG: 2054078
4950 p_mx_wout_ctfn_val => l_rstrn.mx_cvg_alwd_amt,
4951 */
4952 /* Start of Changes for WWBUG: 2054078 */
4953 p_mx_wout_ctfn_val => nvl(l_rstrn.mx_cvg_alwd_amt,l_mx_cvg_wout_ctfn_val),
4954 /* End of Changes for WWBUG: 2054078 */
4955 p_mn_val => l_cvg(0).mn_val,
4956 p_dflt_val => l_cvg(0).dflt_val,
4957 p_incrmt_val => l_cvg(0).incrmt_val,
4958 p_rt_typ_cd => l_cvg(0).rt_typ_cd,
4959 p_perform_rounding_flg => l_perform_rounding_flg,
4960 p_ordr_num => l_order_number,
4961 p_ctfn_rqd_flag => l_ctfn_rqd,
4962 p_enrt_bnft_id => l_enrt_bnft_id,
4963 p_enb_valrow => p_enb_valrow,
4964 p_ultmt_upr_lmt => l_ultmt_upr_lmt,
4965 p_ultmt_lwr_lmt => l_ultmt_lwr_lmt,
4966 p_ultmt_upr_lmt_calc_rl => l_ultmt_upr_lmt_calc_rl,
4967 p_ultmt_lwr_lmt_calc_rl => l_ultmt_lwr_lmt_calc_rl,
4968 p_bnft_amount => l_cvg_amount,
4969 p_vapro_exist => l_vapro_exist
4970 );
4971 -- bug 5900235
4972 if l_cvg(0).cvg_mlt_cd = 'RL'
4973 then
4974
4975 if l_ctfn_rqd = 'Y' and not p_calculate_only_mode
4976 then
4977 --
4978
4979 write_ctfn;
4980 --
4981 end if; -- end 5900235
4982 else
4983 if not p_calculate_only_mode and l_rstrn_found
4984 then
4985 --
4986 write_ctfn;
4987 --
4988 end if;
4989 end if;
4990 --
4991 else
4992 --
4993 fnd_message.set_name('BEN','BEN_91844_BENCVRGE_MLT_CD');
4994 fnd_message.set_token('PACKAGE',l_package);
4995 fnd_message.set_token('PERSON_ID',to_char(l_epe.person_id));
4996 fnd_message.set_token('CALC_MTHD',l_cvg(0).cvg_mlt_cd);
4997 fnd_message.set_token('PGM_ID',to_char(l_epe.pgm_id));
4998 fnd_message.set_token('PL_ID',to_char(l_epe.pl_id));
4999 fnd_message.set_token('PL_TYP_ID',to_char(l_epe.pl_typ_id));
5000 fnd_message.set_token('OIPL_ID',to_char(l_epe.oipl_id));
5001 fnd_message.set_token('PLIP_ID',to_char(l_epe.plip_id));
5002 fnd_message.set_token('PTIP_ID',to_char(l_epe.ptip_id));
5003 fnd_message.raise_error;
5004 --
5005 end if;
5006 --
5007 -- This following routine need to create an additional benefit row, if
5008 -- tne interim enrollment code is 'Same'
5009 -- this row will be used for assigning the interim coverage
5010 --
5011 hr_utility.set_location (' Current Same Calculations ',10);
5012
5013 l_interim_cd := substr(l_rstrn.dflt_to_asn_pndg_ctfn_cd,4,2) ;
5014 l_current_level_cd := substr(l_rstrn.dflt_to_asn_pndg_ctfn_cd,2,2);
5015 --
5016 hr_utility.set_location (' l_interim_cd '||l_interim_cd,22);
5017 hr_utility.set_location (' l_current_level_cd '||l_current_level_cd,22);
5018 --
5019 l_current_plan_id := null ;
5020 l_current_oipl_id := null ;
5021 --
5022 if l_interim_cd = 'SM' then
5023 --
5024 if l_current_level_cd = 'AS' then
5025 --
5026 open c_current_enrt_in_pl_typ(l_epe.pl_typ_id,
5027 nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date))) ; -- FONM
5028 fetch c_current_enrt_in_pl_typ into l_current_plan_id,l_current_oipl_id ;
5029 if c_current_enrt_in_pl_typ%found then
5030 hr_utility.set_location(' l_create_current_enb := true PLTYP',222);
5031 l_create_current_enb := true ;
5032 end if;
5033 close c_current_enrt_in_pl_typ;
5034 --
5035 elsif l_current_level_cd = 'SE' then
5036 open c_current_enrt_in_pln(l_epe.pl_id,
5037 nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date))) ; -- FONM
5038 fetch c_current_enrt_in_pln into l_current_plan_id,l_current_oipl_id ;
5039 if c_current_enrt_in_pln%found then
5040 l_create_current_enb := true ;
5041 end if;
5042 close c_current_enrt_in_pln;
5043 elsif l_current_level_cd = 'SO' then
5044 -- Bug 2543071 changed the l_epe.pl_id to l_epe.oipl_id and added
5045 -- the if condition.
5046 if l_epe.oipl_id is not null then
5047 open c_current_enrt_in_oipl(l_epe.oipl_id,
5048 nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date))) ; -- FONM
5049 fetch c_current_enrt_in_oipl into l_current_plan_id,l_current_oipl_id ;
5050 if c_current_enrt_in_oipl%found then
5051 l_create_current_enb := true ;
5052 end if;
5053 close c_current_enrt_in_oipl;
5054 end if;
5055 end if;
5056 --
5057 hr_utility.set_location (' l_current_plan_id '||l_current_plan_id,222);
5058 hr_utility.set_location (' l_epe.pl_id '||l_epe.pl_id,222);
5059 hr_utility.set_location (' l_current_oipl_id '||l_current_oipl_id,222);
5060 hr_utility.set_location (' l_epe.oipl_id '||l_epe.oipl_id,222);
5061 hr_utility.set_location (' Date '||nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date)),222);
5062 --
5063 if l_create_current_enb and l_current_plan_id = l_epe.pl_id
5064 and nvl(l_current_oipl_id,-1) = nvl(l_epe.oipl_id,-1) then
5065 --
5066 hr_utility.set_location ('l_person_id '||l_person_id,222);
5067 --
5068 open c_current_enb(l_epe.pl_id,l_epe.oipl_id,
5069 nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date))) ; -- FONM
5070 fetch c_current_enb into l_current_enb ;
5071 if c_current_enb%found and not p_calculate_only_mode then
5072 hr_utility.set_location('SAME interim row',111);
5073 ben_enrt_bnft_api.create_enrt_bnft
5074 (p_validate => false,
5075 p_dflt_flag => 'N',
5076 p_val_has_bn_prortd_flag => 'N', -- change when prorating
5077 p_bndry_perd_cd => l_current_enb.bndry_perd_cd, -- l_cvg(0).bndry_perd_cd,
5078 p_bnft_typ_cd => l_current_enb.bnft_typ_cd, -- l_cvg(0).bnft_typ_cd,
5079 p_val => l_current_enb.bnft_amt, -- l_rstrn.mx_cvg_alwd_amt, /*ENH */
5080 p_nnmntry_uom => l_current_enb.nnmntry_uom, -- l_cvg(0).nnmntry_uom,
5081 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
5082 p_prtt_enrt_rslt_id => l_current_enb.prtt_enrt_rslt_id,
5083 p_business_group_id => l_current_enb.business_group_id, -- l_cvg(0).business_group_id,
5084 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
5085 p_program_application_id => fnd_global.prog_appl_id,
5086 p_program_id => fnd_global.conc_program_id,
5087 p_request_id => fnd_global.conc_request_id,
5088 p_comp_lvl_fctr_id => l_current_enb.comp_lvl_fctr_id, --l_cvg(0).comp_lvl_fctr_id,
5089 p_cvg_mlt_cd => l_current_enb.cvg_mlt_cd, -- l_cvg(0).cvg_mlt_cd,
5090 p_crntly_enrld_flag => 'N',
5091 p_ctfn_rqd_flag => 'N',
5092 p_entr_val_at_enrt_flag => 'N',
5093 p_mx_val => null, -- max with ctfn
5094 p_mx_wout_ctfn_val => null, -- max without ctfn
5095 p_mn_val => null,
5096 p_incrmt_val => null,
5097 p_dflt_val => null,
5098 p_rt_typ_cd => l_current_enb.rt_typ_cd, -- l_cvg(0).rt_typ_cd,
5099 p_mx_wo_ctfn_flag => 'Y',
5100 p_program_update_date => sysdate,
5101 p_enrt_bnft_id => l_enrt_bnft_id,
5102 p_object_version_number => l_object_version_number,
5103 p_ordr_num => -1);
5104 end if;
5105 close c_current_enb ;
5106 end if;
5107 --
5108 end if;
5109 hr_utility.set_location ('Leaving '||l_package,10);
5110 --
5111 end main;
5112 --
5113 end ben_determine_coverage;