/* $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_review_v 
AS
SELECT xamr.person_id
      ,(CASE WHEN xamr.action = 'APPROVED_OR_UPDATE'
            THEN absence_attendance_id
            ELSE absence_attendance_id_p
        END) absence_attendance_id
      ,xamr.transaction_id
      ,xamr.transaction_step_id
      ,xamr.hr_api_status_code status
      ,xxas_util_pkg.get_primary_worker_asg(xamr.person_id,trunc(sysdate)) assignment_id
FROM   xxas_absence_management_rev_v xamr;

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

COMMIT;
EXIT;

