Sie sind auf Seite 1von 6

/********************************************************************** $Header: pyust125.sql 120.0.12010000.

2 2009/05/25 07:20:38 sudedas ship $ FORMULA NAME: MEDICAL_PLAN_125_PTX_DEDN_EE FORMULA TYPE: Payroll DESCRIPTION : Contains formula to handle 125 Pretax category for Flat Amt/Perc Caculations *********************************************************************** Change History: Name Date Description ----------------------------------------------------------------------Mehul Shah 27-JUN-2001 Initial Version *********************************************************************** FORMULA TEXT -----------Formula Results : clear_repl_amt Update Recurring Replacement_Amount clear_addl_amt Update Recurring Additional_Amount dedn_amt Direct Result for Deduction Amount error_mesg Message (Fatal) mesg Message (Warning) not_taken Update Deduction Recurring Entry Not Taken stop_entry Stop current recurring entry to_total_owed Update Deduction Recurring Entry Accrued to_arrears Update Deduction Recurring Entry Arrears Contr **********************************************************************/ /*================ DATABASE ITEM DEFAULTS BEGIN =====================*/ Default for NET_ASG_GRE_RUN is 0 Default for TERMINATED_EMPLOYEE is 'N' Default for FINAL_PAY_PROCESSED is 'N' Default for ELEMENT_CATEGORY is ' ' Default for ASG_SALARY is 0 Default for MEDICAL_PLAN_ACCRUED_ASG_GRE_ITD is 0 Default for MEDICAL_PLAN_ARREARS_ASG_GRE_ITD is 0 Default for MEDICAL_PLAN_ARREARS_ASG_GRE_LTD is 0 Default for MEDICAL_PLAN_ASG_GRE_RUN is 0 Default for MEDICAL_PLAN_ASG_GRE_YTD is 0 Default for MEDICAL_PLAN_ASG_GRE_MONTH is 0 Default for MEDICAL_PLAN_ELIGIBLE_COMP_ASG_RUN is 0 Default for MEDICAL_PLAN_PERIOD_TYPE is 'NOT ENTERED' Default for MEDICAL_PLAN_PARTIAL_EE_CONTRIBUTIONS is 'N' Default for MEDICAL_PLAN_ADDITIONAL_AMOUNT_ASG_GRE_ITD is 0 Default for MEDICAL_PLAN_REPLACEMENT_AMOUNT_ASG_GRE_ITD is 0 Default Default ED' Default Default Default for PAY_US_ITERATIVE_METHOD is 'NOT ENTERED' for ORG_DEVELOPER_DF_US_ITERATIVE_RULES_ITERATIVE_METHOD is 'NOT ENTER for PAY_US_PRE_TAX_FIT_TO_WITHIN is '0' for ORG_DEVELOPER_DF_US_ITERATIVE_RULES_PRE_TAX_FIT_TO_WITHIN is '0' for FEDERAL_ASG_FIT_EXEMPT is 'N'

/*================= DATABASE ITEM DEFAULTS ENDS======================*/ /*================= INPUT VALUES DEFAULT BEGIN ======================*/ Default for EE_Contr is 0 Default for ER_Contr is 0 Default for Period_Type is 'NOT ENTERED' Default for Percentage is 0

