1. Home
  2. Sample Projects
  3. Leave Calculator

Leave Calculator

◷ Reading Time: 7 minutes

Introduction

The sample will show how to build a project that calculates the employee vacation days.

Scenario

 In an employee benefits and entitlement system you would have many rules, some of which are designed to calculate employee vacation days. In this example we use following company policy to determine how many vacation days employee has.

Every employee receives at least 22 days. Additional days are provided based on the following criteria:
1. Only employees younger than 18 or at least 60 years of age, or employees with at least 30 years of service, will receive 5 extra days.
2. Employees with at least 30 years of service and also employees of 60 years of age or more will receive 3 extra days, in addition to any extra days already given.
3. If an employee has at least 15, but less than 30 years of service, 2 extra days are given. These 2 days are also provided for employees of age 45 or more.
These 2 extra days cannot be combined with the 5 extra days specified above.

Running the Sample

  • Open the file TotalVacationDateCalculation.xml
  • Click on the Logic Run template.
  • Click on any given template.
  • You can click the ‘Next Step’ button to go step by step to follow the flow.
  • Now you can see the output values in the ‘Parameters’ window.

Process Steps

The process contains the following steps to calculate the employee vacation days .

  1. Calculate base vacation days
  2. Calculate extra vacation days
  3. Calculate total vacation dates

Project Description

The project contains the following documents.

Decision Graph

  • TotalVacationDateCalculation.xml – shows the main data flow

Decision Table

  • BaseDay.xml – Every employee receives at least 22 days.
  • Extra2Days.xml – Extra 2 days for eligible employees
  • Extra3Days.xml – Extra 3 days for eligible employees
  • Extra5Days.xml – Extra 5 days for eligible employees
  • TotalVacationDates.xml – Calculate total vacation dates for a given employees

Fact Concept

  • Employee.xml – Define ‘EmployeeData’, and ‘Eligibility’ objects

The Flow Design

  1. Define the EmployeeData in the fact concept document.
  • EmployeeData.xml

2. Define the Eligibility as another fact in the fact concept document.

3. Create a TotalVacationDateCalculation.xml as a Decision Graph to calculate total vacation dates.

LeaveCalculator
  • BaseDay.xml – Every employee receives at least 22 days.
  • Extra5Days.xml – Only employees younger than 18 or at least 60 years of age, or employees with at least 30 years of service, will receive 5 extra days.
Extra5days
  • Extra3Days.xml – Employees with at least 30 days of service and also employees of age 60 or more, receive 3 extra days, in addition to the possible extra days already given.
  • Extra2Days.xml – If an employee has at least 15, but less than 30 years of service, 2 extra days are given. These 2 days are also provided for employees of age 45 or more. These 2 extra days cannot be combined with the 5 extra days specified previously. (This part is handled when we add up all the values in total vacation days)

4. TotalVacationDates.xml – In here, we calculate the total days based on eligibility for base days and extra days: Total vacation days based on other decision tables

Total Leave calculator
  • Aggregation function – You also need to set the last table aggregation method to Sum based on Rules Order. So the result will be sum of the last column (Vacation Days).

Create and Run Tests Case

You can define some tests cases for the model inside the Test Case Editor.

Then you can run the test case by clicking on Run Tests button.

Test Cases

Download the project

Use the attachment at the end of the page to download the sample project.

Updated on November 22, 2022

Article Attachments

Was this article helpful?

Related Articles