All decision models

Rules-based decision model

Decision Model “Vacation Days”

Calculate an employee’s vacation allowance from age and years of service using transparent, testable business rules.

Business logic

Start with 22 days, then apply the eligible extras.

  • Every employee receives at least 22 vacation days.
  • Employees younger than 18, at least 60, or with at least 30 years of service receive 5 additional days.
  • Employees who have at least 30 years of service and are at least 60 receive another 3 days.
  • Employees with 15–29 years of service, or who are at least 45, may receive 2 days; these cannot be combined with the extra 5 days.
Calculate Vacation Days multi-hit decision table
Main table: Calculate Vacation DaysOpen full size ↗
Decision table for eligibility for five extra vacation days
Eligibility for 5 extra daysOpen full size ↗
Decision table for eligibility for three extra vacation days
Eligibility for 3 extra daysOpen full size ↗
Decision table for eligibility for two extra vacation days
Eligibility for 2 extra daysOpen full size ↗

Model in Excel

Separate the final calculation from its eligibility decisions.

The multi-hit CalculateVacationDays table executes all satisfied rules and accumulates the allowance. Three supporting decision tables determine eligibility for the extra 5, 3, and 2 days.

A glossary defines all input variables and goals. The four decision tables are stored in rules/Rules.xlsx, and OpenRules Explorer automatically builds a diagram of their relationships.

Vacation Days business glossary
Business glossaryOpen full size ↗
Complete Vacation Days decision model in Excel
Complete Excel-based modelOpen full size ↗
Vacation Days diagram generated by OpenRules Explorer
Automatically generated decision diagramOpen full size ↗

Test and explain

Run the same model against reusable test cases.

Test cases live in rules/Test.xlsx. The rules/DecisionModel.xlsx environment table identifies the related model files, while project.properties configures execution.

Double-click test.bat to generate executable code and evaluate all test cases. The resulting HTML report identifies the rules that ran and explains the calculated allowance.

Vacation Days test cases in Excel
Test cases and expected resultsOpen full size ↗
Vacation Days Environment table
Environment tableOpen full size ↗
Vacation Days project properties
Project configurationOpen full size ↗
Vacation Days execution result for test case D
Test-case execution resultOpen full size ↗
Vacation Days rule explanation report
Generated explanation reportOpen full size ↗

Integration

Use the tested model from Java or deploy it as a service.

The generated DecisionModelVacationDays class exposes the available goals. A Java application supplies an Employee object, executes the Vacation Days goal, and reads the result. The same model can also be deployed as a containerized decision service.

Java launcher for the Vacation Days model
Java integration exampleOpen full size ↗

Try the model yourself

Download OpenRules and run the samples.

The evaluation includes working decision projects that you can inspect, test, debug, and adapt.