Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
1587 Näkymät

Hello 
I need to be able to manually enter the overtime in other input.

Therefore I created a new other input type called OT Hours (Code: OT_HOURS)

 I created a new Salary Rule named Overtime Pay (Code: OT_Pay).
Category Gross.

Python Condition:
result = inputs.OT_HOURS.amount > 0 if 'OT_HOURS' in inputs else False

And the Code:
overtime_rate = 1.5  

ot_hours = inputs.OT_HOURS.amount if 'OT_HOURS' in inputs else 0

hourly_rate = contract.wage / 160 

result = ot_hours * hourly_rate * overtime_rate

When I try to compute the sheet in a payslip, after manually adding OT in other Input, I will get a Error stating: 
- Salary rule: Overtime Pay (OT_PAY)
 - Error: : "0" while evaluating "result = inputs.OT_HOURS.amount > 0 if 'OT_HOURS' in inputs else False"

Can anybody help me? Do you see an obvious error why it doesn't work?

Avatar
Hylkää
Paras vastaus

Hi,

The error message suggests there's an issue with the condition provided. To resolve this, consider using the following code:

OVERTIME_RATE = 1.5

HOURS_IN_MONTH = 160 # Assuming 160 working hours per month


# Get the OT hours from the input (or default to 0)

ot_hours = inputs.get('OT_HOURS', 0).amount


# Calculate the hourly rate based on the contract wage

hourly_rate = contract.wage / HOURS_IN_MONTH

# Compute the overtime pay

result = ot_hours * hourly_rate * OVERTIME_RATE


Hope it helps

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
maalisk. 24
1523
0
maalisk. 24
1281
2
helmik. 24
1767
0
toukok. 23
1676
2
maalisk. 15
3795