Oracle Fast Formulas - Chapter 11: Practical Example - Writing a Payroll Fast Formula

 

Chapter 11: Practical Example - Writing a Payroll Fast Formula


Objective of This Chapter

In this chapter, you will learn how to create a simple payroll Fast Formula by applying the concepts of variables, conditions, and calculations practically.


Scenario

We want to create a formula to calculate the monthly bonus based on the following rules:

  • If the employee salary is greater than 50000, bonus is 10% of salary.

  • If the employee salary is less than or equal to 50000, bonus is 5% of salary.

  • If the employee is a new joiner (less than 6 months), bonus is fixed at 2000.


Step-by-Step Formula

  1. Inputs
    We need two inputs:

  • SALARY

  • MONTHS_WORKED

INPUTS ARE SALARY, MONTHS_WORKED

  1. Declare Bonus Variable

DEFAULT FOR SALARY IS 0 DEFAULT FOR MONTHS_WORKED IS 0 bonus = 0

  1. Apply Logic for New Joiners

IF MONTHS_WORKED < 6 THEN bonus = 2000

  1. Apply Logic for Other Employees

ELSE IF SALARY > 50000 THEN bonus = SALARY * 0.10 ELSE bonus = SALARY * 0.05

  1. Return the Bonus

RETURN bonus

Full Formula Example

INPUTS ARE SALARY, MONTHS_WORKED DEFAULT FOR SALARY IS 0 DEFAULT FOR MONTHS_WORKED IS 0 bonus = 0 IF MONTHS_WORKED < 6 THEN bonus = 2000 ELSE IF SALARY > 50000 THEN bonus = SALARY * 0.10 ELSE bonus = SALARY * 0.05 RETURN bonus

Testing Example

SALARYMONTHS_WORKEDBONUS
6000086000
4500082250
5000032000

Best Practices Applied

✅ Clear input definitions
✅ Defaults provided
✅ Conditions clearly structured
✅ Easy to maintain and update
✅ Proper RETURN statement


Mini Practice Quiz

  1. What bonus does a new joiner get?
    Answer: 2000

  2. How is the bonus calculated if salary is above 50000?
    Answer: 10% of salary

  3. What happens if SALARY is missing in input?
    Answer: Default value 0 is used.

No comments:

Post a Comment