Default for Total_Owed is 0 Default for Towards_Owed (text) is 'Y' Default for Clear_Arrears (text) is 'N' Default for Threshold_Amount is 0 /*=================== INPUT VALUES DEFAUT ENDS ======================*/ /*===================== INPUTS SECTION BEGIN ========================*/ INPUTS are EE_Contr ,ER_Contr ,Period_Type (text) ,Percentage ,Total_Owed ,Towards_Owed (text) ,Clear_Arrears(text) ,Threshold_Amount /*====================== INPUTS SECTION ENDS ========================*/ /*===================== FORMULA SECTION BEGIN =======================*/ iter_cnt = GET_ITER_COUNT() l_arrears_asg_gre_ltd = MEDICAL_PLAN_ARREARS_ASG_GRE_LTD l_partial_contrib = MEDICAL_PLAN_PARTIAL_EE_CONTRIBUTIONS owed_flag = 'N' ic_mesg = 'IC = '|| to_char(iter_cnt) /* out variables for the function */ max_dedn = 0 min_dedn = 0 max_desired_amt = 0 calc_method = 'Interpolation' to_within = 1 clear_addl_amt = 0 clear_repl_amt = 0 dedn_amt = GET_ITER_VALUE(iter_cnt,max_dedn, min_dedn, max_desired_amt,calc_method,to_within, clear_addl_amt,clear_repl_amt) ins_flag = GET_INSERTED_FLAG() /* check for stopper */ stop_flag = GET_STOPPER_FLAG() if stop_flag = 'Y' then ( ic_mesg = ic_mesg || ' Stop ' dedn_amt = 0 iter_cnt = 2 ) else ( /* stopper is not set */ if iter_cnt <= 1 and ins_flag = 'N' then ( IF MEDICAL_PLAN_REPLACEMENT_AMOUNT_ASG_GRE_ITD WAS DEFAULTED OR MEDICAL_PLAN_REPLACEMENT_AMOUNT_ASG_GRE_ITD = 0 THEN (

IF EE_Contr WAS DEFAULTED AND /* NOT Flat Amount */ Percentage WAS DEFAULTED THEN /* NOT Percent either! */ ( mesg='MEDICAL_PLAN: No values found to calculate deduction.' ) IF Percentage WAS DEFAULTED THEN /* Flat Amount Calc */ ( /* * get deduction factor for the user i/p period type, if it * is not entered at the input level, check at the element * level */ IF Period_Type WAS DEFAULTED THEN deduction_freq_factor = DEDN_FREQ_FACTOR(MEDICAL_PLAN_PERI OD_TYPE) ELSE ( period_desc = GET_LOOKUP_MEANING('PROC_PERIOD_TYPE', Peri od_Type) deduction_freq_factor = DEDN_FREQ_FACTOR(period_desc) ) dedn_amt = EE_Contr * deduction_freq_factor IF Period_Type = UPPER('Calendar Month') AND (dedn_amt + MEDICAL_PLAN_ASG_GRE_MONTH - EE_Contr ) <= .02 AND (MEDICAL_PLAN_ASG_GRE_MONTH + dedn_amt) > EE_Contr THEN dedn_amt = EE_Contr - MEDICAL_PLAN_ASG_GRE_MONTH ) ELSE /* Percentage calculation */ ( /*============================================================= *================ CUSTOMER PLEASE NOTE ======================= *============================================================= * MEDICAL_PLAN_ELIGIBLE_COMP_ASG_RUN balance is used by default * by this formula to calculate % of Earnings. This balance is * initially defined with feed from the Regular Earnings balance. * You can modify this by adding/deleting other balance feeds. * If you want the formula to use another balance of earnings in * the run, replace this Database item below with item of your * choice : <BALANCE_NAME_IN_UPPER_CASE/UNDERSCORES>_ASG_RUN *==============================================================*/ deduction_freq_factor = DEDN_FREQ_FACTOR(MEDICAL_PLAN_PERIOD_T YPE) dedn_amt = (Percentage * MEDICAL_PLAN_ELIGIBLE_COMP_ASG_RUN / 100 * Deduction_Freq_Factor ) ) ) ELSE ( /* Replacement amount was entered */ dedn_amt = MEDICAL_PLAN_REPLACEMENT_AMOUNT_ASG_GRE_ITD clear_repl_amt = MEDICAL_PLAN_REPLACEMENT_AMOUNT_ASG_GRE_ITD * -1 ) /*================== TEMPLATE ADJUSTMENTS BEGIN ====================*/ IF MEDICAL_PLAN_ADDITIONAL_AMOUNT_ASG_GRE_ITD <> 0 THEN

( dedn_amt = dedn_amt + MEDICAL_PLAN_ADDITIONAL_AMOUNT_ASG_GRE_ITD clear_addl_amt = -1 * MEDICAL_PLAN_ADDITIONAL_AMOUNT_ASG_GRE_ITD ) /*================ TEMPLATE ADJUSTMENTS SECTION ENDS ================*/ max_desired_amt = 0 user_calc_amt = dedn_amt ) /* end count = 0 */ ) /* stopper is not set */ /*=================== LATEST BALANCE CREATION BEGIN =================*/ SOE_run = MEDICAL_PLAN_ASG_GRE_RUN SOE_ytd = MEDICAL_PLAN_ASG_GRE_YTD /*=================== LATEST BALANCE CREATION ENDS ==================*/ /*==================== ARREARS SECTION BEGIN ========================*/ temp_to_arrears temp_not_taken guaranteed_net temp_dedn_amt to_arrears temp_arrears_bal = = = = = = 0 0 0 dedn_amt 0 0

