Error: “Recalculate Salary from the Components before applying the new salary proposal” while updating / Deleting Salary

If you are facing following Error: “Recalculate Salary from the Components before applying the new salary proposal”  while updating or deleting of salary of any employee. The solution could be following.

Ans:

This issue is might be caused by data corruption (caused by loading salaries through api). Records in per_pay_proposals exists that have multiple_components = ‘Y’  although they do not have records in per_pay_proposal_components.

 

Steps:
1. Ensure that you have taken a backup of per_pay_proposals before applying the recommended solution.

2. Run the following scripts.

Update per_pay_proposals set multiple_components=’N’ where pay_proposal_id in (
Select pay_proposal_id from per_pay_proposals ppp where multiple_components = ‘Y’ and not
exists (Select ‘X’ from per_pay_proposal_components comp where comp.pay_proposal_id =ppp.pay_proposal_id));

3. Once the scripts complete, confirm that the data is corrected.
You can use the following SQL to confirm (this is the original script you ran to identify the issue):

Select pay_proposal_id from per_pay_proposals ppp where multiple_components = ‘Y’ and not exists (Select ‘X’ from per_pay_proposal_components comp where comp.pay_proposal_id = ppp.pay_proposal_id) ;

4. If no rows are returned, issue a commit.

5. Confirm that you can now delete a Salary Proposal.