Tuesday, 11 February 2020

Hrms Technical(Create the Function ,Fast Formula & Link the Fast Formula to the Element))

***To create fast formula , first we have to develop and execute one function as per the requirement. After executing the function we have to define the function in front end and have to create the fast formula.
The following steps will use for creating fast formula.

1) Develop and Execute the Function(XXSE_FOOD_ALLWNC_FIXED)
----------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION APPS.xxse_food_allwnc_fixed (
   p_business_group_id    IN   NUMBER,
   p_assignment_id        IN   NUMBER,
   p_payroll_id           IN   NUMBER,
   p_element_name         IN   VARCHAR2,
   p_input_name           IN   VARCHAR2,
   p_payroll_start_date   IN   DATE,
   p_payroll_end_date     IN   DATE
)
   RETURN NUMBER
AS
   -- +================================================================================+
-- |                        Seertree Solutions,Chennai,India                        +
-- +================================================================================+
-- |                                                                                |
-- | $Id: XXSE_FOOD_ALLWNC_FIXED.fnc                                                |
-- |                                                                                |
-- | Description : SQL Scripts for                                                  |
-- |               Getting Employee  Food Allowance Fixed Based Working Days        |
-- |                                                                                |
-- |                                                                                |
-- |Change Record:                                                                  |
-- |===============                                                                 |
-- |Version   Date        Author           Remarks                                  |
-- +=======   =========== =============    =========================================+
-- |1.0       04-Dec-2019 Subba Reddy      Initial Version.                         |
-- |                                                                                |
--+=================================================================================+
   l_aac_proration       NUMBER := 0;
   l_emp_work_day        NUMBER := 0;
   l_emp_bas_sal         NUMBER := 0;
   l_person_id           NUMBER;
   l_asg_id              NUMBER;
   l_basic_mon_amt       NUMBER;
   l_month_act_day_cnt   NUMBER := 0;
   l_basic_day_amt       NUMBER := 0;
   l_food_allwnc_fixed   NUMBER := 0;
   l_glb_sit_inct        NUMBER := 0;
   l_idle_count          NUMBER := 0;
   l_sit_inct_pay_val    NUMBER := 0;
BEGIN
/* We have to pass the Food Allowance Fixed Element name and Input value name to the XXSE_EMP_WORK_DAY_BASIC_SAL. This function wil work for mots of the
 Elements(Not only for Basic).Here we are getting the monthly amount of the element(After calculating all leaves,materinity/paterinity,sick...leaves.*/
   l_food_allwnc_fixed :=
      xxse_emp_work_day_basic_sal (p_business_group_id,
                                   p_assignment_id,
                                   p_payroll_id,
                                   p_element_name,
                                   p_input_name,
                                   p_payroll_start_date,
                                   p_payroll_end_date
                                  );

   --  */
   --Getting Monthly Amount Value of the Site Incentive SE Element
   BEGIN
      l_person_id := 0;
      l_asg_id := 0;
      l_basic_mon_amt := 0;

      SELECT ppf.person_id, pam.assignment_id,
             NVL (screen_entry_value, 0) basic_sal,
             CASE
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Jan'
                   THEN 31
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Feb'
                   THEN DECODE (MOD (TO_CHAR (ppt.start_date, 'YYYY'), 4),
                                0, 29,
                                28
                               )
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Mar'
                   THEN 31
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Apr'
                   THEN 30
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'May'
                   THEN 31
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Jun'
                   THEN 30
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Jul'
                   THEN 31
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Aug'
                   THEN 31
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Sep'
                   THEN 30
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Oct'
                   THEN 31
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Nov'
                   THEN 30
                WHEN TO_CHAR (ppt.start_date, 'Mon') = 'Dec'
                   THEN 31
             END month_act_day_cnt                                         --,
--             ppf.original_date_of_hire emp_hire_date
      INTO   l_person_id, l_asg_id,
             l_basic_mon_amt,
             l_month_act_day_cnt                                           --,
