I have to calculate the basic pay with if condition.if the employee does not have unpaid leave means Unpaid is not there under Worked days and input under payslip then unpaid leave should be o(Zero). I have tried the below code but its given error.
day=contract.wage/30
if not worked_days.Unpaid.number_of_days in payslip:
result=day*(30-0)
else:
result=day*(30-worked_days.Unpaid.number_of_days)
The in command in python is used to check for membership.
E.g. : 3 in [1, 2, 3]
results in True.
I am not exactly sure what is the purpose of payslip in your code but from what I understand you may try this:
day=contract.wage/30
if Not(worked_days.Unpaid.number_of_days):
result=day*(30-0)
else:
result=day*(30-worked_days.Unpaid.number_of_days)
Edit after comments :
day=contract.wage/30
if worked_days.Unpaid and worked_days.Unpaid.number_of_days or False:
result=day*(30-0)
else:
result=day*(30-worked_days.Unpaid.number_of_days)