Deduction issue in salary slip

Hello, community,
I have an issue with salary process!
I want to make deduction according to a field in salary slip

This is my Deduction child table content, I have added penalty which is the name of salary slip fields I want to get value and insert in salary slip deduction

In salary slip, it didn’t take my deduction value!

I don’t know if I make something wrong!

Thanks

Hi,

Formula for the calculation of salary doesn’t look okay. on what bases do you calculate penalty?

Your formula doesn’t seem to specify what amount should be deducted and where the deduction should come from. I you can show the full formula one might be able to deduce where the error is.

I get the penalty amount from other doctype calculation and set them in penalty using before_insert function
I have checked the field and it have the amount I need, but after saving the formula should get this field amount as deduction, but it didnt !

The formula depends on the field amount, that I get from other doctype calculation and set them in penalty using before_insert function

I believe salary slip calculation happened before before_insert function. that’s why penalty_amount has value but it’s not used in calculation. Have you tried validate function?

1 Like

I tried it but the same result!

Hello @OmarJaber :wink:
Firstly, if you are trying to make the salary slip from the salary slip form itself you need to make a custom script for the salary slip docctype to get your penalty value from your penalty doctype in the validate event,
Otherwise, if you are trying to make the salary slip from the payroll entry you need to make a custom script for the payroll entry doctype, this script should make a frappe call to a python script that has a function which handle your logic, or you can handle it by using hook in the validate trigger in your custom app which refer to a python function which handle your logic.

Hope that helps, :smiley:

1 Like

Thanks for replying :smiley:
I have tried this, even I tried to assign any value as a test when open the salary slip then save it but it didn’t get any deduction, I checked the penalty field and it already has value
Strange issue!
For now, as we hurry, I solved it by check the deduction table and append the penalty after penalty have a value