Calculating 13 or 14 months salary in TCS
This is a sample formula for calculating 13 or 14 months salary for the Total Compensation Statement.
This is just a sample code, this may not work as it is for your needs, and you may need to change the logic as per your requirements.
Please see the YouTube Tutorial for an explanation of this code.
Assume your salary is monthly, the salary has not changed during the statement period.
The 13th salary is added to the salary of December.
/**************************************************
FF Name: TILAK_ARRAY_13MONTH_SAL_1
Type : Total Compensation Item
Developer: Tilak
Purpose: Calculate 13-month salary and adding that in DEC month
**************************************************/
/* Declare DBI */
DEFAULT FOR CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT is 0
DEFAULT FOR CMP_ASSIGNMENT_SALARY_ANNUALIZATION_FACTOR is 0
DEFAULT FOR PER_ASG_LEGAL_ENTITY_ID is -1
DEFAULT FOR CMP_ASSIGNMENT_SALARY_DATE_FROM is '1900/01/01' (date)
DEFAULT FOR COMPENSATION_DATES is EMPTY_TEXT_NUMBER
DEFAULT FOR VALUES is EMPTY_TEXT_NUMBER
DEFAULT FOR ASSIGNMENTS is EMPTY_TEXT_NUMBER
DEFAULT FOR LEGALEMPLOYERS is EMPTY_TEXT_NUMBER
/* Declare IV */
INPUTS ARE CMP_IV_PERIOD_START_DATE(DATE),
CMP_IV_PERIOD_END_DATE (DATE)
/***************** Main ************************/
temp = SET_LOG('Entering Fromula TILAK_ARRAY_13MONTH_SAL_1 ' )
myAnnSalary = CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT
myAnnFactor = CMP_ASSIGNMENT_SALARY_ANNUALIZATION_FACTOR
/*
myAnnFactor = 13
IF CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT WAS DEFAULTED THEN
(
temp =SET_LOG('No Salary Found using 13K for testing ' )
myAnnSalary = 13000
)
*/
asgId = get_context(HR_ASSIGNMENT_ID, -1)
leId = PER_ASG_LEGAL_ENTITY_ID
myMonthSalary = myAnnSalary / myAnnFactor
temp =SET_LOG('Annual Salary ' || TO_CHAR(myAnnSalary) )
temp =SET_LOG('Monthly Salary ' || TO_CHAR(myMonthSalary) )
temp =SET_LOG('Assinment ' || TO_CHAR(asgId) )
temp =SET_LOG('LE ' || TO_CHAR(leId) )
/* Asuumed Salary is first of Every Month First the first date within the period */
firstDate = TRUNC(CMP_IV_PERIOD_START_DATE, 'MM')
endDate = CMP_IV_PERIOD_END_DATE
temp =SET_LOG('first Date ' || TO_CHAR(firstDate) )
temp =SET_LOG('Last Date ' || TO_CHAR(endDate) )
index = 1
IF (firstDate < CMP_IV_PERIOD_START_DATE) then
(
firstDate = ADD_MONTHS(firstDate, 1)
)
/* Create Row */
WHILE firstDate <= endDate
LOOP(
temp =SET_LOG('Processing Date ' || TO_CHAR(firstDate) )
COMPENSATION_DATES[index] = to_char(firstDate, 'YYYY/MM/DD')
ASSIGNMENTS[index] = to_char(asgId)
LEGALEMPLOYERS[index] = to_char(leId)
VALUES[index] = to_char(myMonthSalary)
IF ( TO_CHAR(firstDate, 'MM') = '12' ) then
(
VALUES[index] = to_char(myMonthSalary * 2)
)
index = index + 1
firstDate = add_months(firstDate, 1)
)
temp =SET_LOG('Leaving Fromula TILAK_ARRAY_13MONTH_SAL_1 ' )
RETURN COMPENSATION_DATES, VALUES, ASSIGNMENTS, LEGALEMPLOYERS
/**************************************************
FF Name: TILAK_ARRAY_13MONTH_SAL_2
Type : Total Compensation Item
Developer: Tilak
Purpose: Calculate 13-month salary and adding that in DEC month
**************************************************/
/* Declare DBI */
DEFAULT FOR CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT is 0
DEFAULT FOR CMP_ASSIGNMENT_SALARY_ANNUALIZATION_FACTOR is 0
DEFAULT FOR PER_ASG_LEGAL_ENTITY_ID is -1
DEFAULT FOR CMP_ASSIGNMENT_SALARY_DATE_FROM is '1900/01/01' (date)
DEFAULT FOR COMPENSATION_DATES is EMPTY_TEXT_NUMBER
DEFAULT FOR VALUES is EMPTY_TEXT_NUMBER
DEFAULT FOR ASSIGNMENTS is EMPTY_TEXT_NUMBER
DEFAULT FOR LEGALEMPLOYERS is EMPTY_TEXT_NUMBER
/* Declare IV */
INPUTS ARE CMP_IV_PERIOD_START_DATE(DATE),
CMP_IV_PERIOD_END_DATE (DATE)
/***************** Main ************************/
temp = SET_LOG('Entering Fromula TILAK_ARRAY_13MONTH_SAL_1 ' )
myAnnSalary = CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT
myAnnFactor = CMP_ASSIGNMENT_SALARY_ANNUALIZATION_FACTOR
asgId = get_context(HR_ASSIGNMENT_ID, -1)
leId = PER_ASG_LEGAL_ENTITY_ID
temp =SET_LOG('Assinment ' || TO_CHAR(asgId) )
temp =SET_LOG('LE ' || TO_CHAR(leId) )
/* Asuumed Salary is first of Every Month First the first date within the period */
firstDate = TRUNC(CMP_IV_PERIOD_START_DATE, 'MM')
endDate = CMP_IV_PERIOD_END_DATE
temp =SET_LOG('first Date ' || TO_CHAR(firstDate) )
temp =SET_LOG('Last Date ' || TO_CHAR(endDate) )
index = 1
IF (firstDate < CMP_IV_PERIOD_START_DATE) then
(
firstDate = ADD_MONTHS(firstDate, 1)
)
/* Create Row */
WHILE firstDate <= endDate
LOOP(
myMonthSalary = 0
/* Get the salary on the date */
CHANGE_CONTEXTS(EFFECTIVE_DATE=firstDate)
(
myAnnSalary = CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT
myAnnFactor = CMP_ASSIGNMENT_SALARY_ANNUALIZATION_FACTOR
myMonthSalary = myAnnSalary / myAnnFactor
temp =SET_LOG('Annual Salary ' || TO_CHAR(myAnnSalary) )
temp =SET_LOG('Monthly Salary ' || TO_CHAR(myMonthSalary) )
)
if (myMonthSalary != 0 ) THEN
(
temp =SET_LOG('Processing Date ' || TO_CHAR(firstDate) )
temp =SET_LOG('Processing Date ' || TO_CHAR(firstDate) )
COMPENSATION_DATES[index] = to_char(firstDate, 'YYYY/MM/DD')
ASSIGNMENTS[index] = to_char(asgId)
LEGALEMPLOYERS[index] = to_char(leId)
VALUES[index] = to_char(myMonthSalary)
/* add one more row for Dec */
IF ( TO_CHAR(firstDate, 'MM') = '12' ) then
(
index = index + 1
COMPENSATION_DATES[index] = to_char(firstDate, 'YYYY/MM/DD')
ASSIGNMENTS[index] = to_char(asgId)
LEGALEMPLOYERS[index] = to_char(leId)
VALUES[index] = to_char(myMonthSalary)
)
index = index + 1
)
firstDate = add_months(firstDate, 1)
)
temp =SET_LOG('Leaving Fromula TILAK_ARRAY_13MONTH_SAL_1 ' )
RETURN COMPENSATION_DATES, VALUES, ASSIGNMENTS, LEGALEMPLOYERS
This is only a sample formula and is meant to be a guideline. If you are using any of the above code, you need to test it to check if it matches your specific requirements.
Hi Tilak,
ReplyDeleteYour blog really helps all of us a lot. Thank you so much for the efforts. Really appreciate!!
I need your help in one of the customer requirement in HCM Extract Fast Formula rule.
I need to show Line Manager, VP and Director for a particular person in XML as different attributes.
Can you please help me with the logic here. Thanks in Advance!
Can you please let me know what is the problem you are facing?.
DeleteAssume you want Manager in a Formula , Manager-> Manager in a formula , Manager -> manager- > manager in a formula
Manager should not be a problem
Manager -> Manager. Get the manager Asg id (PER_ASG_MGR_MANAGER_ASG_ID). Set the ASG context to this manager asg id and get the manager information
Manager -> Manager -> manager Get the manager Asg id (PER_ASG_MGR_MANAGER_ASG_ID)., again get the manager asg id(Get the manager Asg id (PER_ASG_MGR_MANAGER_ASG_ID).) set the ASG context and get the manager information
please let me how it works for you