--             l_emp_hire_date
      FROM   per_all_people_f ppf,
             per_all_assignments_f pam,
             pay_element_entries_f pe,
             pay_element_types_f pet,
             pay_input_values_f pi,
             pay_element_entry_values_f pee,
             pay_payrolls_f pp,
             per_time_periods ppt
       WHERE 1 = 1
         --AND ppf.employee_number = '1000032'
         AND SYSDATE BETWEEN ppf.effective_start_date AND ppf.effective_end_date
         AND ppf.person_id = pam.person_id
         AND SYSDATE BETWEEN pam.effective_start_date AND pam.effective_end_date
         AND pam.assignment_id = pe.assignment_id
         AND SYSDATE BETWEEN pe.effective_start_date AND pe.effective_end_date
         AND pe.element_type_id = pet.element_type_id
         --AND pet.element_name = 'Basic Salary'        --Entries Form(Elements)
         AND SYSDATE BETWEEN pet.effective_start_date AND pet.effective_end_date
         AND pet.element_type_id = pi.element_type_id
         --AND pi.NAME = 'Monthly Amount'
         --Entry Values Form for the Basice Salary Element
         AND SYSDATE BETWEEN pi.effective_start_date AND pi.effective_end_date
         AND pe.element_entry_id = pee.element_entry_id
         AND pi.input_value_id = pee.input_value_id
         AND SYSDATE BETWEEN pee.effective_start_date AND pee.effective_end_date
         AND pam.payroll_id = pp.payroll_id
         AND SYSDATE BETWEEN pp.effective_start_date AND pp.effective_end_date
         AND pp.payroll_id = ppt.payroll_id
         AND pam.business_group_id =
                              NVL (p_business_group_id, pam.business_group_id)
         AND pam.assignment_id = NVL (p_assignment_id, pam.assignment_id)
         AND pam.payroll_id = NVL (p_payroll_id, pam.payroll_id)
         AND pet.element_name = NVL (p_element_name, pet.element_name)
         AND pi.NAME = NVL (p_input_name, pi.NAME)
         AND ppt.start_date = NVL (p_payroll_start_date, ppt.start_date)
         AND ppt.end_date = NVL (p_payroll_end_date, ppt.end_date);
   EXCEPTION
      WHEN OTHERS
      THEN
         l_person_id := 0;
         l_asg_id := 0;
         l_basic_mon_amt := 0;
--         l_emp_hire_date := NULL;
   END;

   --getting day amount of the Site Incentive SE
   l_basic_day_amt := l_basic_mon_amt / l_month_act_day_cnt;

   --
   --Getting Idle Days of the Employee
   BEGIN
           /* SELECT COUNT (NVL (idle, 0)) idle_count
              INTO l_idle_count
              FROM per_all_people_f ppf,
                   sawaeed.xx_upload_final_timesheet x,
                   per_all_assignments_f pam,
                   sawaeed.xx_job_header xj
             WHERE 1 = 1
               -- AND ppf.employee_number = '1000032'
               AND ppf.employee_number = x.employee_number
               AND SYSDATE BETWEEN ppf.effective_start_date AND ppf.effective_end_date
               -- AND x.employee_status = 'ACTIVE'
      --         AND UPPER (x.idle) = 'YES'--Commented on 22-Dec-2019'
               --If idle is yes for those we can't pay the value
               AND ppf.person_id = pam.person_id
               AND x.job_code = xj.job_code
               --         and upper(xj.JOB_NAME) not like '%IDLE%'--Commented on 22-Dec-2019'
               AND UPPER (xj.job_name) LIKE '%IDLE%'         --Added on 22-Dec-2019'
               AND UPPER (x.absent) = 'NO'                   --Added on 22-Dec-2019'
               AND SYSDATE BETWEEN pam.effective_start_date AND pam.effective_end_date
               AND pam.business_group_id =
                                    NVL (p_business_group_id, pam.business_group_id)
               AND pam.assignment_id = NVL (p_assignment_id, pam.assignment_id)
               AND pam.payroll_id = NVL (p_payroll_id, pam.payroll_id)
               AND gl_date BETWEEN NVL (p_payroll_start_date, x.gl_date)
                               AND NVL (p_payroll_end_date, x.gl_date);*/--COmmented on 23-Dec-2019
      SELECT COUNT (NVL (idle, 0)) idle_count
        INTO l_idle_count
        FROM per_all_people_f ppf,
             sawaeed.xx_upload_final_timesheet x,
             per_all_assignments_f pam,
             fnd_lookup_values fl
       WHERE 1 = 1
         -- AND ppf.employee_number = '1000032'
         AND ppf.employee_number = x.employee_number
         AND SYSDATE BETWEEN ppf.effective_start_date AND ppf.effective_end_date
         AND ppf.person_id = pam.person_id
         AND UPPER (x.absent) = 'NO'
         AND x.job_code = fl.lookup_code
         AND fl.lookup_type = 'XXSE_IDLE_JOB'
         AND fl.LANGUAGE = 'US'
         AND SYSDATE BETWEEN pam.effective_start_date AND pam.effective_end_date
         AND pam.business_group_id =
                              NVL (p_business_group_id, pam.business_group_id)
         AND pam.assignment_id = NVL (p_assignment_id, pam.assignment_id)
         AND pam.payroll_id = NVL (p_payroll_id, pam.payroll_id)
         AND gl_date BETWEEN NVL (p_payroll_start_date, x.gl_date)
                         AND NVL (p_payroll_end_date, x.gl_date);
   EXCEPTION
      WHEN OTHERS
      THEN
         l_idle_count := 0;
   END;

