/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2014 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_MANDATORY_PAYMENTS_V
AS
 SELECT opmtl.org_payment_method_name payment_type_name,
        pay_org_payment_methods_pkg.payee_type ( ppm.payee_type,
                                                 ppm.payee_id,
                                                 sysdate ) payee_name,
        ppm.assignment_id,
        hr_api.return_legislation_code(ppm.business_group_id) legislation_code,
        ppm.personal_payment_method_id
   FROM pay_personal_payment_methods_f ppm,
        pay_org_payment_methods_f_tl opmtl,
        hr_all_organization_units hou
  WHERE ppm.run_type_id IS NULL
    AND ppm.payee_type IN ( 'O',
                            'P' )
    AND sysdate
        BETWEEN ppm.effective_start_date
            AND ppm.effective_end_date
    AND opmtl.org_payment_method_id = ppm.org_payment_method_id
    AND opmtl.language = userenv ( 'LANG' )
    AND hou.organization_id = ppm.payee_id
    AND sysdate
        BETWEEN hou.date_from
            AND nvl ( hou.date_to,
                      to_date ( '31124712',
                                'DDMMYYYY' ) );

BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_MANDATORY_PAYMENTS_V'
   ,p_description            => 'Applaud Vacancy Offers');
END;
/

COMMIT;
EXIT;

