Edit the Fast Formula for Cycle to Work

You need to change the fast formula that was automatically generated from the element creation.

Navigation: My Client Groups > Show More > Fast Formulas
  1. Search for and select the fast formula IE Cycle to Work Earnings.
  2. Add the default values as shown here:
    DEFAULT FOR purchase_cost       is 0
    DEFAULT FOR Number_of_Recovery_Periods is 1
    DEFAULT FOR Unique_Reference is '0'
    DEFAULT FOR RG_CYCLE_OF_WORK_OPENING_BALANCE_ASG_RC_ITD is 0
    DEFAULT FOR RG_CYCLE_OF_WORK_ASG_ITD is 0
    DEFAULT FOR GROSS_PAY_REL_TU_RUN is 0
    DEFAULT FOR RG_IE_SALARY_SACRIFICE_REL_TU_RUN is 0
  3. Make these changes to the formula.
    • Add new input values.
      , Unique_Reference(text)
      , Number_of_Recovery_Periods
    • Initialize the local variables.
      l_opening_bal = 0
      l_repaid = 0
      l_initial_debt = 0
      l_stop = 'N'
      l_cb_id = GET_CONTEXT(CALC_BREAKDOWN_ID, 1)
      l_gross_pay = 0
      l_salsac = 0
    • Set the context to the current unique reference.
      CHANGE_CONTEXTS (REFERENCE_CODE = Unique_Reference)
      (
        l_opening_bal = RG_CYCLE_OF_WORK_OPENING_BALANCE_ASG_RC_ITD
        l_repaid_bal = RG_CYCLE_OF_WORK_ASG_ITD * -1
      )
    • Comment out the predefined periodicity rule.
      PERIODICITY_CONVERSION_RULE> 'method',
              l_source_periodicity > 'SOURCE_PERIODICITY',
           l_target_periodicity > 'TARGET_PERIODICITY',
         l_date_earned > 'effdate',
           l_actual_start_date > 'start_date',
          l_actual_end_date > 'end_date',
              l_convert_amount  < 'TARGET_AMOUNT' DEFAULT 0
           )*/
    • Derive the period value from the input, instead.

      l_convert_amount = (l_opening_bal + l_initial_debt) / Number_of_Recovery_Periods	 
        l_value=l_convert_amount
        l_log = PAY_INTERNAL_LOG_WRITE('(GLBEARN) Convert amount :'||TO_CHAR(l_convert_amount))
        )
    • To avoid a negative net amount.

        l_log = PAY_INTERNAL_LOG_WRITE('(GLBEARN) Derived value : '||TO_CHAR(l_value))
      
        if GET_PLED_LSED <= PAY_EARN_PERIOD_END then
          l_value = l_opening_bal + l_initial_debt - l_repaid_bal 
        
        if l_value > l_gross_pay + l_salsac then
        (
          l_value = l_gross_pay + l_salsac
      	mesg = 'Not enough earnings, so Cycle to Work (Ref: '||Unique_Reference||') deducted partially'
    • Convert the periodic amount to negative

        l_log = PAY_INTERNAL_LOG_WRITE('l_value v2: '||TO_CHAR(l_value))
        
        l_value = l_value * -1
    • Return various result values based on the scenario.

      if l_stop = 'Y' and l_initial_debt <> 0 then
          return l_value,l_hours,l_days,l_reduce,l_reduce_hours,l_reduce_days,l_reduce_abs,l_reduce_abs_hours ,l_reduce_abs_days ,mesg, l_stop, l_initial_debt
        if l_stop = 'Y' then
          return l_value,l_hours,l_days,l_reduce,l_reduce_hours,l_reduce_days,l_reduce_abs,l_reduce_abs_hours ,l_reduce_abs_days ,mesg, l_stop
        if l_initial_debt <> 0 then
          RETURN l_value,l_hours,l_days,l_reduce,l_reduce_hours,l_reduce_days,l_reduce_abs,l_reduce_abs_hours ,l_reduce_abs_days ,mesg, l_initial_debt
        
        RETURN l_value,l_hours,l_days,l_reduce,l_reduce_hours,l_reduce_days,l_reduce_abs,l_reduce_abs_hours ,l_reduce_abs_days ,mesg
      )
  4. Save your changes.