fix termination cal
This commit is contained in:
parent
56e4f3f6c7
commit
6ed9938f0f
|
|
@ -8,6 +8,7 @@ import logging
|
|||
from num2words import num2words
|
||||
from hijri_converter import convert
|
||||
import math
|
||||
import calendar
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -424,9 +425,15 @@ class HrTermination(models.Model):
|
|||
# itemss.net -= abs(itemss.total_loans)
|
||||
# for item in self:
|
||||
# Make the maximum paid duration is 30
|
||||
_, number_of_days = calendar.monthrange(self.last_work_date.year, self.last_work_date.month)
|
||||
if self.paid_duration > 0:
|
||||
if self.paid_duration == 31:
|
||||
duration_percentage = 30 / 30
|
||||
elif self.last_work_date.month ==2:
|
||||
if number_of_days == 28:
|
||||
duration_percentage = 28 / self.paid_duration
|
||||
else:
|
||||
duration_percentage = 29 / self.paid_duration
|
||||
else:
|
||||
duration_percentage = 30 / self.paid_duration
|
||||
else:
|
||||
|
|
@ -477,8 +484,10 @@ class HrTermination(models.Model):
|
|||
rule = rule.browse([rule._origin.id])
|
||||
self.compute_salary_rule(rule, items, duration_percentage, False, 0)
|
||||
for item in items:
|
||||
if rule.id == item.get('salary_rule_id'):
|
||||
total += item.get('amount')
|
||||
if rule.id == item.get('salary_rule_id') and rule.category_id.rule_type =='allowance':
|
||||
total += item.get('amount')
|
||||
if rule.id == item.get('salary_rule_id') and rule.category_id.rule_type =='deduction':
|
||||
total -= item.get('amount')
|
||||
self.salary_for_eos += total
|
||||
else:
|
||||
self.salary_for_eos = 0.0
|
||||
|
|
@ -503,20 +512,21 @@ class HrTermination(models.Model):
|
|||
rule_flag = False
|
||||
for rule in self.cause_type.allowance_ids:
|
||||
rule_flag = False
|
||||
# Check if salary rule does not duplicated when come from contract
|
||||
if items:
|
||||
for record in items:
|
||||
# Check if salary rule does not duplicated when come from contract and is allowance only
|
||||
if rule.category_id.rule_type =='allowance':
|
||||
if items:
|
||||
for record in items:
|
||||
|
||||
if record.get('salary_rule_id') == rule.id and record.get('is_advantage') is True and record.get('advantages_out_rule'):
|
||||
total_rules += record.get('amount')
|
||||
rule_flag = True
|
||||
if record.get('salary_rule_id') == rule.id and record.get('is_advantage') is True and not record.get('advantages_out_rule'):
|
||||
# Change salary rule value in "salary for eos" by that in contract that is duplicated
|
||||
total_rules += record.get('amount') * duration_percentage
|
||||
rule_flag = True
|
||||
if record.get('salary_rule_id') == rule.id and record.get('is_advantage') is True and record.get('advantages_out_rule'):
|
||||
total_rules += record.get('amount')
|
||||
rule_flag = True
|
||||
if record.get('salary_rule_id') == rule.id and record.get('is_advantage') is True and not record.get('advantages_out_rule'):
|
||||
# Change salary rule value in "salary for eos" by that in contract that is duplicated
|
||||
total_rules += record.get('amount') * duration_percentage
|
||||
rule_flag = True
|
||||
|
||||
if rule_flag is False:
|
||||
total_rules += self.compute_rule(rule, self.employee_id.sudo().contract_id)
|
||||
if rule_flag is False:
|
||||
total_rules += self.compute_rule(rule, self.employee_id.sudo().contract_id)
|
||||
reward_amount = 0
|
||||
resedual = all_duration
|
||||
line_amount = 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue