[Home] [Help]
PACKAGE BODY: APPS.HXC_TIMEKEEPER
Source
1 PACKAGE body hxc_timekeeper AS
2 /* $Header: hxctimekeeper.pkb 120.7.12010000.2 2008/08/05 12:08:10 ubhat ship $ */
3
4 g_package varchar2(50) := 'HXC_TIMEKEEPER';
5
6 ----
7 ----
8 ----
9 Procedure remove_blank_attribute_rows
10 (p_attributes in out nocopy hxc_attribute_table_type) is
11
12 l_index number;
13
14 Begin
15
16 l_index := p_attributes.first;
17
18 Loop
19 Exit when not p_attributes.exists(l_index);
20
21 if(
22 ( p_attributes(l_index).attribute_category not like 'COST%'
23 and p_attributes(l_index).attribute_category not like 'GRP%'
24 and p_attributes(l_index).attribute_category not like 'ELEMENT%'
25 and p_attributes(l_index).attribute_category not like 'PAEXPITDFF%'
26 and p_attributes(l_index).attribute_category not like 'POS%'
27 and p_attributes(l_index).attribute_category not like 'JOB%'
28 )
29 AND
30 (p_attributes(l_index).attribute1 is null)
31 AND
32 (p_attributes(l_index).attribute2 is null)
33 AND
34 (p_attributes(l_index).attribute3 is null)
35 AND
36 (p_attributes(l_index).attribute4 is null)
37 AND
38 (p_attributes(l_index).attribute5 is null)
39 AND
40 (p_attributes(l_index).attribute6 is null)
41 AND
42 (p_attributes(l_index).attribute7 is null)
43 AND
44 (p_attributes(l_index).attribute8 is null)
45 AND
46 (p_attributes(l_index).attribute9 is null)
47 AND
48 (p_attributes(l_index).attribute10 is null)
49 AND
50 (p_attributes(l_index).attribute11 is null)
51 AND
52 (p_attributes(l_index).attribute12 is null)
53 AND
54 (p_attributes(l_index).attribute13 is null)
55 AND
56 (p_attributes(l_index).attribute14 is null)
57 AND
58 (p_attributes(l_index).attribute15 is null)
59 AND
60 (p_attributes(l_index).attribute16 is null)
61 AND
62 (p_attributes(l_index).attribute17 is null)
63 AND
64 (p_attributes(l_index).attribute18 is null)
65 AND
66 (p_attributes(l_index).attribute19 is null)
67 AND
68 (p_attributes(l_index).attribute20 is null)
69 AND
70 (p_attributes(l_index).attribute21 is null)
71 AND
72 (p_attributes(l_index).attribute22 is null)
73 AND
74 (p_attributes(l_index).attribute23 is null)
75 AND
76 (p_attributes(l_index).attribute24 is null)
77 AND
78 (p_attributes(l_index).attribute25 is null)
79 AND
80 (p_attributes(l_index).attribute26 is null)
81 AND
82 (p_attributes(l_index).attribute27 is null)
83 AND
84 (p_attributes(l_index).attribute28 is null)
85 AND
86 (p_attributes(l_index).attribute29 is null)
87 AND
88 (p_attributes(l_index).attribute30 is null)
89 ) then
90
91 p_attributes.delete(l_index);
92 end if;
93
94 l_index := p_attributes.next(l_index);
95
96 End Loop;
97
98 End remove_blank_attribute_rows;
99
100 ----------------------------------------------------------------------------
101 -- Save Timecard Procedure
102 -- This procedure....
103 ----------------------------------------------------------------------------
104 Procedure save_timecard
105 (p_blocks in out nocopy HXC_BLOCK_TABLE_TYPE
106 ,p_attributes in out nocopy HXC_ATTRIBUTE_TABLE_TYPE
107 ,p_messages in out nocopy HXC_MESSAGE_TABLE_TYPE
108 ,p_timecard_id out nocopy hxc_time_building_blocks.time_building_block_id%type
109 ,p_timecard_ovn out nocopy hxc_time_building_blocks.object_version_number%type
110 ,p_timekeeper_id in hxc_time_building_blocks.resource_id%type DEFAULT NULL
111 ,p_tk_audit_enabled in VARCHAR2 DEFAULT NULL
112 ,p_tk_notify_to in VARCHAR2 DEFAULT NULL
113 ,p_tk_notify_type in VARCHAR2 DEFAULT NULL
114 ) is
115
116
117 cursor c_previous_timecard(
118 p_timecard_id in hxc_timecard_summary.timecard_id%type) is
119 select tk_audit_item_key,tk_audit_item_type
120 from hxc_timecard_summary
121 where timecard_id = p_timecard_id;
122
123 l_timecard_blocks hxc_timecard.block_list;
124 l_day_blocks hxc_timecard.block_list;
125 l_detail_blocks hxc_timecard.block_list;
126 l_transaction_info hxc_timecard.transaction_info;
127 l_timecard_props hxc_timecard_prop_table_type;
128 l_proc varchar2(50) := g_package||'.SAVE_CONTROLLER';
129 l_timecard_index number;
130
131 l_old_style_blks hxc_self_service_time_deposit.timecard_info;
132 l_old_style_attrs hxc_self_service_time_deposit.building_block_attribute_info;
133 l_old_messages hxc_self_service_time_deposit.message_table;
134
135 l_resubmit varchar2(10) := hxc_timecard_deposit_common.c_no;
136
137 l_rollback BOOLEAN := FALSE;
138 l_status_error BOOLEAN := FALSE;
139 e_timekeeper_check EXCEPTION;
140
141 l_item_key WF_ITEMS.ITEM_KEY%TYPE :=NULL;
142
143 l_previous_tk_item_key hxc_timecard_summary.tk_audit_item_key%type;
144 l_previous_tk_item_type hxc_timecard_summary.tk_audit_item_type%type;
145
146 tk_audit_item_type WF_ITEMS.ITEM_TYPE%TYPE :=NULL;
147 tk_audit_process_name VARCHAR2(50) :=NULL;
148
149 n number;
150
151
152 Begin
153
154 --
155 -- Fnd initialization
156 --
157 fnd_msg_pub.initialize;
158 /*
159 IF g_debug THEN
160 hxc_debug_timecard.writeTimecard(p_blocks,p_attributes,'HXC_TIMEKEEPER',10);
161 END IF;
162 */
163 ----------------------------------------------------------------------------
164 -- Timecard Preparation
165 ----------------------------------------------------------------------------
166 hxc_timecard_message_helper.initializeerrors;
167
168 p_messages := hxc_message_table_type ();
169
170 hxc_timecard_block_utils.initialize_timecard_index;
171
172 --
173 -- Check input parameters
174 --
175 hxc_deposit_checks.check_inputs
176 (p_blocks => p_blocks
177 ,p_attributes => p_attributes
178 ,p_deposit_mode => hxc_timecard_deposit_common.c_save
179 ,p_template => hxc_timecard_deposit_common.c_no
180 ,p_messages => p_messages
181 );
182 /*
183 -- debug
184 IF g_debug THEN
185 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',20);
186 END IF;
187 */
188 hxc_timecard_message_helper.processerrors
189 (p_messages => p_messages);
190
191 --
192 -- First we are getting the preference
193 -- for the resource of the timecard
194 --
195
196 l_timecard_index := hxc_timecard_block_utils.find_active_timecard_index(p_blocks);
197
198 -- this procedure has the otl setup validation
199 hxc_timecard_properties.get_preference_properties
200 (p_validate => hxc_timecard_deposit_common.c_yes
201 ,p_resource_id => p_blocks(l_timecard_index).resource_id
202 ,p_timecard_start_time => fnd_date.canonical_to_date(p_blocks(l_timecard_index).start_time)
203 ,p_timecard_stop_time => fnd_date.canonical_to_date(p_blocks(l_timecard_index).stop_time)
204 ,p_for_timecard => false
205 ,p_messages => p_messages
206 ,p_property_table => l_timecard_props
207 );
208 /*
209 -- debug
210 IF g_debug THEN
211 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',30);
212 END IF;
213 */
214 hxc_timecard_message_helper.processerrors
215 (p_messages => p_messages);
216
217 --
218 -- Sort blocks
219 --
220 hxc_timecard_block_utils.sort_blocks
221 (p_blocks => p_blocks
222 ,p_timecard_blocks => l_timecard_blocks
223 ,p_day_blocks => l_day_blocks
224 ,p_detail_blocks => l_detail_blocks
225 );
226
227 ----------------------------------------------------------------------------
228 -- Timecard Prepre-Validation
229 ----------------------------------------------------------------------------
230 --
231 -- Perform basic checks
232 --
233 hxc_deposit_checks.perform_checks
234 (p_blocks => p_blocks
235 ,p_attributes => p_attributes
236 ,p_timecard_props => l_timecard_props
237 ,p_days => l_day_blocks
238 ,p_details => l_detail_blocks
239 ,p_messages => p_messages
240 );
241 /*
242 -- debug
243 IF g_debug THEN
244 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',40);
245 END IF;
246 */
247 hxc_timecard_message_helper.processerrors
248 (p_messages => p_messages);
249
250 ----------------------------------------------------------------------------
251 -- Timecard Preparation
252 ----------------------------------------------------------------------------
253
254 --
255 -- Add the security attributes
256 -- ARR: 115.28 change, added p_messages
257 --
258 hxc_security.add_security_attribute
259 (p_blocks => p_blocks
260 ,p_attributes => p_attributes
261 ,p_timecard_props => l_timecard_props
262 ,p_messages => p_messages
263 );
264
265 hxc_timecard_message_helper.processerrors
266 (p_messages => p_messages);
267 --
268 -- Translate any aliases
269 --
270 hxc_timecard_deposit_common.alias_translation
271 (p_blocks => p_blocks
272 ,p_attributes => p_attributes
273 ,p_messages => p_messages
274 );
275 /*
276 -- debug
277 IF g_debug THEN
278 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',50);
279 END IF;
280 */
281 hxc_timecard_message_helper.processerrors
282 (p_messages => p_messages);
283
284 --
285 -- Set the block and attribute update process flags
286 -- Based on the data sent and in the db
287 --
288 hxc_block_attribute_update.set_process_flags
289 (p_blocks => p_blocks
290 ,p_attributes => p_attributes
291 );
292
293 --
294 -- Removed any deleted attributes
295 --
296
297 hxc_timecard_attribute_utils.remove_deleted_attributes
298 (p_attributes => p_attributes);
299
300 remove_blank_attribute_rows (p_attributes => p_attributes);
301
302 ----------------------------------------------------------------------------
303 -- Timecard Pre-Validation
304 ----------------------------------------------------------------------------
305 --
306 -- Validate the set up for the user
307 --
308 /*
309 hxc_timecard_deposit_common.validate_setup
310 (p_deposit_mode => hxc_timecard.c_save
311 ,p_blocks => p_blocks
312 ,p_attributes => p_attributes
313 ,p_messages => p_messages
314 );
315
316 -- debug
317 IF g_debug THEN
318 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',60);
319 END IF;
320
321 hxc_timecard_message_helper.processerrors
322 (p_messages => p_messages);
323 */
324 /*
325 Call time entry rules for save
326 */
327
328 /*
329 l_old_style_blks := HXC_TIMECARD_BLOCK_UTILS.convert_to_dpwr_blocks
330 (p_blocks);
331
332 l_old_style_attrs := HXC_TIMECARD_ATTRIBUTE_UTILS.convert_to_dpwr_attributes
333 (p_attributes);
334
335 HXC_TIME_ENTRY_RULES_UTILS_PKG.EXECUTE_TIME_ENTRY_RULES
336 (P_OPERATION => hxc_timecard_deposit_common.c_save
337 ,P_TIME_BUILDING_BLOCKS => l_old_style_blks
338 ,P_TIME_ATTRIBUTES => l_old_style_attrs
339 ,P_MESSAGES => l_old_messages
340 ,P_RESUBMIT => hxc_timecard_deposit_common.c_no
341 );
342
343 hxc_timecard_message_utils.append_old_messages
344 (p_messages => p_messages
345 ,p_old_messages => l_old_messages
346 ,p_retrieval_process_id => null
347 );
348
349 hxc_timecard_message_helper.processerrors
350 (p_messages => p_messages);
351 */
352
353 --
354 -- call the application validation
355 --
356 hxc_timecard_validation.recipients_update_validation
357 (p_blocks => p_blocks
358 ,p_attributes => p_attributes
359 ,p_messages => p_messages
360 ,p_props => l_timecard_props
361 ,p_deposit_mode => hxc_timecard_deposit_common.c_save
362 ,p_resubmit => l_resubmit);
363
364 /* fix for bug 6130457 */
365
366 l_timecard_blocks.delete;
367 l_day_blocks.delete;
368 l_detail_blocks.delete;
369
370 /* end of fix for bug 6130457 */
371
372 /* fix by senthil for bug 5099360*/
373 hxc_timecard_block_utils.sort_blocks
374 (p_blocks => p_blocks
375 ,p_timecard_blocks => l_timecard_blocks
376 ,p_day_blocks => l_day_blocks
377 ,p_detail_blocks => l_detail_blocks
378 );
379 /* end of fix for bug 5099360*/
380
381 hxc_timecard_message_helper.processerrors
382 (p_messages => p_messages);
383
384 hxc_timecard_validation.data_set_validation
385 (p_blocks => p_blocks
386 ,p_messages => p_messages
387 );
388
389 hxc_timecard_message_helper.processerrors
390 (p_messages => p_messages);
391
392 --
393 -- At this point of the process
394 -- we know if the timecard needs to be in error.
395 --
396 -- get all the errors
397 p_messages := hxc_timecard_message_helper.getMessages;
398 /*
399 -- debug
400 IF g_debug THEN
401 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',70);
402 END IF;
403 */
404 hxc_timekeeper_errors.rollback_tc_or_set_err_status
405 (p_message_table => p_messages
406 ,p_blocks => p_blocks
407 ,p_attributes => p_attributes
408 ,p_rollback => l_rollback
409 ,p_status_error => l_status_error);
410
411 --p_messages.delete;
412 --
413 -- if the rollback is set then we need to execute it
414 --
415 IF l_rollback THEN
416 -- we are setting the error to be
417 -- send
418 raise e_timekeeper_check;
419
420 ELSE
421 -- p_messages.delete;
422 --
423 -- Store blocks and attributes
424 --
425
426 -- get all the errors before the deposit
427 -- in order to main the -ve ids
428 -- at this point p_messages is not delete
429 -- so we still have the full message structures
430
431 hxc_timecard_deposit.execute
432 (p_blocks => p_blocks
433 ,p_attributes => p_attributes
434 ,p_timecard_blocks => l_timecard_blocks
435 ,p_day_blocks => l_day_blocks
436 ,p_detail_blocks => l_detail_blocks
437 ,p_messages => p_messages
438 ,p_transaction_info => l_transaction_info
439 );
440
441 p_timecard_id :=
442 p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).time_building_block_id;
443 p_timecard_ovn:=
444 p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).object_version_number;
445
446 hxc_timecard_audit.maintain_latest_details
447 (p_blocks => p_blocks );
448
449
450 IF p_timekeeper_id IS NOT NULL and
451 p_tk_audit_enabled = 'Y' and
452 p_tk_notify_to <> 'NONE' THEN
453
454 open c_previous_timecard(p_timecard_id);
455 fetch c_previous_timecard into l_previous_tk_item_key,l_previous_tk_item_type;
456 if (c_previous_timecard%found) then
457
458 --Cancel notifications for TK Audit
459
460 hxc_timekeeper_wf_pkg.cancel_previous_notifications
461 ( p_tk_audit_item_type => l_previous_tk_item_type
462 ,p_tk_audit_item_key => l_previous_tk_item_key
463 );
464
465 end if;
466 close c_previous_timecard;
467
468 l_item_key :=
469 hxc_timekeeper_wf_pkg.begin_audit_process
470 (p_timecard_id => p_timecard_id
471 ,p_timecard_ovn => p_timecard_ovn
472 ,p_resource_id => p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).resource_id
473 ,p_timekeeper_id => p_timekeeper_id
474 ,p_tk_audit_enabled => p_tk_audit_enabled
475 ,p_tk_notify_to => p_tk_notify_to
476 ,p_tk_notify_type => p_tk_notify_type
477 ,p_property_table => l_timecard_props
478 );
479 END IF;
480
481 IF l_item_key IS NOT NULL THEN
482 tk_audit_process_name := 'HXC_TK_AUDIT_PROCESS';
483 tk_audit_item_type := 'HXCTKWF';
484 END IF;
485
486 --hxc_timecard_message_helper.processerrors
487 --(p_messages => p_messages);
488
489 --
490 -- Maintain summary table
491 --
492
493 hxc_timecard_summary_api.timecard_deposit
494 (p_blocks => p_blocks
495 ,p_approval_item_type => NULL
496 ,p_approval_process_name => NULL
497 ,p_approval_item_key => NULL
498 ,p_tk_audit_item_type => tk_audit_item_type
499 ,p_tk_audit_process_name => tk_audit_process_name
500 ,p_tk_audit_item_key => l_item_key
501 );
502
503 hxc_timecard_audit.audit_deposit
504 (p_transaction_info => l_transaction_info
505 ,p_messages => p_messages
506 );
507
508 --
509 -- store error
510 --
511 -- get all the errors
512 -- p_messages := hxc_timecard_message_helper.getMessages;
513 /*
514 if g_debug THEN
515 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',80);
516 end if;
517 */
518
519 -- set the out parameters --
520
521 hxc_timekeeper_errors.maintain_errors
522 (p_messages => p_messages
523 ,p_timecard_id => p_timecard_id
524 ,p_timecard_ovn => p_timecard_ovn);
525
526
527 END IF;
528
529 --dbms_profiler.stop_profiler;
530
531 EXCEPTION
532 WHEN e_timekeeper_check then
533 hxc_timecard_message_helper.prepareErrors;
534 rollback;
535
536 End save_timecard;
537
538
539 ----------------------------------------------------------------------------
540 -- Submit Timecard Procedure
541 -- This procedure....
542 ----------------------------------------------------------------------------
543
544 Procedure submit_timecard
545 (p_blocks in out nocopy HXC_BLOCK_TABLE_TYPE
546 ,p_attributes in out nocopy HXC_ATTRIBUTE_TABLE_TYPE
547 ,p_messages in out nocopy HXC_MESSAGE_TABLE_TYPE
548 ,p_timecard_id out nocopy hxc_time_building_blocks.time_building_block_id%type
549 ,p_timecard_ovn out nocopy hxc_time_building_blocks.object_version_number%type
550 ,p_timekeeper_id in hxc_time_building_blocks.resource_id%type DEFAULT NULL
551 ,p_tk_audit_enabled in VARCHAR2 DEFAULT NULL
552 ,p_tk_notify_to in VARCHAR2 DEFAULT NULL
553 ,p_tk_notify_type in VARCHAR2 DEFAULT NULL
554 ) IS
555
556 cursor c_previous_timecard(
557 p_timecard_id in hxc_timecard_summary.timecard_id%type) is
558 select tk_audit_item_key,tk_audit_item_type
559 from hxc_timecard_summary
560 where timecard_id = p_timecard_id;
561
562
563 l_timecard_blocks hxc_timecard.block_list;
564 l_day_blocks hxc_timecard.block_list;
565 l_detail_blocks hxc_timecard.block_list;
566 l_transaction_info hxc_timecard.transaction_info;
567 l_timecard_props hxc_timecard_prop_table_type;
568
569 l_proc varchar2(50) := g_package||'.SUBMIT_TIMECARD';
570 l_can_deposit boolean := true;
571 l_resubmit varchar2(10) := hxc_timecard_deposit_common.c_no;
572 l_timecard_index number;
573
574 l_rollback BOOLEAN := FALSE;
575
576 l_status_error BOOLEAN := FALSE;
577
578 l_item_key WF_ITEMS.ITEM_KEY%TYPE :=NULL;
579 tk_item_key WF_ITEMS.ITEM_KEY%TYPE :=NULL;
580 tk_audit_item_type WF_ITEMS.ITEM_TYPE%TYPE :=NULL;
581 tk_audit_process_name VARCHAR2(50) :=NULL;
582
583 l_previous_tk_item_key hxc_timecard_summary.tk_audit_item_key%type;
584 l_previous_tk_item_type hxc_timecard_summary.tk_audit_item_type%type;
585
586
587 BEGIN
588
589 --
590 -- Fnd initialization
591 --
592 fnd_msg_pub.initialize;
593
594 ----------------------------------------------------------------------------
595 -- Timecard Preparation
596 ----------------------------------------------------------------------------
597
598 hxc_timecard_block_utils.initialize_timecard_index;
599
600 hxc_timecard_message_helper.initializeerrors;
601
602 p_messages := hxc_message_table_type ();
603
604 --
605 -- Check input parameters
606 --
607
608 hxc_deposit_checks.check_inputs
609 (p_blocks => p_blocks
610 ,p_attributes => p_attributes
611 ,p_deposit_mode => hxc_timecard_deposit_common.c_submit
612 ,p_template => hxc_timecard_deposit_common.c_no
613 ,p_messages => p_messages
614 );
615
616 hxc_timecard_message_helper.processerrors
617 (p_messages => p_messages);
618
619 --
620 -- Determine if this is a resubmitted timecard
621 --
622 l_timecard_index := hxc_timecard_block_utils.find_active_timecard_index(p_blocks);
623
624 if(hxc_timecard_block_utils.date_value(p_blocks(l_timecard_index).date_to)
625 = hr_general.end_of_time)
626 then
627 l_resubmit := hxc_timecard_approval.is_timecard_resubmitted
628 (p_blocks(l_timecard_index).time_building_block_id
629 ,p_blocks(l_timecard_index).object_version_number
630 ,p_blocks(l_timecard_index).resource_id
631 ,hxc_timecard_block_utils.date_value(p_blocks(l_timecard_index).start_time)
632 ,hxc_timecard_block_utils.date_value(p_blocks(l_timecard_index).stop_time)
633 );
634 else
635 l_resubmit := hxc_timecard_deposit_common.c_delete;
636 end if;
637
638 --
639 -- Obtain the timecard properties
640 -- This might be changed to send
641 -- this information in from the
642 -- middle tier, to avoid another
643 -- pref evaluation
644 --
645
646 hxc_timecard_properties.get_preference_properties
647 (p_validate => hxc_timecard_deposit_common.c_yes
648 ,p_resource_id => p_blocks(l_timecard_index).resource_id
649 ,p_timecard_start_time => fnd_date.canonical_to_date(p_blocks(l_timecard_index).start_time)
650 ,p_timecard_stop_time => fnd_date.canonical_to_date(p_blocks(l_timecard_index).stop_time)
651 ,p_for_timecard => false
652 ,p_messages => p_messages
653 ,p_property_table => l_timecard_props
654 );
655
656 hxc_timecard_message_helper.processerrors
657 (p_messages => p_messages);
658
659 --
660 -- Sort the blocks - needed for deposit
661 -- and all sorts of short cuts!
662 --
663
664 hxc_timecard_block_utils.sort_blocks
665 (p_blocks => p_blocks
666 ,p_timecard_blocks => l_timecard_blocks
667 ,p_day_blocks => l_day_blocks
668 ,p_detail_blocks => l_detail_blocks
669 );
670
671 --
672 -- Main deposit controls
673 -- ^^^^^^^^^^^^^^^^^^^^^
674 -- Reform time data, if required
675 -- e.g Denormalize time data
676 --
677
678 hxc_block_attribute_update.denormalize_time
679 (p_blocks => p_blocks
680 ,p_mode => 'ADD'
681 );
682
683 --
684 -- Perform basic checks, e.g.
685 -- Are there any other timecards for this period?
686 --
687
688 hxc_deposit_checks.perform_checks
689 (p_blocks => p_blocks
690 ,p_attributes => p_attributes
691 ,p_timecard_props => l_timecard_props
692 ,p_days => l_day_blocks
693 ,p_details => l_detail_blocks
694 ,p_messages => p_messages
695 );
696
697 hxc_timecard_message_helper.processerrors
698 (p_messages => p_messages);
699
700 --
701 -- Add the security attributes
702 -- ARR: 115.28 change, added p_messages
703 --
704 hxc_security.add_security_attribute
705 (p_blocks => p_blocks,
706 p_attributes => p_attributes,
707 p_timecard_props => l_timecard_props,
708 p_messages => p_messages
709 );
710
711 hxc_timecard_message_helper.processerrors
712 (p_messages => p_messages);
713 --
714 -- Translate any aliases
715 --
716 hxc_timecard_deposit_common.alias_translation
717 (p_blocks => p_blocks
718 ,p_attributes => p_attributes
719 ,p_messages => p_messages
720 );
721
722 hxc_timecard_message_helper.processerrors
723 (p_messages => p_messages);
724
725 --
726 -- Set the block and attribute update process flags
727 -- Based on the data sent and in the db
728 --
729 hxc_block_attribute_update.set_process_flags
730 (p_blocks => p_blocks
731 ,p_attributes => p_attributes
732 );
733
734 --
735 -- Removed any deleted attributes
736 --
737
738 hxc_timecard_attribute_utils.remove_deleted_attributes
739 (p_attributes => p_attributes);
740
741
742 --
743 -- Perform process checks
744 --
745 hxc_deposit_checks.perform_process_checks
746 (p_blocks => p_blocks
747 ,p_attributes => p_attributes
748 ,p_timecard_props => l_timecard_props
749 ,p_days => l_day_blocks
750 ,p_details => l_detail_blocks
751 ,p_template => hxc_timecard_deposit_common.c_no
752 ,p_deposit_mode => hxc_timecard_deposit_common.c_submit
753 ,p_messages => p_messages
754 );
755
756 --in case of rejected TC again resubmit so remove the error raised
757 --for SS as TK dosn't work in same way .
758 --set process/changed flag to 'Y'.
759
760 IF p_messages.count > 0 THEN
761
762 hxc_timekeeper_utilities.check_msg_set_process_flag
763 ( p_blocks => p_blocks
764 ,p_attributes => p_attributes
765 ,p_messages => p_messages
766 );
767 END IF;
768
769
770 hxc_timecard_message_helper.processerrors
771 (p_messages => p_messages);
772 --
773 -- Validate blocks, attributes
774 --
775 /*
776 hxc_timecard_validation.deposit_validation
777 (p_blocks => p_blocks
778 ,p_attributes => p_attributes
779 ,p_messages => p_messages
780 ,p_props => l_timecard_props
781 ,p_deposit_mode => hxc_timecard_deposit_common.c_submit
782 ,p_template => hxc_timecard_deposit_common.c_no
783 ,p_resubmit => l_resubmit
784 ,p_can_deposit => l_can_deposit
785 );
786 */
787
788
789
790 hxc_timecard_validation.recipients_update_validation
791 (p_blocks => p_blocks
792 ,p_attributes => p_attributes
793 ,p_messages => p_messages
794 ,p_props => l_timecard_props
795 ,p_deposit_mode => hxc_timecard_deposit_common.c_submit
796 ,p_resubmit => l_resubmit);
797
798 hxc_timecard_message_helper.processerrors
799 (p_messages => p_messages);
800
801 hxc_timecard_validation.data_set_validation
802 (p_blocks => p_blocks
803 ,p_messages => p_messages
804 );
805
806 hxc_timecard_message_helper.processerrors
807 (p_messages => p_messages);
808
809
810 --
811 -- Validate the set up for the user
812 -- Do this only for timecards, and not
813 -- for templates.
814 --
815 /*
816 hxc_timecard_deposit_common.validate_setup
817 (p_deposit_mode => hxc_timecard_deposit_common.c_submit
818 ,p_blocks => p_blocks
819 ,p_attributes => p_attributes
820 ,p_messages => p_messages
821 );
822
823 hxc_timecard_message_helper.processerrors
824 (p_messages => p_messages);
825 */
826 --
827 -- Reform time data, if required
828 -- e.g Denormalize time data
829 --
830 hxc_block_attribute_update.denormalize_time
831 (p_blocks => p_blocks
832 ,p_mode => 'REMOVE'
833 );
834
835 --
836 -- At this point of the process
837 -- we know if the timecard needs to be in error.
838 --
839
840 -- get all the errors
841 p_messages := hxc_timecard_message_helper.getMessages;
842 /*
843 -- debug
844 IF g_debug THEN
845 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',70);
846 END IF;
847 */
848
849 hxc_timekeeper_errors.rollback_tc_or_set_err_status
850 (p_message_table => p_messages
851 ,p_blocks => p_blocks
852 ,p_attributes => p_attributes
853 ,p_rollback => l_rollback
854 ,p_status_error => l_status_error);
855
856 --p_messages.delete;
857 -- at this point we have the full message structure
858 -- so we can pass it to deposit to main the -ve ids
859 -- in the error table.
860
861 --
862 -- Store blocks and attributes
863 --
864 hxc_timecard_deposit.execute
865 (p_blocks => p_blocks
866 ,p_attributes => p_attributes
867 ,p_timecard_blocks => l_timecard_blocks
868 ,p_day_blocks => l_day_blocks
869 ,p_detail_blocks => l_detail_blocks
870 ,p_messages => p_messages
871 ,p_transaction_info=> l_transaction_info
872 );
873
874
875 p_timecard_id :=
876 p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).time_building_block_id;
877 p_timecard_ovn:=
878 p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).object_version_number;
879
880 --hxc_timecard_message_helper.processerrors
881 -- (p_messages => p_messages);
882
883 hxc_timecard_audit.maintain_latest_details
884 (p_blocks => p_blocks );
885
886 IF p_timekeeper_id IS NOT NULL and
887 p_tk_audit_enabled = 'Y' and
888 p_tk_notify_to <> 'NONE' THEN
889
890 open c_previous_timecard(p_timecard_id);
891 fetch c_previous_timecard into l_previous_tk_item_key,l_previous_tk_item_type;
892 if (c_previous_timecard%found) then
893
894 --Cancel notifications for TK Audit
895
896 hxc_timekeeper_wf_pkg.cancel_previous_notifications
897 ( p_tk_audit_item_type => l_previous_tk_item_type
898 ,p_tk_audit_item_key => l_previous_tk_item_key
899 );
900
901 end if;
902 close c_previous_timecard;
903
904 tk_item_key :=
905 hxc_timekeeper_wf_pkg.begin_audit_process
906 (p_timecard_id => p_timecard_id
907 ,p_timecard_ovn => p_timecard_ovn
908 ,p_resource_id => p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).resource_id
909 ,p_timekeeper_id => p_timekeeper_id
910 ,p_tk_audit_enabled => p_tk_audit_enabled
911 ,p_tk_notify_to => p_tk_notify_to
912 ,p_tk_notify_type => p_tk_notify_type
913 ,p_property_table => l_timecard_props
914 );
915
916 END IF;
917
918 IF TK_ITEM_KEY IS NOT NULL THEN
919 tk_audit_process_name := 'HXC_TK_AUDIT_PROCESS';
920 tk_audit_item_type := 'HXCTKWF';
921 END IF;
922 --
923 -- Maintain summary table
924 --
925 hxc_timecard_summary_api.timecard_deposit
926 (p_blocks => p_blocks
927 ,p_approval_item_type => NULL
928 ,p_approval_process_name => NULL
929 ,p_approval_item_key => NULL
930 ,p_tk_audit_item_type => tk_audit_item_type
931 ,p_tk_audit_process_name => tk_audit_process_name
932 ,p_tk_audit_item_key => tk_item_key
933 );
934
935 --
936 -- Starting Approval
937 --
938 IF not(l_status_error) THEN
939
940 l_item_key :=
941 hxc_timecard_approval.begin_approval
942 (p_blocks => p_blocks
943 ,p_item_type => hxc_timecard_deposit_common.c_hxcempitemtype
944 ,p_process_name => hxc_timecard_deposit_common.c_hxcapprovalprocess
945 ,p_resubmitted => l_resubmit
946 ,p_timecard_props => l_timecard_props
947 ,p_messages => p_messages
948 );
949
950 END IF;
951
952 -- start the approval only if the timecard has
953 -- a different status than 'Error'
954 --
955 -- Audit this transaction
956 --
957 --p_messages.delete;
958
959 hxc_timecard_audit.audit_deposit
960 (p_transaction_info => l_transaction_info
961 ,p_messages => p_messages
962 );
963
964
965
966 --hxc_timecard_message_helper.processerrors
967 -- (p_messages => p_messages);
968
969 -- get all the errors
970 --p_messages := hxc_timecard_message_helper.getMessages;
971
972
973 -- set the out parameters --
974
975 hxc_timecard_summary_pkg.update_summary_row
976 (p_timecard_id => p_timecard_id
977 ,p_approval_item_type => hxc_timecard_deposit_common.c_hxcempitemtype
978 ,p_approval_process_name => hxc_timecard_deposit_common.c_hxcapprovalprocess
979 ,p_approval_item_key => l_item_key
980 );
981
982 /*
983 if g_debug THEN
984 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',80);
985 end if;
986 */
987 hxc_timekeeper_errors.maintain_errors
988 (p_messages => p_messages
989 ,p_timecard_id => p_timecard_id
990 ,p_timecard_ovn => p_timecard_ovn);
991
992
993 END submit_timecard;
994
995 ----------------------------------------------------------------------------
996 -- Delete Timecard Procedure
997 -- This procedure....
998 ----------------------------------------------------------------------------
999 Procedure delete_timecard
1000 (p_timecard_id in out nocopy hxc_time_building_blocks.time_building_block_id%type
1001 ,p_messages in out nocopy HXC_MESSAGE_TABLE_TYPE
1002 ) is
1003
1004 /*
1005 hxc_timecard_deposit_common.delete_timecard
1006 (p_mode => 'DELETE'
1007 ,p_template => 'N'
1008 ,p_timecard_id => p_timecard_id
1009 );
1010 */
1011
1012 cursor c_previous_timecard(
1013 p_timecard_id in hxc_timecard_summary.timecard_id%type) is
1014 select tk_audit_item_key,tk_audit_item_type,timecard_ovn
1015 from hxc_timecard_summary
1016 where timecard_id = p_timecard_id;
1017
1018 /*
1019 cursor c_timecard_ovn
1020 (p_timecard_id in hxc_time_building_blocks.time_building_block_id%type) is
1021 select tbb.object_version_number
1022 from hxc_time_building_blocks tbb
1023 where tbb.time_building_block_id = p_timecard_id
1024 and tbb.date_to = hr_general.end_of_time;
1025 */
1026
1027 CURSOR csr_chk_transfer (p_timecard_id hxc_time_building_blocks.time_building_block_id%type) IS
1028 SELECT 1
1029 FROM dual
1030 WHERE EXISTS (
1031 SELECT 1
1032 FROM hxc_transactions t
1033 , hxc_transaction_details td
1034 WHERE td.time_building_block_id = p_timecard_id
1035 AND t.transaction_id = td.transaction_id
1036 AND t.type = 'RETRIEVAL'
1037 AND t.status = 'SUCCESS' );
1038
1039 l_blocks hxc_block_table_type := hxc_block_table_type();
1040 l_attributes hxc_attribute_table_type := hxc_attribute_table_type();
1041 l_messages hxc_message_table_type := hxc_message_table_type();
1042
1043 l_timecard_blocks hxc_timecard.block_list;
1044 l_day_blocks hxc_timecard.block_list;
1045 l_detail_blocks hxc_timecard.block_list;
1046
1047 l_transaction_info hxc_timecard.transaction_info;
1048 l_timecard_props hxc_timecard_prop_table_type;
1049
1050 l_dummy boolean := true;
1051
1052 l_timecard_ovn hxc_time_building_blocks.object_version_number%type;
1053 l_timecard_index number;
1054
1055 l_status_error BOOLEAN := FALSE;
1056
1057 l_rollback BOOLEAN := FALSE;
1058 e_timekeeper_check EXCEPTION;
1059
1060 l_previous_tk_item_key hxc_timecard_summary.tk_audit_item_key%type;
1061 l_previous_tk_item_type hxc_timecard_summary.tk_audit_item_type%type;
1062
1063 l_dummy_num NUMBER(1);
1064
1065 Begin
1066
1067 --
1068 -- Find the corresponding ovn of the timecard
1069 --
1070
1071 open c_previous_timecard(p_timecard_id);
1072 fetch c_previous_timecard into l_previous_tk_item_key,l_previous_tk_item_type,l_timecard_ovn;
1073 if(c_previous_timecard%notfound) then
1074 close c_previous_timecard;
1075 fnd_message.set_name('HXC','HXC_NO_ACTIVE_TIMECARD');
1076 fnd_message.raise_error;
1077 else
1078
1079 --Cancel notifications for TK Audit
1080 hxc_timekeeper_wf_pkg.cancel_previous_notifications
1081 ( p_tk_audit_item_type => l_previous_tk_item_type
1082 ,p_tk_audit_item_key => l_previous_tk_item_key
1083 );
1084 close c_previous_timecard;
1085
1086 end if;
1087
1088 --
1089 -- Initialize the message stack
1090 --
1091
1092 fnd_msg_pub.initialize;
1093 hxc_timecard_message_helper.initializeErrors;
1094 --
1095 -- Get the timecard or timecard template blocks and attributes
1096 --
1097
1098 l_blocks := hxc_timecard_deposit_common.load_blocks(p_timecard_id, l_timecard_ovn);
1099 l_attributes := hxc_timecard_deposit_common.load_attributes(l_blocks);
1100
1101 --
1102 -- Main delete processing
1103 --
1104
1105 l_timecard_index := hxc_timecard_block_utils.find_active_timecard_index(l_blocks);
1106
1107 -- we need to check if the timecard is in error and
1108 -- if it has been retrieved.
1109 IF (l_blocks(l_timecard_index).approval_status = 'ERROR')
1110 THEN
1111 OPEN csr_chk_transfer(p_timecard_id);
1112 FETCH csr_chk_transfer INTO l_dummy_num;
1113
1114 IF csr_chk_transfer%FOUND
1115 THEN
1116 close csr_chk_transfer;
1117
1118 -- add the message in the message table
1119 hxc_timecard_message_helper.addErrorToCollection
1120 (p_messages,
1121 'HXC_DEL_ERROR_RET',
1122 hxc_timecard.c_error,
1123 null,
1124 null,
1125 hxc_timecard.c_hxc,
1126 null,
1127 null,
1128 null,
1129 null
1130 );
1131
1132 raise e_timekeeper_check;
1133 END IF;
1134
1135 close csr_chk_transfer;
1136 END IF;
1137
1138 hxc_timecard_properties.get_preference_properties
1139 (p_validate => hxc_timecard.c_yes
1140 ,p_resource_id => l_blocks(l_timecard_index).resource_id
1141 ,p_timecard_start_time => fnd_date.canonical_to_date(l_blocks(l_timecard_index).start_time)
1142 ,p_timecard_stop_time => fnd_date.canonical_to_date(l_blocks(l_timecard_index).stop_time)
1143 ,p_for_timecard => false
1144 ,p_messages => l_messages
1145 ,p_property_table => l_timecard_props
1146 );
1147
1148 hxc_timecard_message_helper.processerrors
1149 (p_messages => l_messages);
1150
1151
1152 hxc_timecard_block_utils.sort_blocks
1153 (p_blocks => l_blocks
1154 ,p_timecard_blocks => l_timecard_blocks
1155 ,p_day_blocks => l_day_blocks
1156 ,p_detail_blocks => l_detail_blocks
1157 );
1158
1159 hxc_block_attribute_update.set_process_flags
1160 (p_blocks => l_blocks
1161 ,p_attributes => l_attributes
1162 );
1163
1164 hxc_timecard_validation.deposit_validation
1165 (p_blocks => l_blocks
1166 ,p_attributes => l_attributes
1167 ,p_messages => l_messages
1168 ,p_props => l_timecard_props
1169 ,p_deposit_mode => hxc_timecard.c_submit
1170 ,p_template => 'N'
1171 ,p_resubmit => hxc_timecard_deposit_common.c_delete
1172 ,p_can_deposit => l_dummy
1173 );
1174
1175 hxc_timecard_message_helper.processerrors
1176 (p_messages => l_messages);
1177
1178
1179 -- get all the errors
1180 l_messages := hxc_timecard_message_helper.getMessages;
1181 /*
1182 -- debug
1183 IF g_debug THEN
1184 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',70);
1185 END IF;
1186 */
1187 hxc_timekeeper_errors.rollback_tc_or_set_err_status
1188 (p_message_table => l_messages
1189 ,p_blocks => l_blocks
1190 ,p_attributes => l_attributes
1191 ,p_rollback => l_rollback
1192 ,p_status_error => l_status_error);
1193
1194 -- l_messages.delete;
1195 --
1196 -- if the rollback is set then we need to execute it
1197 --
1198 IF l_rollback THEN
1199 -- we are setting the error to be
1200 -- send
1201 p_messages := l_messages;
1202 l_messages.delete;
1203 raise e_timekeeper_check;
1204
1205 ELSE
1206
1207 --l_messages.delete;
1208 hxc_timecard_deposit.execute
1209 (p_blocks => l_blocks
1210 ,p_attributes => l_attributes
1211 ,p_timecard_blocks => l_timecard_blocks
1212 ,p_day_blocks => l_day_blocks
1213 ,p_detail_blocks => l_detail_blocks
1214 ,p_messages => l_messages
1215 ,p_transaction_info => l_transaction_info
1216 );
1217
1218 --hxc_timecard_message_helper.processerrors
1219 --(p_messages => l_messages);
1220
1221
1222 hxc_timecard_summary_api.delete_timecard
1223 (p_blocks => l_blocks
1224 ,p_timecard_id => p_timecard_id
1225 );
1226
1227 --l_messages.delete;
1228 hxc_timecard_audit.audit_deposit
1229 (p_transaction_info => l_transaction_info
1230 ,p_messages => l_messages
1231 );
1232 -- hxc_timecard_message_helper.processerrors
1233 -- (p_messages => l_messages);
1234
1235 hxc_timecard_audit.maintain_latest_details
1236 (p_blocks => l_blocks );
1237
1238 hxc_timecard_message_helper.prepareErrors;
1239
1240 -- get all the errors
1241 --l_messages := hxc_timecard_message_helper.getMessages;
1242 /*
1243 if g_debug THEN
1244 hxc_debug_timecard.writeMessages(p_messages,'HXC_TIMEKEEPER',80);
1245 end if;
1246 */
1247
1248 hxc_timekeeper_errors.maintain_errors
1249 (p_messages => l_messages
1250 ,p_timecard_id => p_timecard_id
1251 ,p_timecard_ovn => l_timecard_ovn);
1252
1253 end if;
1254
1255
1256 EXCEPTION
1257 WHEN e_timekeeper_check then
1258 hxc_timecard_message_helper.prepareErrors;
1259 rollback;
1260
1261 End delete_timecard;
1262
1263
1264
1265 END hxc_timekeeper;