Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

0

You can filter the ot lines by the code of the desired rate. For example, below is the code for the OTREG0006

amount = 0.0
for line in payslip.payslip_ot_line_ids.filtered(lambda l: l.overtime_rule_id.code == 'OTREG0006'):
	amount += 20 * line.number_of_hours * line.rate / 100.0
result = amount


0
Renato Lopez Jr.
On 3/20/19, 12:01 AM

actually, the computation is right, but i want to separate all each overtime rate into different salary rule computation for intensive report purpose.



0

There is a rule named "Overtime Allowance Amount" added by this module, in which the computation is as follow

# find total working hours
total_hours = sum(line.number_of_hours for line in payslip.worked_days_line_ids)

# cost per hour is calculated base on contract's wage and above found total hours
hour_cost = total_hours and contract.wage / total_hours or 0.0

# start calculating overtime cost
amount = 0.0
for line in payslip.payslip_ot_line_ids:
	if payslip.contract_id:
		amount += hour_cost * line.number_of_hours * line.rate / 100
result = amount


As for your case, I will need more information on how you caculate your overtime. I.e.: base amount, rate for each type of overtime against the base.

I assume that
  • base amount: $20/hour
  • rate of the OTREG0006: 150%
  • rate of the OTREG0617: 150%
  • rate of the OTSUN0006: 200%
  • rate of the OTSUN0617: 200%
  • the employee has 10 overtime hours against the OTREG0006 and 5 overtime hours against the OTSUN0006 and 7 overtime hours against the OTSUN0617 and

The python code below could give you the result as 780
amount = 0.0
for line in payslip.payslip_ot_line_ids:
	amount += 20 * line.number_of_hours * line.rate / 100.0
# after the loop, the cummulative amount should be 780.0
result = amount

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Keep Informed

About This Community

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/6/19, 4:22 AM
Seen: 1407 times
Last updated: 3/6/19, 4:22 AM