# Time Off: How to retrieve the exact number of days within a Holiday Calendar Year

While configuring accrual Business Rules for Time Account Types within Time Off, it is common to leverage on the difference between “Accrual Period” and “Accruable Period”.

The Accrual Period always contains the full period that is the subject of the accrual process.
For a yearly accrual, for example, it would reach from 1st of January to 31st of December in most cases.
However, when the employee is hired on, for example, 1st of April, the target accrual amount should somehow reflect this shorter period.

This is where the Accruable Period comes into play, reflecting the period from 1st of April to 31st of December.

This means that the Accruable Period is derived from the Accrual Period shortened by some factors. The Accrual Period and the Accruable Period can then be used in the accrual rule to determine the right booking amount based on the correct prorations.

But in some cases, you would still need to manually determine your prorations within the accrual rule.
This can happen for example if you are looking to implement complex rules where you need to retrieve the number eligible calendar days within a calendar year in order to prorate the accrual.

This value can either be 365 days or 366 days, depending on the year taken into account.

The business rule will need to calculate this value without any reference to specific years so that it can be used as a general rule and does not need to be amended anymore in its definition.

The key factors to be considered will be:

– Account Valid From Date;
– Account Valid Until Date;
– Hire Date;
– Termination Date.

Employees are entitled to accrue a certain fraction of day every day, based on how many days they were eligible during the year.
Therefore the divisor in my proration will be 365 or 366.

The easiest way to retrieve the divisor in the equation is to use the Accrual Start Date and Accrual End Date, but this won’t work across all the scenarios.
Moreover, it would be interesting to create a logic behind which can be re-usable for other different situations, even beyond the Time Off module.

In this blog, I will explain an easy workaround which dynamically creates the dates we are interested in without leveraging on the Accrual start and end dates.

Scenario 1

The Holiday Calendar Year goes from the 1st of January to the 31st of December.

In this scenario, the Account Valid From date and Account Valid Until date will always fall in the same year.

This means that the variable used in the Business Rule will be in its easiest version:

This function will calculate the number of calendar days between the 1st January and 31st December and will adjust the year considered according to the time account taken into account.

Scenario 2

In this second scenario, the situation is slightly different.

When Holiday Calendar Years run across two years, we need to take into account different sub scenarios where, for example, the Account Valid From date and Account Valid Until date fall in the same year or in a different one.

In this example, we will use a Holiday Calendar Year which goes from the 1st of June to the 31st of May,  but the logic behind is applicable to any other scenario where the expected normal Account Valid From date and Account Valid Until date fall in different years.

Scenario 2.1 – Hire date and Account Valid Until are in different years.

This scenario is applicable if the employee was already part of the organization as of the 1st June or if the Hire date falls in the previous year compared to the Account Valid Until date (any date between 1st June 2020 and 31st December 2020 in the example below).

The variable to be used in the Business Rule is the following:

This function will calculate the number of calendar days between the 1st June and 31st May and will adjust the year considered according to the time account taken into account.

Scenario 2.2 – Hire date and Account Valid Until date are in the same year – Right segment

This scenario is applicable if the employee has been hired in the same year as the Account Valid Until date (any date between 1st January 2021 and 31st May 2021 in the example below).

The variable to be used in the Business Rule is the following:

As before, this function will calculate the number of calendar days between the 1st June and 31st May and will adjust the year considered according to the time account taken into account.

Scenario 2.3 – Hire date and Account Valid Until are in the same year – Left segment

This scenario is applicable if the employee has been terminated and the Termination Date is in the same year as the Account Valid From date (left segment in figure below).

This scenario is actually relatable to scenario 2.1 described earlier.
The reason is very simple: despite the Termination Date, the system will still rely on the Account Valid Until date set on 31st May 2021.
Therefore you can use the variable described in scenario 2.1 both in case the employee was already part of the organization as of the 1st June 2020 or if the Hire date is any date between 1st June 2020 and 31st December 2020.

Conclusion

Once you have identified your specific case, in order to differentiate between the variable to be used, you can easily include an IF condition which evaluates the year of the Account Valid From date and the year of the Account Valid Until date:

The last step is to include the variable within your calculation.
This can vary a lot according to the specific case and how you are going to use the number of days previously retrieved.

Also, please note that the cases seen above are specific to Time Off configurations, but obviously, the logic behind can easily be adapted according to the specific situation you need to handle.

Thanks for taking the time to read this post, I hope you found it useful.

### Assigned Tags

1 Comment
You must be Logged on to comment or reply to a post.

Nice Blog. thanks for sharing.