Hello Sankaran,
This issue is solved.
The logic you have posted helped me a lot, there were few modifications and additions I have made in the rule as per business requirement and accordingly written the rule by using payroll functions & operations.
Once again thank you very much.