In our journey working on Time-Off, we've realized that it's like a puzzle - often there are specific requirements that need to fit just right, with certain dependencies in play.
Today, we're going to delve into one such special case: Parental Leave, which like a newborn baby, comes to life only after a child is born.
The Building Blocks
In our Parental Leave scenario, there are two key factors we need to keep in mind:
Just like those precious first six months of a baby's life, parental leave is eligible only until your little one is half a year old.
You can take up to five days of leave per child - a perfect little break to bond with your baby!
To make sure we adhere to these conditions, we're going to put on our rule-making hats and craft some rules.
Creating the Rules
Rule 1: Checking Up on the Baby
Our first rule works like a friendly neighborhood doctor. It uses the function Get Count of Dependents() to check if the baby's data has been updated in the dependents' portlet. Here, Relationship Type '2' is the secret code for 'Child'. If the baby's data isn't maintained, the system will kindly remind you with an error.
Rule 2: Counting the Months
Our second rule is like a digital calendar. Using Get Number of Months From Start Date Until End Date(), it keeps track of how old your baby is. It's looking for the most recent data of a specific relationship type. If the baby data shows an age of more than six months, the system will gently remind you with an error.
Rule 3: Counting the Days
Our third rule works like a dedicated secretary, keeping track of your leaves.
It uses Get Absence in Days for Period Based on Calendar Days For Time Type() fetches leaves already availed from the start date (baby's birth date) to the end date (the present date when leave is being availed again).
This output is combined with the output of Get Number of Calendar Days(), which counts the number of days between the start and end dates, i.e., leave days being availed now. If the total is more than five days, the system will gently remind you with an error.
Remember, the system can only handle one time type at a time. If you have multiple time types with the same requirement, no worries, just create more rules!
Putting the Rules to Work
Now that we have our rules, it's time to put them in their rightful place - under the Take Rule of the time type (in our case, Parental Leave).
Things to Keep in Mind
This solution is like a baby - it can only come to life if the Dependents portlet is in use.
The rule will only pay attention to the youngest child's data, so any overlapping will not be captured.
We hope this playful guide helps you in implementing the Dependent Specific Time-Off rule. Remember, rules are here to help us, and with the right ones in place, you'll be all set to enjoy some quality time with your little one!