DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_TIMECARD_VALIDATION

Source


1 package body hxc_timecard_validation as
2 /* $Header: hxctimevalid.pkb 120.2.12020000.2 2013/01/18 06:16:15 asrajago ship $ */
3 
4 type retrieval_ref_cursor IS ref cursor;
5 -- Bug 16178193
6 g_debug BOOLEAN := hr_utility.debug_enabled;
7 
8    Function get_otm_app_attributes
9               (p_attributes in            hxc_attribute_table_type,
10                p_messages   in out nocopy hxc_message_table_type)
11       return hxc_self_service_time_deposit.app_attributes_info is
12 
13       cursor c_deposit_process is
14         select deposit_process_id
15           from hxc_deposit_processes
16          where name = 'OTL Deposit Process';
17 
18       l_deposit_process_id hxc_deposit_processes.deposit_process_id%type;
19       l_app_attributes     hxc_self_service_time_deposit.app_attributes_info;
20 
21    begin
22 
23       open c_deposit_process;
24       fetch c_deposit_process into l_deposit_process_id;
25       if(c_deposit_process%notfound) then
26          close c_deposit_process;
27          hxc_timecard_message_helper.addErrorToCollection
28             (p_messages,
29              'HXC_NO_OTL_DEPOSIT_PROC',
30              hxc_timecard.c_error,
31              null,
32              null,
33              hxc_timecard.c_hxc,
34              null,
35              null,
36              null,
37              null
38              );
39 
40       else
41          close c_deposit_process;
42 
43          l_app_attributes :=
44             hxc_app_attribute_utils.create_app_attributes
45               (p_attributes           => p_attributes,
46                p_retrieval_process_id => null,
47                p_deposit_process_id   => l_deposit_process_id
48                );
49       end if;
50 
51       return l_app_attributes;
52 
53    end get_otm_app_attributes;
54 
55    Function find_retrieval_process_id
56               (p_time_recipient_id
57                   in hxc_time_recipients.time_recipient_id%type,
58                p_retrieval_function
59                   in hxc_time_recipients.application_retrieval_function%type)
60       Return number is
61 
62       c_ret_pro              retrieval_ref_cursor;
63       l_sql                  VARCHAR2(32000);
64       l_retrieval_process_id hxc_retrieval_processes.retrieval_process_id%type;
65 
66    Begin
67 
68       l_sql := 'select retrieval_process_id
69                   from hxc_retrieval_processes
70                   where time_recipient_id = '|| p_time_recipient_id
71              ||' and name = '||p_retrieval_function;
72 
73       open c_ret_pro for l_sql;
74       fetch c_ret_pro into l_retrieval_process_id;
75 
76       if c_ret_pro%notfound then
77          close c_ret_pro;
78          fnd_message.set_name('hxc','hxc_xxxxx_no_app_ret_proc_name');
79          fnd_msg_pub.add;
80       else
81          close c_ret_pro;
82       end if;
83 
84       return l_retrieval_process_id;
85 
86    End find_retrieval_process_id;
87 
88    Function recipients
89               (p_application_set_id in number)
90       Return recipient_application_table is
91 
92       cursor csr_time_recipients(p_application_set_id in number) is
93         select tr.time_recipient_id,
94                tr.name,
95                tr.application_retrieval_function,
96                tr.application_update_process,
97                tr.appl_validation_process
98           from hxc_time_recipients tr,
99                hxc_application_set_comps_v asc1
100          where p_application_set_id = asc1.application_set_id
101            and asc1.time_recipient_id = tr.time_recipient_id
102            and tr.application_retrieval_function is not null;
103 
104       l_appl_recipients recipient_application_table;
105       l_index           pls_integer;
106 
107    Begin
108 
109       l_index := 0;
110       for recip_rec in csr_time_recipients(p_application_set_id) loop
111          l_index := l_index +1;
112          l_appl_recipients(l_index).time_recipient_id
113             := recip_rec.time_recipient_id;
114          l_appl_recipients(l_index).name := recip_rec.name;
115          l_appl_recipients(l_index).application_retrieval_function
116             := recip_rec.application_retrieval_function;
117          l_appl_recipients(l_index).application_update_process
118             := recip_rec.application_update_process;
119          l_appl_recipients(l_index).appl_validation_process
120             := recip_rec.appl_validation_process;
121          l_appl_recipients(l_index).appl_retrieval_process_id
122             := find_retrieval_process_id
123                  (recip_rec.time_recipient_id,
124                   recip_rec.application_retrieval_function);
125       end loop;
126 
127       return l_appl_recipients;
128 
129    End recipients;
130 
131    Procedure update_attributes
132                (p_attributes in out nocopy hxc_attribute_table_type) is
133 
134       l_app_attributes hxc_self_service_time_deposit.app_attributes_info;
135 
136    Begin
137 
138       l_app_attributes := hxc_self_service_time_deposit.get_app_attributes;
139 
140       hxc_app_attribute_utils.update_attributes
141          (p_attributes => p_attributes,
142           p_app_attributes => l_app_attributes
143           );
144 
145    End update_attributes;
146 
147    Procedure set_attributes
148                (p_blocks               in hxc_block_table_type,
149                 p_attributes           in hxc_attribute_table_type,
150                 p_old_style_attrs      in hxc_self_service_time_deposit.building_block_attribute_info,
151                 p_retrieval_process_id in number,
152                 p_recipients           in recipient_application_table,
153                 p_elp_enabled          in boolean
154                 ) is
155 
156       l_app_attributes hxc_self_service_time_deposit.app_attributes_info;
157       l_messages       hxc_self_service_time_deposit.message_table;
158 
159    Begin
160 
161       if(p_elp_enabled) then
162 
163          l_app_attributes
164             := hxc_app_attribute_utils.create_app_attributes
165                  (p_blocks => p_blocks,
166                   p_attributes => p_attributes,
167                   p_deposit_process_id => null,
168                   p_retrieval_process_id => p_retrieval_process_id,
169                   p_recipients => p_recipients
170                   );
171 
172       else
173 
174          l_app_attributes
175             := hxc_app_attribute_utils.create_app_attributes
176                  (p_attributes => p_attributes,
177                   p_deposit_process_id => null,
178                   p_retrieval_process_id => p_retrieval_process_id
179                   );
180       end if;
181 
182       hxc_self_service_time_deposit.initialize_globals;
183       hxc_self_service_time_deposit.set_update_phase(true);
184 
185 
186       hxc_self_service_time_deposit.set_app_hook_params
187          (p_building_blocks
188             => hxc_timecard_block_utils.convert_to_dpwr_blocks(p_blocks),
189           p_app_attributes  => l_app_attributes,
190           p_messages        => l_messages
191           );
192 
193 
194       hxc_self_service_time_deposit.set_g_attributes
195          (p_attributes => p_old_style_attrs );
196 
197 
198    End set_attributes;
199 
200    Procedure update_messages
201                (p_messages             in out nocopy hxc_message_table_type,
202                 p_retrieval_process_id in            number) is
203 
204       l_messages hxc_self_service_time_deposit.message_table;
205    Begin
206 
207       l_messages := hxc_self_service_time_deposit.get_messages;
208       hxc_timecard_message_utils.append_old_messages
209          (p_messages             => p_messages,
210           p_old_messages         => l_messages,
211           p_retrieval_process_id => p_retrieval_process_id
212          );
213 
214    End update_messages;
215 
216    procedure update_phase
217                (p_recipients       in            recipient_application_table,
218                 p_blocks           in            hxc_block_table_type,
219                 p_attributes       in out nocopy hxc_attribute_table_type,
220                 p_old_style_attrs  in hxc_self_service_time_deposit.building_block_attribute_info,
221                 p_messages         in out nocopy hxc_message_table_type,
222                 p_deposit_mode     in            varchar2,
223                 p_projects_tr_id   in            number,
224                 p_validate_on_save in            varchar2
225                 ) is
226 
227       l_elp_blocks hxc_block_table_type;
228       l_index      pls_integer;
229       l_upd_sql    varchar2(2000);
230 
231    Begin
232       l_elp_blocks := hxc_block_table_type();
233       l_index := p_recipients.first;
234       Loop
235          Exit when not p_recipients.exists(l_index);
236          if((p_recipients(l_index).application_update_process is not null)
237             AND
238             (p_recipients(l_index).appl_retrieval_process_id is not null)) then
239 
240             if((p_deposit_mode <> hxc_timecard.c_save)
241                OR(
242                   (p_deposit_mode = hxc_timecard.c_save)
243                   AND
244                      (p_recipients(l_index).time_recipient_id = p_projects_tr_id)
245                   )
246                OR(
247                   (p_deposit_mode = hxc_timecard.c_save)
248                   AND
249                      (p_validate_on_save = hxc_timecard.c_yes)
250                   )) then
251 
252                set_attributes
253                   (p_blocks,
254                    p_attributes,
255                    p_old_style_attrs,
256                    p_recipients(l_index).appl_retrieval_process_id,
257                    p_recipients,
258                    false
259                    );
260 
261                l_upd_sql := 'BEGIN '||fnd_global.newline
262                   ||p_recipients(l_index).application_update_process ||fnd_global.newline
263                   ||'(p_operation => :1);'||fnd_global.newline
264                   ||'END;';
265 
266                EXECUTE IMMEDIATE l_upd_sql using IN p_deposit_mode;
267 
268                update_attributes(p_attributes);
269 
270                update_messages
271                   (p_messages,
272                    p_recipients(l_index).appl_retrieval_process_id
273                    );
274 
275             end if;
276 
277          end if;
278          l_index := p_recipients.next(l_index);
279       End loop;
280 
281    End update_phase;
282 
283    Procedure validate_phase
284                (p_recipients       in            recipient_application_table,
285                 p_blocks           in            hxc_block_table_type,
286                 p_attributes       in out nocopy hxc_attribute_table_type,
287                 p_old_style_attrs  in hxc_self_service_time_deposit.building_block_attribute_info,
288                 p_messages         in out nocopy hxc_message_table_type,
289                 p_deposit_mode     in            varchar2,
290                 p_elp_terg_id      in            number,
291                 p_projects_tr_id   in            number,
292                 p_validate_on_save in            varchar2
293                 ) is
294 
295       l_elp_blocks  hxc_block_table_type;
296       l_index       pls_integer;
297       l_val_sql     varchar2(2000);
298       l_elp_enabled boolean := false;
299 
300    Begin
301 
302       l_index := p_recipients.first;
303       Loop
304          Exit when not p_recipients.exists(l_index);
305 
306          if((p_recipients(l_index).appl_validation_process is not null)
307             AND
308             (p_recipients(l_index).appl_retrieval_process_id is not null))then
309 
310             if((p_deposit_mode <> hxc_timecard.c_save)
311                OR(
312                   (p_deposit_mode = hxc_timecard.c_save)
313                   AND
314                   (p_recipients(l_index).time_recipient_id = p_projects_tr_id)
315                  )
316                OR((p_deposit_mode = hxc_timecard.c_save)
317                   AND
318                   (p_validate_on_save = hxc_timecard.c_yes)
319                  )) then
320 
321                if(p_elp_terg_id is not null) then
322                   l_elp_blocks := hxc_elp_utils.build_elp_objects
323                                     (p_elp_time_building_blocks =>  p_blocks,
324                                      p_elp_time_attributes => p_attributes,
325                                      p_time_recipient_id    =>  p_recipients(l_index).time_recipient_id
326                                      );
327                   l_elp_enabled := true;
328                else
329                   l_elp_blocks := p_blocks;
330                end if;
331 
332                set_attributes
333                   (l_elp_blocks,
334                    p_attributes,
335                    p_old_style_attrs,
336                    p_recipients(l_index).appl_retrieval_process_id,
337                    p_recipients,
338                    l_elp_enabled
339                    );
340 
341                l_val_sql := 'BEGIN '||fnd_global.newline
342                   ||p_recipients(l_index).appl_validation_process ||fnd_global.newline
343                   ||'(p_operation => :1);'||fnd_global.newline
344                   ||'END;';
345 
346                EXECUTE IMMEDIATE l_val_sql using IN p_deposit_mode;
347 
348                update_messages
349                   (p_messages,
350                    p_recipients(l_index).appl_retrieval_process_id
351                    );
352 
353             end if; -- is this save and PA? or non-save?
354 
355          end if;
356          l_index := p_recipients.next(l_index);
357       End loop;
358 
359    End validate_phase;
360 
361    Function template_name_exists
362               (p_resource_id in number,
363                p_name_to_check in varchar2,
364                p_time_building_block_id in number,
365                p_template_type in varchar2,
366                p_business_group_id in varchar2
367                )
368       Return boolean is
369 
370       cursor c_is_dynamic_template
371                (p_name_to_check in varchar2) is
372         select 'Y'
373           from hr_lookups
374          where lookup_type = 'HXC_DYNAMIC_TEMPLATES'
375            and meaning = p_name_to_check;
376 
377       cursor c_is_private_template
378                (p_name_to_check in varchar2,
379                 p_resoure_id in number,
380                 p_time_building_block_id in number
381                 ) is
382         select 'Y'
383           from hxc_template_summary
384          where template_type = 'PRIVATE'
385            and template_id <> p_time_building_block_id
386            and template_name = p_name_to_check
387            and resource_id = p_resource_id;
388 
389       cursor c_is_public_template
390                (p_name_to_check in varchar2,
391                 p_time_building_block_id in number,
392                 p_business_group_id in varchar2) is
393         select 'Y'
394           from hxc_template_summary
395          where template_type = 'PUBLIC'
396            and template_id <> p_time_building_block_id
397            and template_name = p_name_to_check
398            and business_group_id =p_business_group_id ;
399 
400       l_dummy varchar2(2);
401       value boolean := false;
402 
403    Begin
404 
405       open c_is_dynamic_template(p_name_to_check);
406       fetch c_is_dynamic_template into l_dummy;
407       if c_is_dynamic_template%NOTFOUND then
408          close c_is_dynamic_template;
409          if(p_template_type = 'PRIVATE') THEN
410             open c_is_private_template(p_name_to_check,p_resource_id,p_time_building_block_id);
411             fetch c_is_private_template into l_dummy;
412             if c_is_private_template%NOTFOUND then
413                close c_is_private_template;
414             else
415                close c_is_private_template;
416                value:=true;
417             end if;
418          elsif(p_template_type = 'PUBLIC') THEN
419             open c_is_public_template(p_name_to_check,p_time_building_block_id,p_business_group_id);
420             fetch c_is_public_template into l_dummy;
421             if c_is_public_template%NOTFOUND then
422                close c_is_public_template;
423             else
424                close c_is_public_template;
425                value:=true;
426             end if;
427          end if;
428       else
429          close c_is_dynamic_template;
430          value := true;
431       end if;
432 
433       return value;
434 
435    end template_name_exists;
436 
437    Procedure template_validation
438                (p_blocks     in out nocopy hxc_block_table_type,
439                 p_attributes in out nocopy hxc_attribute_table_type,
440                 p_messages   in out nocopy hxc_message_table_type,
441                 p_can_deposit   out nocopy boolean
442                 ) is
443 
444       l_template_index number;
445       l_template_name  hxc_time_attributes.attribute1%type;
446       l_security_index number;
447       l_business_group_id  hxc_time_attributes.attribute1%type;
448 
449    Begin
450 
451       p_can_deposit := true;
452       l_template_index := hxc_timecard_attribute_utils.get_attribute_index
453                             (p_attributes,
454                              hxc_timecard.c_template_attribute,
455                              null
456                              );
457       l_security_index := hxc_timecard_attribute_utils.get_attribute_index
458                             (p_attributes,
459                              hxc_timecard.c_security_attribute,
460                              null
461                              );
462 
463       l_template_name := p_attributes(l_template_index).attribute1;
464       l_business_group_id := p_attributes(l_security_index).attribute2;
465 
466       if(template_name_exists
467            (p_blocks(1).resource_id
468             ,l_template_name
469             ,p_attributes(l_template_index).building_block_id
470             ,p_attributes(l_template_index).attribute2,
471             l_business_group_id)) then
472 
473          p_can_deposit := false;
474 
475          hxc_timecard_message_helper.addErrorToCollection
476             (p_messages,
477              'HXC_366204_TEMPLATE_NAME',
478              hxc_timecard.c_error,
479              null,
480              'TEMPLATE_NAME&'||l_template_name,
481              hxc_timecard.c_hxc,
482              null,
483              null,
484              null,
485              null
486              );
487 
488       End if;
489 
490    End template_validation;
491 
492    Procedure change_late_audit_validation
493       (p_old_style_blks   in            hxc_self_service_time_deposit.timecard_info,
494        p_old_style_attrs in            hxc_self_service_time_deposit.building_block_attribute_info,
495        p_props           in            hxc_timecard_prop_table_type,
496        p_eval_start_date in            date,
497        p_eval_end_date   in            date,
498        p_messages        in out nocopy hxc_message_table_type
499        ) is
500 
501       l_cla_terg_id  number;
502       l_old_messages hxc_self_service_time_deposit.message_table;
503 
504    Begin
505 
506       l_cla_terg_id := to_number(
507                          hxc_timecard_properties.find_property_value
508                             (p_props,
509                              'TsPerAuditRequirementsAuditRequirements',
510                              null,
511                              null,
512                              p_eval_start_date,
513                              p_eval_end_date
514                              ));
515 
516       if(l_cla_terg_id is not null) then
517          hxc_time_entry_rules_utils_pkg.execute_cla_time_entry_rules
518             (p_time_building_blocks        =>  p_old_style_blks,
519              p_time_attributes             =>  p_old_style_attrs,
520              p_messages                    =>  l_old_messages,
521              p_time_entry_rule_group_id    =>  l_cla_terg_id
522              );
523 
524          hxc_timecard_message_utils.append_old_messages
525             (p_messages             => p_messages,
526              p_old_messages         => l_old_messages,
527              p_retrieval_process_id => null
528              );
529       end if;
530 
531    End change_late_audit_validation;
532 
533    Procedure recipients_update_validation
534       (p_blocks          in out nocopy hxc_block_table_type,
535        p_attributes      in out nocopy hxc_attribute_table_type,
536        p_old_style_blks  in            hxc_self_service_time_deposit.timecard_info,
537        p_old_style_attrs in            hxc_self_service_time_deposit.building_block_attribute_info,
538        p_props           in            hxc_timecard_prop_table_type,
539        p_eval_date       in            date,
540        p_deposit_mode    in            varchar2,
541        p_resubmit        in            varchar2,
542        p_messages        in out nocopy hxc_message_table_type
543        ) is
544 
545       cursor c_pa_tr_id is
546         select time_recipient_id
547           from hxc_time_recipients
548          where upper(name) = 'PROJECTS';
549 
550       l_application_set_id  number;
551       l_elp_terg_id         number;
552       l_eval_date           date;
553       l_appl_recipients     recipient_application_table;
554       l_old_messages        hxc_self_service_time_deposit.message_table;
555       l_otm_attributes      hxc_self_service_time_deposit.app_attributes_info;
556       l_timecard_start_time date;
557       l_timecard_stop_time  date;
558       l_projects_tr_id      number;
559       l_validate_on_save    hxc_pref_hierarchies.attribute1%type;
560       l_app_attributes hxc_self_service_time_deposit.app_attributes_info;
561       l_messages       hxc_self_service_time_deposit.message_table;
562 
563 
564     -- Bug 16178193
565     -- Added this function below to check if Projects is one of the time recipients in the
566     --  application set attached to the employee. We can pick this up using a cursor using just
567     --  the application set id, but looping thru the already available recipients table
568     --  avoids another cursor.
569     FUNCTION app_set_includes_projects(p_appl_recipients  recipient_application_table)
570     RETURN BOOLEAN
571     IS
572 
573      l_exists_flag  BOOLEAN := FALSE;
574 
575     BEGIN
576         FOR i IN p_appl_recipients.FIRST..p_appl_recipients.LAST
577         LOOP
578            IF g_debug
579            THEN
580               hr_utility.trace('Recipient : '||p_appl_recipients(i).name);
581            END IF;
582            IF p_appl_recipients(i).name = 'Projects'
583            THEN
584               l_exists_flag := TRUE;
585               IF g_debug
586               THEN
587                  hr_utility.trace('Projects exists in the list of Recipients');
588               END IF;
589               EXIT;
590            END IF;
591         END LOOP;
592         RETURN l_exists_flag;
593      END app_set_includes_projects;
594 
595 
596      -- Bug 16178193
597      -- Added this procedure to delete Project attributes with project_id, task_id and
598      --  expenditure type as NULL. Such records are invalid and are created as attributes
599      --  only because the hidden field Billable flag gets populated anyway.
600      --  The case exists only for ELP, that too on updating an entry on an ELP timecard by
601      --  Nulling out the Projects attributes.
602      PROCEDURE remove_empty_proj_attributes(p_attributes IN OUT NOCOPY hxc_attribute_table_type)
603      IS
604 
605        l_index  BINARY_INTEGER;
606 
607      BEGIN
608          IF p_attributes.COUNT > 0
609          THEN
610             l_index := p_attributes.FIRST;
611             LOOP
612                IF p_attributes(l_index).attribute_category = 'PROJECTS'
613                 AND p_attributes(l_index).attribute1 IS NULL
614                 AND p_attributes(l_index).attribute2 IS NULL
615                 AND p_attributes(l_index).attribute3 IS NULL
616                THEN
617                   p_attributes.DELETE(l_index);
618                END IF;
619                l_index := p_attributes.NEXT(l_index);
620                EXIT WHEN NOT p_attributes.EXISTS(l_index);
621             END LOOP;
622           END IF;
623        END remove_empty_proj_attributes;
624 
625 
626 
627 
628    Begin
629 
630       open c_pa_tr_id;
631       fetch c_pa_tr_id into l_projects_tr_id;
632       close c_pa_tr_id;
633 
634       l_timecard_start_time :=
635          hxc_timecard_block_utils.date_value
636            (p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).start_time);
637       l_timecard_stop_time:=
638          hxc_timecard_block_utils.date_value
639            (p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).stop_time);
640 
641 
642       l_application_set_id := to_number
643          (hxc_timecard_properties.find_property_value
644             (p_props,
645              'TsPerApplicationSetTsApplicationSet',
646              null,
647              null,
648              l_timecard_start_time,
649              l_timecard_stop_time
650              ));
651 
652       l_validate_on_save :=
653          hxc_timecard_properties.find_property_value
654            (p_props,
655             'TsPerValidateOnSaveValidateOnSave',
656             null,
657             null,
658             l_timecard_start_time,
659             l_timecard_stop_time
660             );
661 
662       if(l_validate_on_save is null) then
663          l_validate_on_save := hxc_timecard.c_no;
664       end if;
665 
666       l_appl_recipients := recipients(l_application_set_id);
667 
668       if(l_appl_recipients.count>0) then
669 
670          hxc_app_attribute_utils.cache_mappings;
671 
672          update_phase
673             (l_appl_recipients,
674              p_blocks,
675              p_attributes,
676              p_old_style_attrs,
677              p_messages,
678              p_deposit_mode,
679              l_projects_tr_id,
680              l_validate_on_save
681              );
682 
683          l_elp_terg_id := to_number
684             (hxc_timecard_properties.find_property_value
685                 (p_props,
686                  'TsPerElpRulesElpTimeEntryRuleGroup',
687                  null,
688                  null,
689                  l_timecard_start_time,
690                  l_timecard_stop_time
691                  ));
692 
693          -- Bug 16178193
694          -- If ELP is set, and projects is one of the time recipients,
695          --  remove empty projects attributes.
696          IF l_elp_terg_id IS NOT NULL
697            AND app_set_includes_projects(l_appl_recipients)
698          THEN
699             IF g_debug
700             THEN
701                hr_utility.trace('Setup shows ELP with Projects; need to check attributes');
702             END IF;
703             remove_empty_proj_attributes(p_attributes);
704          END IF;
705 
706          hxc_time_category_utils_pkg.push_timecard
707             (p_blocks,
708              p_attributes);
709 
710          if(l_elp_terg_id is not null) then
711             hxc_time_entry_rules_utils_pkg.execute_elp_time_entry_rules
712                (p_time_building_blocks        =>  p_blocks,
713                 p_time_attributes             =>  p_attributes,
714                 p_messages                    =>  l_old_messages,
715                 p_time_entry_rule_group_id    =>  l_elp_terg_id
716                 );
717          end if;
718 
719          hxc_elp_utils.set_time_bb_appl_set_id
720             (p_time_building_blocks        =>  p_blocks,
721              p_time_attributes             =>  p_attributes,
722              p_messages                    =>  l_old_messages,
723              p_pte_terg_id                 =>  l_elp_terg_id,
724              p_application_set_id          =>  l_application_set_id
725              );
726 
727          hxc_timecard_message_utils.append_old_messages
728             (p_messages             => p_messages,
729              p_old_messages         => l_old_messages,
730              p_retrieval_process_id => null
731              );
732 
733          validate_phase
734             (l_appl_recipients,
735              p_blocks,
736              p_attributes,
737              p_old_style_attrs,
738              p_messages,
739              p_deposit_mode,
740              l_elp_terg_id,
741              l_projects_tr_id,
742              l_validate_on_save
743              );
744 
745       end if;
746 
747       l_old_messages.delete;
748 
749       -- GPM v115.12 WWB 3470294
750       -- set the bld blks and app attribute structures to show the non
751       -- non filtered ELP structures
752       -- ARR 115.25 Now use this l_app_attributes structure of the otm
753       -- validation as well, since TERs do not change the values in here
754       --
755 
756       l_app_attributes := get_otm_app_attributes
757          (p_attributes,
758           p_messages);
759 
760       -- GPM v115.12 WWB 3470294
761 
762 
763   -- GPM v115.26 start
764   -- added calls to set_update_phase and set_g_attributes
765   -- otherwise g_attributes and g_timecard are not available to
766   -- TER when no recipient validation is called
767 
768   hxc_self_service_time_deposit.set_update_phase(true);
769 
770   hxc_self_service_time_deposit.set_app_hook_params
771     (p_building_blocks => p_old_style_blks
772     ,p_app_attributes  => l_app_attributes
773     ,p_messages        => l_messages );
774 
775   hxc_self_service_time_deposit.set_update_phase(false);
776 
777   hxc_self_service_time_deposit.set_g_attributes
778      ( p_attributes     =>  p_old_style_attrs );
779 
780   -- GPM v115.26 end
781 
782       hxc_time_entry_rules_utils_pkg.execute_time_entry_rules
783          (p_operation => p_deposit_mode,
784           p_time_building_blocks =>  p_old_style_blks,
785           p_time_attributes => p_old_style_attrs,
786           p_messages => l_old_messages,
787           p_resubmit => p_resubmit,
788           p_blocks => p_blocks,
789           p_attributes => p_attributes
790           );
791 
792       hxc_timecard_message_utils.append_old_messages
793          (p_messages             => p_messages,
794           p_old_messages         => l_old_messages,
795           p_retrieval_process_id => null
796           );
797 
798       --
799       -- Now include the OTM validation, which was included in the set up
800       -- validation called previously.
801       --
802       l_old_messages.delete;
803 
804       hxt_hxc_retrieval_process.otlr_validation_required
805          (p_operation            => p_deposit_mode,
806           p_otm_explosion        => hxc_timecard_properties.find_property_value
807              (p_props,
808               'TcWRulesEvaluationRulesEvaluation',
809               null,
810               null,
811               p_eval_date
812               ),
813           p_otm_rtr_id           => hxc_timecard_properties.find_property_value
814              (p_props,
815               'TcWRulesEvaluationAppRulesEvaluation',
816               null,
817               null,
818               p_eval_date
819               ),
820           p_app_set_id           => l_application_set_id,
821           p_timecard_id          => p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).time_building_block_id,
822           p_timecard_ovn         => p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).object_version_number,
823           p_time_building_blocks => p_old_style_blks,
824           p_time_att_info        => l_app_attributes,
825           p_messages             => l_old_messages
826           );
827 
828       hxc_timecard_message_utils.append_old_messages
829          (p_messages             => p_messages,
830           p_old_messages         => l_old_messages,
831           p_retrieval_process_id => null
832           );
833 
834    End recipients_update_validation;
835 
836    Procedure recipients_update_validation
837       (p_blocks       in out nocopy hxc_block_table_type,
838        p_attributes   in out nocopy hxc_attribute_table_type,
839        p_messages     in out nocopy hxc_message_table_type,
840        p_props        in            hxc_timecard_prop_table_type,
841        p_deposit_mode in            varchar2,
842        p_resubmit     in            varchar2
843        ) is
844 
845       l_eval_date       date;
846       l_old_style_blks  HXC_SELF_SERVICE_TIME_DEPOSIT.timecard_info;
847       l_old_style_attrs hxc_self_service_time_deposit.building_block_attribute_info;
848 
849    Begin
850       l_old_style_blks := HXC_TIMECARD_BLOCK_UTILS.convert_to_dpwr_blocks(p_blocks);
851       l_old_style_attrs := HXC_TIMECARD_ATTRIBUTE_UTILS.convert_to_dpwr_attributes(p_attributes);
852       l_eval_date := fnd_date.canonical_to_date(p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).start_time);
853 
854       recipients_update_validation
855          (p_blocks          => p_blocks,
856           p_attributes      => p_attributes,
857           p_old_style_blks  => l_old_style_blks,
858           p_old_style_attrs => l_old_style_attrs,
859           p_props           => p_props,
860           p_eval_date       => l_eval_date,
861           p_deposit_mode    => p_deposit_mode,
862           p_resubmit        => p_resubmit,
863           p_messages        => p_messages
864           );
865 
866    End recipients_update_validation;
867 
868    Procedure  data_set_validation
869       (p_blocks        in out nocopy hxc_block_table_type,
870        p_messages      in out nocopy hxc_message_table_type
871        ) is
872 
873       cursor c_data_set( p_stop_time date) is
874         select 1
875           from hxc_data_sets  d
876          where p_stop_time between d.start_date and d.end_date
877            and status in ('OFF_LINE','BACKUP_IN_PROGRESS','RESTORE_IN_PROGRESS');
878 
879       l_timecard_start_time date;
880       l_timecard_stop_time  date;
881       l_dummy               number;
882 
883    Begin
884 
885       l_timecard_start_time := hxc_timecard_block_utils.date_value
886          (p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).start_time);
887 
888       l_timecard_stop_time := hxc_timecard_block_utils.date_value
889          (p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).stop_time);
890 
891       open c_data_set(l_timecard_stop_time);
892       fetch c_data_set into l_dummy;
893       if c_data_set%found then
894          close c_data_set;
895          hxc_timecard_message_helper.addErrorToCollection
896             (p_messages,
897              'HXC_TC_OFFLINE_PERIOD_CONFLICT',
898              hxc_timecard.c_error,
899              null,
900              null,
901              hxc_timecard.c_hxc,
902              p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).time_building_block_id,
903              p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).object_version_number,
904              null,
905              null
906              );
907       else
908          close c_data_set;
909       end if;
910    End data_set_validation;
911 
912    Procedure timecard_validation
913       (p_blocks       in out nocopy hxc_block_table_type,
914        p_attributes   in out nocopy hxc_attribute_table_type,
915        p_messages     in out nocopy hxc_message_table_type,
916        p_props        in            hxc_timecard_prop_table_type,
917        p_deposit_mode in            varchar2,
918        p_resubmit     in            varchar2
919        ) is
920 
921       l_tc_start_date      date;
922       l_tc_end_date        date;
923       l_old_style_blks     HXC_SELF_SERVICE_TIME_DEPOSIT.timecard_info;
924       l_old_style_attrs    hxc_self_service_time_deposit.building_block_attribute_info;
925 
926    Begin
927       l_old_style_blks := HXC_TIMECARD_BLOCK_UTILS.convert_to_dpwr_blocks
928          (p_blocks);
929 
930       l_old_style_attrs := HXC_TIMECARD_ATTRIBUTE_UTILS.convert_to_dpwr_attributes
931          (p_attributes);
932 
933       l_tc_start_date:= fnd_date.canonical_to_date
934          (p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).start_time);
935       l_tc_end_date  := fnd_date.canonical_to_date
936          (p_blocks(hxc_timecard_block_utils.find_active_timecard_index(p_blocks)).stop_time);
937 
938       recipients_update_validation
939          (p_blocks          => p_blocks,
940           p_attributes      => p_attributes,
941           p_old_style_blks  => l_old_style_blks,
942           p_old_style_attrs => l_old_style_attrs,
943           p_props           => p_props,
944           p_eval_date       => l_tc_start_date,
945           p_deposit_mode    => p_deposit_mode,
946           p_resubmit        => p_resubmit,
947           p_messages        => p_messages
948          );
949 
950       change_late_audit_validation
951          (p_old_style_blks  => l_old_style_blks,
952           p_old_style_attrs => l_old_style_attrs,
953           p_props           => p_props,
954           p_eval_start_date => l_tc_start_date,
955           p_eval_end_date   => l_tc_end_date,
956           p_messages        => p_messages
957          );
958 
959       data_set_validation
960          (p_blocks       => p_blocks,
961           p_messages     => p_messages
962           );
963 
964    End timecard_validation;
965 
966    procedure deposit_validation
967       (p_blocks       in out nocopy hxc_block_table_type,
968        p_attributes   in out nocopy hxc_attribute_table_type,
969        p_messages     in out nocopy hxc_message_table_type,
970        p_props        in            hxc_timecard_prop_table_type,
971        p_deposit_mode in            varchar2,
972        p_template     in            varchar2,
973        p_resubmit     in            varchar2,
974        p_can_deposit     out nocopy boolean
975       ) is
976 
977    Begin
978 
979       if(p_template = 'Y') then
980          if(p_deposit_mode <> hxc_timecard.c_delete) then
981             template_validation
982                (p_blocks     => p_blocks,
983                 p_attributes => p_attributes,
984                 p_messages   => p_messages,
985                 p_can_deposit=> p_can_deposit
986                 );
987          end if;
988       else
989          timecard_validation
990             (p_blocks       => p_blocks,
991              p_attributes   => p_attributes,
992              p_messages     => p_messages,
993              p_props        => p_props,
994              p_deposit_mode => p_deposit_mode,
995              p_resubmit     => p_resubmit
996              );
997       end if;
998 
999    End deposit_validation;
1000 
1001 end hxc_timecard_validation;