Configure Business Rules for Salary Processes
Here are examples of a defaulting rule and multiple validating rules.
Validate that the user hasn't changed the rate component value
Advanced Expression
/* eslint-disable dot-notation */
define([], () => {
'use strict';
/**
*
* @param {object} context
* @return {boolean}
*/
function runCondition(context) {
const { $componentContext, $fields, $modules, $user } = context;
let salBasisType = $fields.compensationSalaries.SalaryBasisType.$value();
if(salBasisType == 'R'){
let newSalaryBasisId = $fields.compensationSalaries.SalaryBasisId.$value();
let curSalaryBasisId = $fields.compensationSalaries.SalaryBasisId.$initialValue();
if(newSalaryBasisId != curSalaryBasisId){
return false;
}
let curValue = 0;
let newValue = 0;
let curComponentsArray = $fields.compensationSalaries.salaryPayRateComponents.$initialValue().items;
for(let i in curComponentsArray){
let cmpt=curComponentsArray[i];
if(cmpt.Name == 'ZCMP GSP RATE BASE'){
curValue = Number(cmpt.RateAmount);
}
}
let componentsArray = $fields.compensationSalaries.salaryPayRateComponents.$value().items;
for(let j in componentsArray){
let cmpt=componentsArray[j];
if(cmpt.Name == 'ZCMP GSP RATE BASE'){
newValue = Number(cmpt.RateAmount);
}
}
if(curValue != newValue){
return true;
}
}
return false;
}
return { runCondition };
});
Validate that a value is provided for the rate component
Advanced Expression
/* eslint-disable dot-notation */
define([], () => {
'use strict';
/**
*
* @param {object} context
* @return {boolean}
*/
function runCondition(context) {
const { $objectContext, $fields, $modules, $user, $value } = context;
let salary = $fields['compensationSalaries'].$value();
let payRateComponents = salary['salaryPayRateComponents'];
if (payRateComponents) {
let componentsArray = payRateComponents.items;
if (componentsArray) {
for (let i = 0; i < componentsArray.length; i++) {
let element = componentsArray[i];
if (element.Name === 'ZCMP RTS USVS ARS Base Salary' && element.RateAmount == 0) {
return true;
}
}
}
}
return false;
}
return { runCondition };
});
Validate that the sum of a certain simple component needs to be based on a formula (Adjustment needs to be sum of all components minus cost of living)
Advanced Expression
/* eslint-disable dot-notation */
define([], () => {
'use strict';
/**
*
* @param {object} context
* @return {boolean}
*/
function runCondition(context) {
const { $componentContext, $fields, $modules, $user } = context;
let salBasisType = $fields.compensationSalaries.SalaryBasisType.$value();
let sum = 0;
let result = 0;
let difference = 0;
if(salBasisType == 'C'){
let componentsArray = $fields.compensationSalaries.salaryComponents.$value().items;
for(let i in componentsArray){
let cmpt=componentsArray[i];
if(cmpt.ComponentReasonCode == 'ADJUSTMENT'){
result = Number(cmpt.AdjustmentAmount);
}
else if(cmpt.ComponentReasonCode == 'COST_OF_LIVING'){
difference += Number(cmpt.AdjustmentAmount);
}
else{
sum += Number(cmpt.AdjustmentAmount);
}
}
if(result != sum - difference){
return true;
}
}
return false;
}
return { runCondition };
});
Default the effective date to current date and next salary review date to 1 year after the effective date, when line managers propose salary change
Advanced Expression
/* eslint-disable dot-notation */
define([], () => {
'use strict';
/**
* Default value expression for whenAndWhy.StartDate
* @param {object} context
* @return {date}
*/
function getWhenAndWhyStartDate(context) {
const { $objectContext, $fields, $modules, $user } = context;
let date = new Date();
let firstDay = new Date(date.getFullYear(), date.getMonth()+1, 1);
let year = firstDay.toLocaleString("default", { year: "numeric" });
let month = firstDay.toLocaleString("default", { month: "2-digit" });
let day = firstDay.toLocaleString("default", { day: "2-digit" });
return (year + "-" + month + "-" + day);
}
return { getWhenAndWhyStartDate };
});
Validate that the user hasn't changed the simple component value
Advanced Expression
/* eslint-disable dot-notation */
define([], () => {
'use strict';
/**
*
* @param {object} context
* @return {boolean}
*/
function runCondition(context) {
const { $componentContext, $fields, $modules, $user } = context;
let salBasisType = $fields.compensationSalaries.SalaryBasisType.$value();
if(salBasisType == 'ORA_SIMPLE_COMPONENTS'){
let newSalaryBasisId = $fields.compensationSalaries.SalaryBasisId.$value();
let curSalaryBasisId = $fields.compensationSalaries.SalaryBasisId.$initialValue();
if(newSalaryBasisId != curSalaryBasisId){
return false;
}
let curValue = 0;
let newValue = 0;
let curComponentsArray = $fields.compensationSalaries.salarySimpleComponents.$initialValue().items;
for(let i in curComponentsArray){
let cmpt=curComponentsArray[i];
if(cmpt.ComponentCode == 'ORA_WAGE_PROGRESSION_RATE'){
curValue = Number(cmpt.Amount);
}
}
let componentsArray = $fields.compensationSalaries.salarySimpleComponents.$value().items;
for(let j in componentsArray){
let cmpt=componentsArray[j];
if(cmpt.ComponentCode == 'ORA_WAGE_PROGRESSION_RATE'){
newValue = Number(cmpt.Amount);
}
}
if(curValue != newValue){
return true;
}
}
return false;
}
return { runCondition };
});
Validate that user hasn't entered a 0 value for a simple component
Advanced Expression
/* eslint-disable dot-notation */
define([], () => {
'use strict';
/**
*
* @param {object} context
* @return {boolean}
*/
function runCondition(context) {
const { $componentContext, $fields, $modules, $user } = context;
let salBasisType = $fields.compensationSalaries.SalaryBasisType.$value();
if(salBasisType == 'ORA_SIMPLE_COMPONENTS'){
let componentsArray = $fields.compensationSalaries.salarySimpleComponents.$value().items;
for(let i in componentsArray){
let cmpt=componentsArray[i];
//To Check if specific component has 0 amount value
// if(cmpt.ComponentCode == 'ORA_WAGE_PROGRESSION_RATE' && cmpt.Amount==0){
// return true;
// }
//To Check if any component has 0 amount value
if(cmpt.Amount==0){
return true;
}
}
}
return false;
}
return { runCondition };
});