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


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

DECLARE

  --
  -- Local constants and variables
  --
  l_SERVICE CONSTANT xxas_com_service_repository.service_name%TYPE
                       := 'ChangePay';

BEGIN


  xxas_com_sr_pkg.set_rest_service
    (p_service_name       => l_SERVICE
    ,p_description        => 'Change Pay'
    ,p_path               => '/changepay'
    ,p_consumes           => 'application/xml'
    ,p_produces           => 'application/xml');
    
  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'ListSalaryBasis'
    ,p_description        => 'List of all Salary basis'
    ,p_path               => 'salarybasis'
    ,p_methods            => 'GET'
    ,p_remove_root_ele    => true
    ,p_sql                =>
      q'[
        SELECT XMLElement
                 ("data"
                 ,XMLAttributes
                   ('true' as "json:force-array"
                   ,'http://json.org/' as "xmlns:json")
                 ,XMLAgg
                   (XMLElement
                     ("obj"
                     ,XMLForest
                       (rslt.id "id"
                       ,rslt.value "value"
                       ,rslt.value "label"
                       )
                     )
                   )
                 ) "data"
        FROM  xxas_salary_basis_v rslt
		WHERE rslt.business_group_id = (SELECT business_group_id FROM per_all_people_f WHERE person_id = nvl({requestParam.personId},fnd_global.employee_id)
        AND trunc(sysdate) BETWEEN effective_start_date AND effective_end_date)
        ]'
    );

END;
/
COMMIT;
EXIT;