/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2017 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

CREATE OR REPLACE VIEW xxas_absence_event_view_edit_v 
AS
SELECT xamv.person_id
      ,(CASE WHEN xamv.action = 'APPROVED_OR_UPDATE'
            THEN absence_attendance_id
            ELSE absence_attendance_id_p
        END) absence_attendance_id
      ,xamv.transaction_id
      ,xamv.transaction_step_id
      ,xamv.hr_api_status_code status
      ,xxas_util_pkg.get_primary_worker_asg(xamv.person_id,trunc(sysdate)) assignment_id
      ,(CASE WHEN xamv.action = 'APPROVED_OR_UPDATE'
            THEN date_start
            ELSE date_start_p
        END) date_start  
FROM   xxas_absence_management_v xamv;

BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_ABSENCE_EVENT_VIEW_EDIT_V'
   ,p_description            => 'Applaud Absence Events View Edit View');
END;
/

COMMIT;
EXIT;

