Skip to Content
Menu
This question has been flagged
3 Replies
4841 Views

Actually i need to check whether the employee had taken unpaid leave this month or not in basic calculation. I had used the below function

result = (worked_days.WORK100.number_of_days-worked_days.Unpaid.number_of_days) * (contract.basic / worked_days.WORK100.number_of_days) if (worked_days.Unpaid.number_of_days) != 'False'
else contract.basic

This is not working


Avatar
Discard
Best Answer

I think this code Will help you solve the Problem that you are facing while calculating with Unpaid or with out Unpaid For Payslip.

if not worked_days.Unpaid:
    result=contract.basic
else:
    result=(worked_days.WORK100.number_of_days-worked_days.Unpaid.number_of_days) * (contract.basic / worked_days.WORK100.number_of_days)

Avatar
Discard
Best Answer

Try this one

result = if (worked_days.Unpaid.number_of_days):  ( (worked_days.WORK100.number_of_days-worked_days.Unpaid.number_of_days) * (contract.basic / worked_days.WORK100.number_of_days)) 
else: (contract.basic)

or 


result = if (worked_days.Unpaid.number_of_days) > 0: ((worked_days.WORK100.number_of_days-worked_days.Unpaid.number_of_days) * (contract.basic / worked_days.WORK100.number_of_days)) 
else: (contract.basic)

Avatar
Discard
Author Best Answer

@subbarao Checked using your rule but same error "Wrong python code defined for salary rule Basic Salary (BASIC)."

Avatar
Discard
Related Posts Replies Views Activity
0
Oct 19
2275
0
May 23
2028
2
Feb 21
3217
1
Mar 18
3194
2
Dec 24
724