--   --Here we are reducing the idle days count fronm the work day count
--   l_emp_work_day :=l_emp_work_day -nvl(l_idle_count,0);
   --Calculating Site Incentive(Here we are substrating of the element day amount * Emp Idle Days)
   l_food_allwnc_fixed :=
               l_food_allwnc_fixed
               - (l_basic_day_amt * NVL (l_idle_count, 0));
   RETURN NVL (l_food_allwnc_fixed, 0);
EXCEPTION
   WHEN OTHERS
   THEN
      l_food_allwnc_fixed := 0;
      RETURN l_food_allwnc_fixed;
END xxse_food_allwnc_fixed;

/

2) Register the function(XXSE_FOOD_ALLWNC_FIXED) in front end:
----------------------------------------------------------------------------------------------
-->Go to the HRMS responsibility.
-->Go to 'Other Definitions' ->Click on 'Formula Function'-->It will open the 'Define Function' form.




Name :  Give any Unique Name. Here i am giving XXSE_FOOD_ALLWNC_FIXED
Data Type : Give the return type the above developed function.
Class : External Function
Definition : Here you have to give the function name developed above(XXSE_FOOD_ALLWNC_FIXED).

-->Click on Save
-->Click on Context Usages-->Here you have to give the parameters used in the function.

--> The above 3 parameters are automatically pass the values to the function at payroll run time.
-->In 'Define Function' form click on parameters and enter the remain parameters as follows.


-->For the above parameters we have assign the values in the fast formula.
-->Click on Save.

3) Creating Fast Formula:
------------------------------------
-->Go to the HRMS responsibility.
-->Go to 'Total Compensation' ->Click on 'Basic'-->Click on 'Write Formulas'-->It will open the 'Formula' form.


***After opening the form Change the Date in above "Calendar' icon for effective dates.
Name : Give anyUnique Name.
Type : Oracle Payroll


--->Click on Edit --> and paste the following logic and click on verify.
-->Click on Save.


/* ----------------------------------------------------------------
This Formula is to Calculate Monthly Food Allowance Fixed  of an Employee Based on Working Days.

Element Requirements
1.Food Allowance Fixed(R/W)

User Defined Function
1.XXSE_FOOD_ALLWNC_FIXED

Date                       Author                    Changes
04-Dec-2019            Subba Reddy                   Created
------------------------------------------------------------------ */

/* ====== Variables Value Defaults Begin ====== */
DEFAULT FOR Food_Allwnc_Fixed is 0
DEFAULT FOR E_DATE is '31-DEC-4712' (DATE)
DEFAULT FOR S_DATE is '01-JAN-1900' (DATE)
/* ====== Variables Value Defaults Ends ====== */

/* ====== Database Items Defaults Begin ====== */
DEFAULT FOR PAY_PROC_PERIOD_START_DATE is '01-JAN-1900'(DATE)
DEFAULT FOR PAY_PROC_PERIOD_END_DATE is '31-DEC-4712'(DATE)
DEFAULT FOR EMP_HIRE_DATE is '01-JAN-1900'(DATE)
DEFAULT FOR EMP_TERM_DATE IS '31-DEC-4712'(DATE)
/* ====== Database Items Defaults Ends ====== */

/* ====== Formula Body Starts ====== */

ACT_TERM_DATE = TO_DATE('4712/12/31 00:00:00','YYYY/MM/DD HH24:MI:SS')

E_DATE = LEAST(PAY_PROC_PERIOD_END_DATE,EMP_TERM_DATE, ACT_TERM_DATE)
S_DATE = GREATEST(PAY_PROC_PERIOD_START_DATE,EMP_HIRE_DATE)

/* Calling the function for getting the prorated value */
Food_Allwnc_Fixed = ROUND(XXSE_FOOD_ALLWNC_FIXED
                                     ('Food Allowance Fixed',
                                      'Monthly Amount',
                                       PAY_PROC_PERIOD_START_DATE,
                                       PAY_PROC_PERIOD_END_DATE),2)


RETURN Food_Allwnc_Fixed

/* ====== Formula Body Ends ====== */


4) Link the Fast Formula to the Element:
-----------------------------------------------------

-->Go to the HRMS responsibility.
-->Go to 'Total Compensation' ->Click on 'Basic'-->Click on 'Formula Resultss'-->It will open the 'Formula Result Rules' form.
***After opening the form Change the Date in above "Calendar' icon for effective dates.

-->Give the Element Name and click on find and enter the following details.


***At the time of running the payroll , elements will calculate the values based on the above fast formula and return the run result values.


















No comments:

Post a Comment

API to Delete Assignment Set

*** Before going to Delete Assignment Set first we have to delete the Assignment Amendments after that only we have to delete the Assignmen...