IF Clear_Arrears = 'N' THEN temp_arrears_bal = l_arrears_asg_gre_ltd /*MEDICAL_PLAN_ARREARS_ASG_GRE_LTD */ ELSE /* Call arrearage with 0 as arrears bal b/c it has been cleared */ to_arrears = -1 * l_arrears_asg_gre_ltd /*MEDICAL_PLAN_ARREARS_ASG_GRE_LTD */ dedn_amt = ITERATIVE_ARREARAGE(l_partial_contrib, NET_ASG_RUN, temp_arrears_bal, guaranteed_net, dedn_amt, max_desired_amt, iter_cnt, temp_to_arrears, temp_not_taken, ins_flag) func_dedn_amt = dedn_amt /* Only create formula results when necessary... */ IF temp_to_arrears <> 0 THEN to_arrears = to_arrears + temp_to_arrears IF temp_not_taken <> 0 THEN not_taken = temp_not_taken /*===================== ARREARS SECTION END =========================*/ /*=================== STOP RULE SECTION BEGIN =======================*/ IF Total_Owed WAS NOT DEFAULTED THEN IF Towards_Owed = 'Y' THEN ( /* Put towards total owed - ie reduce declining balance */

Total_Accrued = dedn_amt + MEDICAL_PLAN_ACCRUED_ASG_GRE_ITD IF total_accrued >= Total_Owed THEN ( owed_flag = 'Y' dedn_amt = Total_Owed - MEDICAL_PLAN_ACCRUED_ASG_GRE_ITD /* * The total has been reached,return will stop the entry. * Also, zero out Accrued balance. */ to_total_owed = -1 * MEDICAL_PLAN_ACCRUED_ASG_GRE_ITD stop_entry = 'Y' mesg = 'MEDICAL_PLAN has reached total owed.' ) ELSE /* Total Owed not reached yet. */ to_total_owed = dedn_amt ) /*=================== STOP RULE SECTION ENDS =======================*/ /*==================== SET ITERATIVE VALUES =========================*/ if iter_cnt <= 1 and ins_flag = 'N' then ( /* get the calculation method once */ /* Payroll level */ if PAY_US_ITERATIVE_METHOD was Defaulted then ( /* check BG level */ if ORG_DEVELOPER_DF_US_ITERATIVE_RULES_ITERATIVE_METHOD was defaulted then ( calc_method = 'Interpolation' to_within = 1 ) else ( calc_method = ORG_DEVELOPER_DF_US_ITERATIVE_RULES_ITERATIVE_METH OD to_within = to_number(ORG_DEVELOPER_DF_US_ITERATIVE_RULES_PRE_TA X_FIT_TO_WITHIN) ) ) else ( calc_method = PAY_US_ITERATIVE_METHOD to_within = to_number(PAY_US_PRE_TAX_FIT_TO_WITHIN) ) if FEDERAL_ASG_FIT_EXEMPT = 'Y' then to_within = 0 min_amt = 0 if owed_flag = 'Y' then ( max_amt = LEAST(dedn_amt,func_dedn_amt) max_desired_amt = LEAST(dedn_amt,user_calc_amt) ) else ( max_amt = GREATEST(dedn_amt,user_calc_amt) max_desired_amt = user_calc_amt )

inserted_flag = 'Y' dummy1 = SET_ITER_VALUE(iter_cnt,max_amt,min_amt,max_amt, max_desired_amt, calc_method, to_within, clear_addl_amt,clear_repl_amt) dummy = ITERATION_INITIALISE(max_amt, min_amt, max_amt) flag_inserted = SET_INSERTED_FLAG(inserted_flag) if l_partial_contrib = 'Y' and calc_method = 'Interpolation' then dummy2 = ITERATION_GET_INTERPOLATION(0) ) /*=================== SET ITERATIVE VALUES END ======================*/ /*====================== FORMULA SECTION ENDS =======================*/ /*===================== RETURN SECTION ==============================*/ RETURN Clear_Repl_Amt ,clear_addl_amt ,dedn_amt ,mesg ,ic_mesg ,not_taken ,stop_entry ,to_total_owed ,to_arrears ,iter_cnt ,user_calc_amt ,func_dedn_amt ,min_amt ,max_amt ,min_dedn ,max_dedn ,max_desired_amt ,calc_method ,to_within ,ER_Contr /*========================= End Program =============================*/