You can add custom fields in Salary Slip, and use it in the formula of Salary Components and created a Salary Structure with it. I have done it
In the use case you mentioned,
You can calculate the deduction using the Payment Days field in salary slip to get working days for the salary period and find out the total monthly working hour and compare it with Total Working Hours for the employee from Attendance