DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_TIMECARD_APPROVAL

Source


1 package body hxc_timecard_approval as
2 /* $Header: hxctimeapprove.pkb 120.8.12010000.5 2009/10/05 12:09:47 amakrish ship $ */
3 
4   g_package varchar2(30) := 'hxc_timecard_approval.';
5   g_debug boolean := hr_utility.debug_enabled;
6 
7   TYPE application_period_table IS TABLE OF hxc_app_period_summary.APPLICATION_PERIOD_ID%TYPE;
8   TYPE tc_ap_links IS RECORD
9     (TIMECARD_ID			hxc_tc_ap_links.TIMECARD_ID%TYPE,
10      APPLICATION_PERIOD_ID		hxc_tc_ap_links.APPLICATION_PERIOD_ID%TYPE
11      );
12   TYPE tc_ap_links_table IS TABLE OF tc_ap_links INDEX BY BINARY_INTEGER;
13 
14   TYPE time_recipient_table IS TABLE OF HXC_TIME_RECIPIENTS.TIME_RECIPIENT_ID%TYPE INDEX BY BINARY_INTEGER;
15 
16   TYPE application_period_id_arr IS TABLE OF hxc_tc_ap_links.APPLICATION_PERIOD_ID%TYPE INDEX BY BINARY_INTEGER;
17 
18   TYPE time_building_block_id_arr IS TABLE OF hxc_ap_detail_links.TIME_BUILDING_BLOCK_ID%TYPE INDEX BY BINARY_INTEGER;
19 
20   TYPE time_building_block_ovn_arr IS TABLE OF hxc_ap_detail_links.TIME_BUILDING_BLOCK_OVN%TYPE INDEX BY BINARY_INTEGER;
21 
22   TYPE ap_detail_links_rec IS RECORD
23     (APPLICATION_PERIOD_ID		application_period_id_arr,
24      TIME_BUILDING_BLOCK_ID	time_building_block_id_arr,
25      TIME_BUILDING_BLOCK_OVN	time_building_block_ovn_arr
26      );
27 
28   TYPE timecard_info IS RECORD
29     (TIME_BUILDING_BLOCK_ID	HXC_TIME_BUILDING_BLOCKS.TIME_BUILDING_BLOCK_ID%TYPE,
30      OBJECT_VERSION_NUMBER	HXC_TIME_BUILDING_BLOCKS.OBJECT_VERSION_NUMBER%TYPE,
31      TYPE			HXC_TIME_BUILDING_BLOCKS.TYPE%TYPE,
32      START_TIME		HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE,
33      STOP_TIME		HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE,
34      RESOURCE_ID		HXC_TIME_BUILDING_BLOCKS.RESOURCE_ID%TYPE,
35      RESOURCE_TYPE		HXC_TIME_BUILDING_BLOCKS.RESOURCE_TYPE%TYPE,
36      APPROVAL_STYLE_ID	HXC_TIME_BUILDING_BLOCKS.APPROVAL_STYLE_ID%TYPE,
37      APPLICATION_SET_ID	HXC_TIME_BUILDING_BLOCKS.APPLICATION_SET_ID%TYPE,
38      CREATION_DATE		HXC_TIME_BUILDING_BLOCKS.CREATION_DATE%TYPE
39      );
40 
41   g_light_approval_style_id number	:= -99;
42 
43   Function get_item_key return number is
44     l_item_key number;
45   Begin
46       select hxc_approval_item_key_s.nextval
47         into l_item_key
48         from dual;
49 
50     return l_item_key;
51 
52   End get_item_key;
53 
54   Function is_timecard_resubmitted
55     (p_timecard_id in hxc_time_building_blocks.time_building_block_id%type,
56      p_timecard_ovn in hxc_time_building_blocks.object_version_number%type,
57      p_resource_id in hxc_time_building_blocks.resource_id%type,
58      p_start_time  in hxc_time_building_blocks.start_time%type,
59      p_stop_time   in hxc_time_building_blocks.stop_time%type
60      ) return varchar2 is
61 
62     cursor csr_resubmitted
63       (p_timecard_id IN HXC_TIME_BUILDING_BLOCKS.TIME_BUILDING_BLOCK_ID%TYPE,
64        p_max_ovn     IN HXC_TIME_BUILDING_BLOCKS.OBJECT_VERSION_NUMBER%TYPE
65        ) is
66       select 'YES'
67         from hxc_time_building_blocks
68        where time_building_block_id = p_timecard_id
69          and object_version_number <= p_max_ovn
70          and approval_status = 'SUBMITTED';
71 
72     cursor csr_further_check
73       (p_timecard_id in hxc_time_building_blocks.time_building_block_id%type,
74        p_resource_id in hxc_time_building_blocks.resource_id%type,
75        p_start_time in hxc_time_building_blocks.start_time%type,
76        p_stop_time in hxc_time_building_blocks.stop_time%type
77        ) is
78       select 'YES'
79         from hxc_time_building_blocks
80        where time_building_block_id <> p_timecard_id
81          and approval_status = 'SUBMITTED'
82          and start_time <= p_stop_time
83          and stop_time >= p_start_time
84          and resource_id = p_resource_id
85          and scope = 'TIMECARD';
86 
87     l_resubmitted varchar2(3) := 'NO';
88 
89   Begin
90 
91     open csr_resubmitted(p_timecard_id, p_timecard_ovn);
92     fetch csr_resubmitted into l_resubmitted;
93     if(csr_resubmitted%NOTFOUND) then
94       close csr_resubmitted;
95       open csr_further_check(p_timecard_id, p_resource_id, p_start_time, p_stop_time);
96       fetch csr_further_check into l_resubmitted;
97       if (csr_further_check%NOTFOUND) then
98         l_resubmitted := 'NO';
99       end if;
100       close csr_further_check;
101     else
102       close csr_resubmitted;
103     end if;
104 
105     return l_resubmitted;
106 
107   Exception
108     When others then
109       return l_resubmitted;
110 
111   End is_timecard_resubmitted;
112 
113   Procedure get_timecard_information
114     (p_blocks       in            hxc_block_table_type,
115      p_timecard_id     out nocopy hxc_time_building_blocks.time_building_block_id%type,
116      p_timecard_ovn    out nocopy hxc_time_building_blocks.object_version_number%type,
117      p_new_blocks      out nocopy varchar2,
118      p_timecard_info   out nocopy timecard_info
119      ) is
120     l_timecard_index number;
121   Begin
122     l_timecard_index := hxc_timecard_block_utils.find_active_timecard_index(p_blocks);
123     p_timecard_id  := p_blocks(l_timecard_index).time_building_block_id;
124     p_timecard_ovn := p_blocks(l_timecard_index).object_version_number;
125     p_new_blocks   := hxc_timecard_block_utils.any_new_blocks(p_blocks);
126     p_timecard_info.time_building_block_id	:= p_blocks(l_timecard_index).time_building_block_id;
127     p_timecard_info.object_version_number	:= p_blocks(l_timecard_index).object_version_number;
128     p_timecard_info.type			:= p_blocks(l_timecard_index).type;
129     p_timecard_info.start_time		:= to_date(p_blocks(l_timecard_index).start_time,'rrrr/mm/dd hh24:mi:ss');
130     p_timecard_info.stop_time		:= to_date(p_blocks(l_timecard_index).stop_time,'rrrr/mm/dd hh24:mi:ss');
131     p_timecard_info.resource_id		:= p_blocks(l_timecard_index).resource_id;
132     p_timecard_info.resource_type		:= p_blocks(l_timecard_index).resource_type;
133     p_timecard_info.approval_style_id	:= p_blocks(l_timecard_index).approval_style_id;
134     p_timecard_info.application_set_id	:= p_blocks(l_timecard_index).application_set_id;
135   End get_timecard_information;
136 
137 
138   Procedure light_approve_timecards
139     (p_tc_bb_id       IN            number,
140      p_tc_ovn         IN            number,
141      p_tc_resubmitted IN            varchar2,
142      p_blocks  	      IN	    hxc_block_table_type,
143      p_timecard_info  IN	    timecard_info,
144      p_messages	      IN OUT NOCOPY HXC_MESSAGE_TABLE_TYPE
145      )is
146 
147     Cursor c_get_tc_ap_links
148     is
149       select timecard_id,
150              application_period_id
151         from hxc_tc_ap_links
152        where timecard_id = p_tc_bb_id;
153 
154     Cursor c_creation_date
155       (l_app_id hxc_time_building_blocks.time_building_block_id%TYPE,
156        l_app_ovn hxc_time_building_blocks.object_version_number%TYPE
157        ) is
158       select creation_date
159         from hxc_time_building_blocks
160        where time_building_block_id = l_app_id
161          and object_version_number = l_app_ovn;
162 
163     cursor c_app_period
164       (p_resource_id hxc_time_building_blocks.resource_id%TYPE,
165        p_start_time  hxc_time_building_blocks.start_time%TYPE,
166        p_stop_time   hxc_time_building_blocks.stop_time%TYPE,
167        p_time_recipient_id hxc_time_recipients.time_recipient_id%TYPE
168        ) is
169       select application_period_id
170         from hxc_app_period_summary
171        where resource_id = p_resource_id
172          and trunc(start_time) = trunc(p_start_time)
173          and trunc(stop_time) = trunc(p_stop_time)
174          and time_recipient_id  = p_time_recipient_id
175          and recipient_sequence IS NULL
176          and time_category_id IS NULL
177          and category_sequence IS NULL
178          and approval_comp_id IS NULL;
179 
180     cursor c_get_apps_from_app_set
181       (p_app_set number) is
182       select htr.time_recipient_id
183         from hxc_application_sets_v has,
184              hxc_application_set_comps_v hasc,
185              hxc_time_recipients htr
186        where has.application_set_id = p_app_set
187          and hasc.application_set_id = has.application_set_id
188          and hasc.time_recipient_id = htr.time_recipient_id;
189 
190     l_application_set_id  	HXC_APPLICATION_SETS_V.APPLICATION_SET_ID%TYPE;
191     l_appl_recipients 		time_recipient_table;
192     l_time_building_block_id	HXC_TIME_BUILDING_BLOCKS.TIME_BUILDING_BLOCK_ID%TYPE ;
193     l_object_version_number	HXC_TIME_BUILDING_BLOCKS.OBJECT_VERSION_NUMBER%TYPE ;
194     l_resource_id  		HXC_TIME_BUILDING_BLOCKS.RESOURCE_ID%TYPE ;
195     l_resource_type 		HXC_TIME_BUILDING_BLOCKS.RESOURCE_TYPE%TYPE ;
196     l_timecard_type 		HXC_TIME_BUILDING_BLOCKS.TYPE%TYPE ;
197     l_timecard_start_time 	HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE ;
198     l_timecard_stop_time  	HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE ;
199     l_period_start_date		HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE ;
200     l_period_end_date		HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE ;
201     l_tc_ap_links_table		tc_ap_links_table;
202     l_index 			number ;
203     l_assignment_periods        hxc_timecard_utilities.periods;
204     l_app_period_info 		application_period_table;
205     l_creation_date 		hxc_time_building_blocks.creation_date%TYPE := NULL;
206     l_dup_index			number;
207     l_detail_array		ap_detail_links_rec;
208     l_index_1			number;
209     l_index_2			number;
210     l_timecard_blocks  		hxc_timecard.block_list;
211     l_day_blocks       		hxc_timecard.block_list;
212     l_detail_blocks    		hxc_timecard.block_list;
213     l_proc                      varchar2(70);
214 
215   Begin
216     if g_debug then
217       l_proc := g_package||'light_approve_timecards';
218       hr_utility.set_location('Processing '||l_proc, 10);
219     end if;
220 
221     l_timecard_type	:=	p_timecard_info.TYPE;
222     l_timecard_start_time	:=	p_timecard_info.START_TIME;
223     l_timecard_stop_time	:=	p_timecard_info.STOP_TIME;
224     l_resource_id		:=	p_timecard_info.RESOURCE_ID;
225     l_resource_type	:=	p_timecard_info.RESOURCE_TYPE;
226     l_application_set_id	:=	p_timecard_info.APPLICATION_SET_ID;
227 
228 
229 /*Cancel all the previous notifications for this Timecard. The rationale
230 * is, this Timecard is going to be Light approved, which means there should
231 * be no open notifications for this Timecard. If the Timecard had previously
232 * been associated with some other Approval style, then the notifications
233 * generated, if any should be CANCELLED. */
234 
235 
236     if g_debug then
237       hr_utility.set_location('Processing '||l_proc, 20);
238     end if;
239 
240     hxc_find_notify_aprs_pkg.cancel_previous_notifications
241       (p_timecard_id => p_tc_bb_id);
242 
243 /*Remove existing records from hxc_tc_ap_links
244 * Most probably there wont be any records as they would have
245 * been deleted in the hxc_timecard package      */
246 
247     hxc_tc_ap_links_pkg.remove_timecard_links
248       (p_timecard_id => p_tc_bb_id );
249 
250     open c_get_apps_from_app_set(l_application_set_id );
251     fetch c_get_apps_from_app_set BULK COLLECT INTO l_appl_recipients;
252 
253     if l_appl_recipients.count > 0 then
254 /* Loop through all the recipient applications */
255       for l_index IN l_appl_recipients.first .. l_appl_recipients.last LOOP
256         if g_debug then
257           hr_utility.set_location('Processing '||l_proc, 30);
258         end if;
259         l_period_start_date	:= l_timecard_start_time;
260         l_period_end_date	:= l_timecard_stop_time;
261 /* Get any existing Application period for the same resource_id, recipient_id, start and stop time */
262         open c_app_period
263           (l_resource_id,
264            l_period_start_date,
265            l_period_end_date,
266            l_appl_recipients(l_index)
267            );
268 
269         fetch c_app_period bulk collect into l_app_period_info;
270         close c_app_period;
271 
272         if l_app_period_info.count > 0 then
273           if g_debug then
274             hr_utility.set_location('Processing '||l_proc, 40);
275           end if;
276 
277           for l_dup_index IN  l_app_period_info.first .. l_app_period_info.last loop
278             if g_debug then
279               hr_utility.set_location('Processing '||l_proc, 50);
280             end if;
281  /* Remove the existing record from hxc_ap_detail_links table */
282             hxc_ap_detail_links_pkg.delete_ap_detail_links(p_application_period_id => l_app_period_info(l_dup_index));
283 /* Remove the record from hxc_app_period_summary table */
284             hxc_app_period_summary_pkg.delete_summary_row(p_app_period_id => l_app_period_info(l_dup_index) );
285           End loop;
286         end if;
287       end loop;
288 
289     else
290       if g_debug then
291         hr_utility.set_location('Processing '||l_proc, 60);
292       end if;
293       fnd_message.set_name('HXC', 'HXC_APR_NO_APPL_SET_PREF');
294       fnd_message.raise_error;
295     end if;
296 
297 /* For each of the recipient Application present in the Application set of the person*/
298 /* We get the detail blocks of the Timecard from p_blocks */
299 
300     hxc_timecard_block_utils.sort_blocks
301       (p_blocks          => p_blocks,
302        p_timecard_blocks => l_timecard_blocks,
303        p_day_blocks      => l_day_blocks,
304        p_detail_blocks   => l_detail_blocks
305        );
306 
307 
308     l_index_1 := l_detail_blocks.first;
309     l_index_2  := 1;
310     loop
311       EXIT WHEN NOT l_detail_blocks.exists(l_index_1);
312       if g_debug then
313         hr_utility.set_location('Processing '||l_proc, 70);
314       end if;
315       l_detail_array.TIME_BUILDING_BLOCK_ID(l_index_2) := p_blocks(l_detail_blocks(l_index_1)).time_building_block_id  ;
316       l_detail_array.TIME_BUILDING_BLOCK_OVN(l_index_2) := p_blocks(l_detail_blocks(l_index_1)).object_version_number ;
317       l_index_2 := l_index_2 + 1;
318       l_index_1 := l_detail_blocks.next(l_index_1);
319     end loop;
320     if g_debug then
321       hr_utility.set_location('Processing '||l_proc, 80);
322     end if;
323 
324     for l_index IN l_appl_recipients.first .. l_appl_recipients.last LOOP
325      /* Call to create an Application period  in hxc_time_building blocks table */
326       l_time_building_block_id := null;
327       l_object_version_number  := null;
328 
329       if g_debug then
330         hr_utility.set_location('Processing '||l_proc, 90);
331       end if;
332 
333       hxc_building_block_api.create_building_block
334         (p_effective_date            => trunc(SYSDATE),
335          p_type                      => l_timecard_type,
336          p_measure                   => null,
337          p_unit_of_measure           => null,
338          p_start_time                => l_timecard_start_time,
339          p_stop_time                 => l_timecard_stop_time,
340          p_parent_building_block_id  => null,
341          p_parent_building_block_ovn => null,
342          p_scope                     => 'APPLICATION_PERIOD',
343          p_approval_style_id         => null,
344          p_approval_status           => 'APPROVED',
345          p_resource_id               => l_resource_id,
346          p_resource_type             => l_resource_type,
347          p_comment_text              => 'LIGHT_APPROVAL',
348          p_application_set_id        => null,
349          p_translation_display_key   => null,
350          p_time_building_block_id    => l_time_building_block_id,
351          p_object_version_number     => l_object_version_number
352          );
353 
354 
355 /* Get the creation date of the Timecard to populate in the hxc_app_period_summary table */
356       open c_creation_date(l_time_building_block_id , l_object_version_number );
357       fetch c_creation_date into l_creation_date;
358       close c_creation_date;
359       if g_debug then
360         hr_utility.set_location('Processing '||l_proc, 100);
361       end if;
362 
363    /* Call to create the Application period  in hxc_app_period_summary table */
364       hxc_app_period_summary_pkg.insert_summary_row
365         (p_application_period_id => l_time_building_block_id,
366          p_application_period_ovn=> l_object_version_number,
367          p_approval_status       => 'APPROVED',
368          p_time_recipient_id     => l_appl_recipients(l_index),
369          p_time_category_id      => NULL,
370          p_start_time	       => l_timecard_start_time,
371          p_stop_time	       => l_timecard_stop_time,
372          p_resource_id	       => l_resource_id,
373          p_recipient_sequence    => null,
374          p_category_sequence     => null,
375          p_creation_date         => l_creation_date,
376          p_notification_status   => 'FINISHED',
377          p_approver_id           => null,
378          p_approval_comp_id      => null,
379          p_approval_item_type    => NULL,
380          p_approval_process_name => NULL,
381          p_approval_item_key     => NULL,
382          p_data_set_id 	       => null	----- Passing data set id as null explicitly.,
383          );
384 
385 
386    /* Call to create the Timecard - Application period  link in hxc_yc_ap_links table */
387       hxc_tc_ap_links_pkg.insert_summary_row
388         (p_timecard_id           => p_tc_bb_id,
389          p_application_period_id => l_time_building_block_id
390          );
391 
392    /* Call to get all the detail records of the Timecard and populate the nested array l_detail_array */
393       --Fix the bug 4506258. Added the if condition to take care of empty PL/SQL table when empty TC is submitted
394       if(l_detail_array.time_building_block_id.count>0) then
395         For l_index_app IN l_detail_array.TIME_BUILDING_BLOCK_ID.first .. l_detail_array.TIME_BUILDING_BLOCK_ID.last LOOP
396           l_detail_array.application_period_id(l_index_app) :=   l_time_building_block_id ;
397         End loop;
398       end if;
399       if g_debug then
400         hr_utility.set_location('Processing '||l_proc, 110);
401       end if;
402    /* Bulk insert the nested array into the hxc_ap_detail_links table */
403       --Fix the bug 4506258. Added the if condition to take care of empty PL/SQL table when empty TC is submitted
404       if(l_detail_array.application_period_id.count>0) then
405         forall l_dup_index in l_detail_array.application_period_id.first .. l_detail_array.application_period_id.last
406           insert into hxc_ap_detail_links
407           values ( l_detail_array.APPLICATION_PERIOD_ID(l_dup_index),
408                    l_detail_array.TIME_BUILDING_BLOCK_ID(l_dup_index),
409                    l_detail_array.TIME_BUILDING_BLOCK_OVN(l_dup_index)
410                    );
411       end if;
412     end loop;
413     if g_debug then
414       hr_utility.set_location('Processing '||l_proc, 120);
415     end if;
416 
417       update hxc_timecard_summary
418          set approval_status = hxc_timecard.c_approved_status
419        where timecard_id = p_tc_bb_id;
420 
421     if g_debug then
422       hr_utility.set_location('Processing '||l_proc, 130);
423     end if;
424 
425   -- OTL-Absences Integration (Bug 8779478)
426     IF (nvl(fnd_profile.value('HR_ABS_OTL_INTEGRATION'), 'N') = 'Y') THEN
427        IF g_debug THEN
428         	hr_utility.trace('Initiated Online Retrieval from HXC_TIMECARD_APPROVAL.LIGHT_APPROVE_TIMECARDS');
429        END IF;
430 
431        HXC_ABS_RETRIEVAL_PKG.POST_ABSENCES(l_resource_id,
432        					   l_timecard_start_time,
433        					   l_timecard_stop_time,
434        					   hxc_timecard.c_approved_status,
435        					   p_messages);
436 
437     END IF;
438 
439   end light_approve_timecards;
440 
441   Function active_assignment_over_period
442     (p_timecard_info timecard_info,
443      p_timecard_props hxc_timecard_prop_table_type)
444     return Boolean is
445 
446     l_return     boolean := true;
447     l_types_done boolean := false;
448     l_pind       binary_integer;
449 
450   Begin
451     l_pind := p_timecard_props.last;
452     Loop
453       Exit when ((not p_timecard_props.exists(l_pind))
454                  or
455                  (not l_return)
456                  or
457                  (l_types_done)
458                  );
459       if(p_timecard_props(l_pind).property_name = 'ResourceAssignmentStatusType') then
460         if(p_timecard_props(l_pind).date_from <= p_timecard_info.stop_time) then
461           if(p_timecard_props(l_pind).date_to >= p_timecard_info.start_time) then
462             if(p_timecard_props(l_pind).property_value not in ('ACTIVE_ASSIGN','ACTIVE_CWK',
463             						       'SUSP_ASSIGN','TERM_ASSIGN',  -- Bug 8271321
464             						       'SUSP_CWK_ASG')) then
465               l_return := false;
466             end if;
467           end if;
468         end if;
469       else
470         l_types_done := true;
471       end if;
472       l_pind := l_pind - 1;
473     End Loop;
474 
475     return l_return;
476   end active_assignment_over_period;
477   -- 115.12
478   -- Added timecard properties and messages in case of
479   -- non active assignment
480   Function begin_approval
481     (p_blocks         in            hxc_block_table_type,
482      p_item_type      in            wf_items.item_type%type,
483      p_process_name   in            wf_process_activities.process_name%type,
484      p_resubmitted    in            varchar2,
485      p_timecard_props in            hxc_timecard_prop_table_type,
486      p_messages       in out nocopy hxc_message_table_type
487      ) return VARCHAR2 is
488 
489     l_item_key            number;
490     l_timecard_id         hxc_time_building_blocks.time_building_block_id%type;
491     l_timecard_ovn        hxc_time_building_blocks.object_version_number%type;
492     l_new_building_blocks varchar2(3) := 'NO';
493     l_proc                varchar2(70);
494     l_dummy		  varchar2(1);
495     l_active_asg          boolean := true;
496 
497     Cursor c_get_appr_style is
498       Select APPROVAL_STYLE_ID
499         from hxc_approval_styles
500        where NAME = 'Approval on Submit' ;
501 
502     l_timecard_info		timecard_info;
503 
504   Begin
505 
506     g_debug := hr_utility.debug_enabled;
507 
508     if g_debug then
509       l_proc := g_package||'begin_approval';
510       hr_utility.set_location('Processing '||l_proc, 10);
511     end if;
512 
513     get_timecard_information
514       (p_blocks       => p_blocks,
515        p_timecard_id  => l_timecard_id,
516        p_timecard_ovn => l_timecard_ovn,
517        p_new_blocks   => l_new_building_blocks,
518        p_timecard_info => l_timecard_info
519        );
520 
521     if g_debug then
522       hr_utility.set_location('Processing '||l_proc, 20);
523     end if;
524 
525     IF g_light_approval_style_id = -99 then
526       if g_debug then
527 	hr_utility.set_location('Processing '||l_proc, 30);
528       end if;
529 
530       open c_get_appr_style;
531       fetch c_get_appr_style into g_light_approval_style_id;
532       close c_get_appr_style ;
533 
534     end if;
535     -- 115.12 Call active assignment over period, if false
536     -- we must use approve on submit approval style
537     l_active_asg := active_assignment_over_period(l_timecard_info,p_timecard_props);
538 
539     If ((l_timecard_info.approval_style_id <> g_light_approval_style_id)
540        AND
541         (l_active_asg)) then
542 
543       if g_debug then
544 	hr_utility.set_location('Processing '||l_proc, 40);
545       end if;
546 
547       l_item_key := get_item_key;
548       hxc_approval_wf_pkg.start_approval_wf_process
549         (p_item_type      => p_item_type,
550          p_item_key       => to_char(l_item_key),
551          p_process_name   => p_process_name,
552          p_tc_bb_id       => l_timecard_id,
553          p_tc_ovn         => l_timecard_ovn,
554          p_tc_resubmitted => p_resubmitted,
555          p_bb_new         => l_new_building_blocks
556          );
557 
558     else
559       if g_debug then
560 	hr_utility.set_location('Processing '||l_proc, 50);
561       end if;
562       light_approve_timecards
563         (p_tc_bb_id       => l_timecard_id,
564          p_tc_ovn         => l_timecard_ovn,
565          p_tc_resubmitted => p_resubmitted,
566          p_blocks         => p_blocks,
567          p_timecard_info  => l_timecard_info,
568          p_messages	  => p_messages
569          );
570     end if;
571     -- If the timekeeper has entered time for a suspended or
572     -- other non-active assignment, we should inform them
573     -- that the timecard has been auto-approved.
574     if(not l_active_asg) then
575       -- Add informational Message
576       hxc_timecard_message_helper.addErrorToCollection
577         (p_messages,
578          'HXC_366547_INACTIVE_ASG_APPR',
579          hxc_timecard.c_business_message,
580          null,
581          null,
582          hxc_timecard.c_hxc,
583          l_timecard_id,
584          l_timecard_ovn,
585          null,
586          null
587          );
588     end if;
589 
590     if g_debug then
591       hr_utility.set_location('Processing '||l_proc, 60);
592     end if;
593 
594     return to_char(l_item_key);
595 
596   End begin_approval;
597 
598 end hxc_timecard_approval;