Configure Business Rules for Individual Compensation Processes
Here are examples of a defaulting rule and multiple validating rules.
Default When date such that awards can be created after 1st of next quarter by employees only
Advanced Expression
let effectiveDate = new Date();
let currentQuarter = Math.floor((effectiveDate.getMonth() + 3) / 3);
// Get first date of current quarter
effectiveDate.setDate(1);
effectiveDate.setMonth((currentQuarter - 1) * 3);
// Use this technique for year rollover
effectiveDate.setMonth(effectiveDate.getMonth() + 3);
return effectiveDate.toISOString().slice(0, 10);
Validate When date such that it's in the current fiscal year (1 Apr - 31 Mar)
Advanced Expression
let effectiveDate = $fields.individualCompensationDetails.EffectiveDate.$value();
if (effectiveDate) {
// Fetch current financial year start date
let currentDate = new Date();
let fyStartDate = null, fyEndDate = null;
if (currentDate.getMonth() + 1 <= 3) {
fyStartDate = new Date(currentDate.getFullYear() - 1, 3, 1);
fyEndDate = new Date(currentDate.getFullYear(), 2, 31);
} else {
fyStartDate = new Date(currentDate.getFullYear(), 3, 1);;
fyEndDate = new Date(currentDate.getFullYear() + 1, 2, 31);
}
return (new Date(effectiveDate) < fyStartDate || new Date(effectiveDate) > fyEndDate);
}
return false;
Validate new hire bonus doesn't exceed $3000
Advanced Expression
if ($fields.individualCompensationDetails.PlanId.$value() === '100000018708168'
&& Number($fields.individualCompensationDetails.ValueString.$value()) > 3000) {
return true;
}
return false;
Validate car allowance increase is below or equal to 10%
Advanced Expression
if ($fields.individualCompensationDetails.ComponentId.$numberValue() === 300100010424490
&& $fields.individualCompensationDetails.Mode.$initialValue() === 'EDIT') {
let proposedValue = Number($fields.individualCompensationDetails.ValueString.$value());
let currentValue = Number($fields.individualCompensationDetails.ValueString.$initialValue());
if (proposedValue > (1.1 * currentValue))
return true;
}
return false;
In this example, initialValue of Mode is used to handle date-effective update scenario.
For date effective update case, the new record will have Mode as 'CREATE' because it's a newly generated split.
Validate new awards start on or before 17th of a month
Advanced Expression
if ($fields.individualCompensationDetails.Mode.$value() == 'CREATE'
&& $fields.individualCompensationDetails.EffectiveStartDate.$value()) {
let planSD = new Date($fields.individualCompensationDetails.EffectiveStartDate.$value());
return (planSD.getDate() > 17)
}
return false;
Validate that only one award proposal is submitted at a time
Advanced Expression
let currentAllocations = $fields.individualCompensationDetails.CurrentAllocations.$value();
if (currentAllocations && currentAllocations.length) {
let newAllocationCount = 0;
for (let allocation of currentAllocations) {
if (allocation.Mode == 'CREATE')
newAllocationCount++;
}
if(newAllocationCount > 1)
return true;
}
return false;
Validate bus and taxi reimbursement aren't claimed together
Advanced Expression
let currentAllocations = $fields.individualCompensationDetails.CurrentAllocations.$value();
if (currentAllocations && currentAllocations.length) {
let busBonusPresent = false;
let taxiBonusPresent = false;
for (let allocation of currentAllocations) {
if (allocation.PlanId == '300100113565911')
busBonusPresent = true;
else if (allocation.PlanId == '300100113565893')
taxiBonusPresent = true;
}
return (busBonusPresent && taxiBonusPresent);
}
return false;
Validate bonus is allocated only once in six months
if ($fields.individualCompensationDetails.PlanId.$numberValue() === 300100090079227
&& $fields.individualCompensationDetails.Mode.$value() === 'CREATE') {
let startDate = new Date($fields.individualCompensationDetails.EffectiveStartDate.$value());
let minusSixMonth = new Date(startDate.getFullYear(), startDate.getMonth() - 6, startDate.getDay());
minusSixMonth = minusSixMonth.toISOString().slice(0, 10);
let priorAllocations = $fields.individualCompensationDetails.PriorAllocations.$value();
if (priorAllocations?.length) {
let priorSpotBonus = priorAllocations.find(record => record.PlanId == '300100004468561');
if (priorSpotBonus?.EffectiveStartDate > minusSixMonth) {
return true;
}
}
}
return false;