make unit test hr base
This commit is contained in:
parent
255bf2ea5b
commit
87bab36cb2
|
|
@ -227,7 +227,7 @@ class employee_overtime_request(models.Model):
|
|||
'debit': record.price_hour,
|
||||
'account_id': account_debit_id.id,
|
||||
'partner_id': record.employee_id.user_id.partner_id.id,
|
||||
# 'analytic_account_id': analytic_account_id.id,
|
||||
'analytic_account_id': analytic_account_id.id,
|
||||
}
|
||||
credit_line_vals = {
|
||||
'name': record.employee_id.name,
|
||||
|
|
@ -242,6 +242,8 @@ class employee_overtime_request(models.Model):
|
|||
'date': item.request_date,
|
||||
'ref': record.employee_id.name,
|
||||
'line_ids': [(0, 0, debit_line_vals), (0, 0, credit_line_vals)],
|
||||
'res_model': 'employee.overtime.request',
|
||||
'res_id': self.id
|
||||
|
||||
})
|
||||
record.account_id = account_debit_id.id
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# from . import test_overtime_process
|
||||
# from . import test_employee_department_jobs
|
||||
# from . import test_hr_clearance_form
|
||||
from . import test_overtime_process
|
||||
from . import test_employee_department_jobs
|
||||
from . import test_hr_clearance_form
|
||||
from . import test_hr_personal_permission
|
||||
|
|
@ -80,346 +80,246 @@ class HrSalaryRules(models.Model):
|
|||
raise UserError(_("The Salary Rule is Not Deduction"))
|
||||
|
||||
def _compute_rule(self, localdict):
|
||||
|
||||
self.ensure_one()
|
||||
payslip = localdict.get('payslip')
|
||||
contract = localdict.get('contract')
|
||||
current_date = fields.Date.today()
|
||||
|
||||
fix_amount_value = self.amount_fix if hasattr(self, 'amount_fix') else getattr(self, 'fixed_amount', 0.0)
|
||||
|
||||
|
||||
def get_related_amount():
|
||||
salary_type = getattr(self, 'salary_type', 'fixed')
|
||||
if salary_type == 'related_levels' and contract.salary_level:
|
||||
related = self.salary_amount_ids.filtered(lambda r: r.salary_scale_level.id == contract.salary_level.id)
|
||||
return related.salary if related else 0.0
|
||||
elif salary_type == 'related_groups' and contract.salary_group:
|
||||
related = self.salary_amount_ids.filtered(lambda r: r.salary_scale_group.id == contract.salary_group.id)
|
||||
return related.salary if related else 0.0
|
||||
elif salary_type == 'related_degrees' and contract.salary_degree:
|
||||
related = self.salary_amount_ids.filtered(
|
||||
lambda r: r.salary_scale_degree.id == contract.salary_degree.id)
|
||||
return related.salary if related else 0.0
|
||||
return fix_amount_value
|
||||
|
||||
if self.amount_select == 'percentage':
|
||||
total_percent = 0.0
|
||||
related_rules = getattr(self, 'related_benefits_discounts', [])
|
||||
|
||||
if related_rules:
|
||||
for line in related_rules:
|
||||
total_percent, total = 0, 0
|
||||
if self.related_benefits_discounts:
|
||||
for line in self.related_benefits_discounts:
|
||||
calc_line = line._compute_rule(localdict)[0]
|
||||
line_in_advantages = False
|
||||
advantages = contract.advantages if contract else []
|
||||
|
||||
if advantages:
|
||||
con = next((adv for adv in advantages if adv.benefits_discounts.id == line.id), None)
|
||||
if con:
|
||||
line_in_advantages = True
|
||||
is_valid_date = False
|
||||
|
||||
if payslip:
|
||||
if con.date_from > payslip.date_from:
|
||||
total_percent += calc_line
|
||||
continue
|
||||
elif (not con.date_to) or (con.date_to >= payslip.date_to):
|
||||
is_valid_date = True
|
||||
else:
|
||||
if con.date_from <= current_date:
|
||||
if (not con.date_to) or (con.date_to >= current_date):
|
||||
is_valid_date = True
|
||||
|
||||
if is_valid_date:
|
||||
total_to_add = 0.0
|
||||
if con.type == 'exception':
|
||||
if con.amount < calc_line:
|
||||
total_to_add = calc_line - con.amount
|
||||
if line.amount_select == 'fix':
|
||||
if contract.advantages:
|
||||
for con in contract.advantages:
|
||||
if line.id == con.benefits_discounts.id:
|
||||
if payslip:
|
||||
if con.date_from > payslip.date_from:
|
||||
total_percent = calc_line
|
||||
elif con.date_to is not None and str(
|
||||
con.date_to) >= payslip.date_to or con.date_to is None:
|
||||
if con.type == 'exception':
|
||||
if con.amount > calc_line or con.amount == calc_line:
|
||||
pass
|
||||
elif con.amount < calc_line:
|
||||
total = calc_line - con.amount
|
||||
elif con.type == 'customize':
|
||||
total = con.amount
|
||||
total_percent += total
|
||||
else:
|
||||
total_to_add = 0.0
|
||||
elif con.type == 'customize':
|
||||
total_to_add = con.amount
|
||||
|
||||
if line.amount_select == 'percentage':
|
||||
total_percent -= calc_line
|
||||
total_percent += total_to_add
|
||||
if str(con.date_from) < str(datetime.now().date()):
|
||||
if con.date_to:
|
||||
if datetime.strptime(str(con.date_to), "%Y-%m-%d").date().month \
|
||||
>= datetime.now().date().month or not con.date_to:
|
||||
if con.type == 'exception':
|
||||
if con.amount > calc_line or con.amount == calc_line:
|
||||
pass
|
||||
elif con.amount < calc_line:
|
||||
total = calc_line - con.amount
|
||||
elif con.type == 'customize':
|
||||
total = con.amount
|
||||
total_percent += total
|
||||
else:
|
||||
total_percent += total_to_add
|
||||
else:
|
||||
total_percent += calc_line
|
||||
total_percent = calc_line
|
||||
else:
|
||||
total_percent += calc_line
|
||||
|
||||
if not line_in_advantages:
|
||||
total_percent += calc_line
|
||||
elif line.amount_select == 'percentage':
|
||||
if contract.advantages:
|
||||
for con in contract.advantages:
|
||||
if line.id == con.benefits_discounts.id:
|
||||
if payslip:
|
||||
if con.date_from > payslip.date_from:
|
||||
total_percent = calc_line
|
||||
elif con.date_to is not None and str(
|
||||
con.date_to) >= payslip.date_to or con.date_to is None:
|
||||
if con.type == 'exception':
|
||||
if con.amount > calc_line or con.amount == calc_line:
|
||||
pass
|
||||
elif con.amount < calc_line:
|
||||
total = calc_line - con.amount
|
||||
elif con.type == 'customize':
|
||||
total = con.amount
|
||||
total_percent -= calc_line
|
||||
total_percent += total
|
||||
else:
|
||||
if str(con.date_from) < str(datetime.now().date()):
|
||||
if con.date_to:
|
||||
if datetime.strptime(str(con.date_to), "%Y-%m-%d").date().month \
|
||||
>= datetime.now().date().month or not con.date_to:
|
||||
if con.type == 'exception':
|
||||
if con.amount > calc_line or con.amount == calc_line:
|
||||
pass
|
||||
elif con.amount < calc_line:
|
||||
total = calc_line - con.amount
|
||||
elif con.type == 'customize':
|
||||
total = con.amount
|
||||
total_percent -= calc_line
|
||||
total_percent += total
|
||||
else:
|
||||
if con.type != 'exception':
|
||||
total_percent += calc_line
|
||||
break
|
||||
else:
|
||||
total_percent += calc_line
|
||||
|
||||
else:
|
||||
if contract.advantages:
|
||||
for con in contract.advantages:
|
||||
if line.id == con.benefits_discounts.id:
|
||||
if payslip:
|
||||
if con.date_from > payslip.date_from:
|
||||
total_percent = calc_line
|
||||
elif con.date_to is not None and con.date_to >= payslip.date_to or con.date_to is None:
|
||||
if con.type == 'exception':
|
||||
if con.amount > calc_line or con.amount == calc_line:
|
||||
pass
|
||||
elif con.amount < calc_line:
|
||||
total = calc_line - con.amount
|
||||
elif con.type == 'customize':
|
||||
total = con.amount
|
||||
total_percent = 0
|
||||
total_percent += total
|
||||
else:
|
||||
if con.date_from < (datetime.now().date()):
|
||||
if con.date_to:
|
||||
if datetime.strptime(str(con.date_to), "%Y-%m-%d").date().month \
|
||||
>= datetime.now().date().month or not con.date_to:
|
||||
if con.type == 'exception':
|
||||
if con.amount > calc_line or con.amount == calc_line:
|
||||
pass
|
||||
elif con.amount < calc_line:
|
||||
total = calc_line - con.amount
|
||||
elif con.type == 'customize':
|
||||
total = con.amount
|
||||
total_percent = 0
|
||||
total_percent += total
|
||||
else:
|
||||
if datetime.strptime(str(con.date_from),
|
||||
"%Y-%m-%d").date().month >= datetime.now().date().month:
|
||||
if con.type == 'exception':
|
||||
if con.amount > calc_line or con.amount == calc_line:
|
||||
pass
|
||||
elif con.amount < calc_line:
|
||||
total = calc_line - con.amount
|
||||
elif con.type == 'customize':
|
||||
total = con.amount + calc_line
|
||||
total_percent = 0
|
||||
total_percent += total
|
||||
|
||||
else:
|
||||
if not total_percent:
|
||||
total_percent = calc_line
|
||||
else:
|
||||
total_percent += calc_line
|
||||
if total_percent:
|
||||
try:
|
||||
qty = float(safe_eval(self.quantity, localdict))
|
||||
rate = self.amount_percentage
|
||||
return float(total_percent * self.amount_percentage / 100), qty, rate
|
||||
except Exception as e:
|
||||
raise UserError(_('Error calculating percentage rule %s: %s') % (self.name, e))
|
||||
if self.salary_type == 'fixed':
|
||||
try:
|
||||
return float(total_percent * self.amount_percentage / 100), \
|
||||
float(safe_eval(self.quantity, localdict)), self.amount_percentage
|
||||
except:
|
||||
raise UserError(
|
||||
_('Wrong percentage base or quantity defined for salary rule %s (%s).') % (
|
||||
self.name, self.code))
|
||||
elif self.salary_type == 'related_levels':
|
||||
levels_ids = self.salary_amount_ids.filtered(
|
||||
lambda item: item.salary_scale_level.id == contract.salary_level.id)
|
||||
if levels_ids:
|
||||
for l in levels_ids:
|
||||
try:
|
||||
return float(l.salary * total_percent / 100), float(
|
||||
safe_eval(self.quantity, localdict)), 100.0
|
||||
except:
|
||||
raise UserError(
|
||||
_('Wrong quantity defined for salary rule %s (%s).') % (
|
||||
self.name, self.code))
|
||||
else:
|
||||
return 0, 0, 0
|
||||
elif self.salary_type == 'related_groups':
|
||||
groups_ids = self.salary_amount_ids.filtered(
|
||||
lambda item: item.salary_scale_group.id == contract.salary_group.id)
|
||||
if groups_ids:
|
||||
for g in groups_ids:
|
||||
try:
|
||||
return float(g.salary * total_percent / 100), float(
|
||||
safe_eval(self.quantity, localdict)), 100.0
|
||||
except:
|
||||
raise UserError(
|
||||
_('Wrong quantity defined for salary rule %s (%s).') % (
|
||||
self.name, self.code))
|
||||
else:
|
||||
return 0, 0, 0
|
||||
elif self.salary_type == 'related_degrees':
|
||||
degrees_ids = self.salary_amount_ids.filtered(
|
||||
lambda item: item.salary_scale_degree.id == contract.salary_degree.id)
|
||||
if degrees_ids:
|
||||
for d in degrees_ids:
|
||||
try:
|
||||
return float(d.salary * total_percent / 100), float(
|
||||
safe_eval(self.quantity, localdict)), 100.0
|
||||
except:
|
||||
raise UserError(
|
||||
_('Wrong quantity defined for salary rule %s (%s).') % (
|
||||
self.name, self.code))
|
||||
else:
|
||||
return 0, 0, 0
|
||||
else:
|
||||
return 0.0, 0.0, 0.0
|
||||
try:
|
||||
return 0, 0, 0
|
||||
except:
|
||||
raise UserError(_('There is no total for rule : %s') % self.name)
|
||||
|
||||
elif self.amount_select == 'fix':
|
||||
try:
|
||||
qty = float(safe_eval(self.quantity, localdict))
|
||||
amount = get_related_amount()
|
||||
return amount, qty, 100.0
|
||||
except Exception as e:
|
||||
raise UserError(_('Error computing fix rule %s: %s') % (self.name, e))
|
||||
if self.salary_type == 'fixed':
|
||||
try:
|
||||
return self.fixed_amount, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
except:
|
||||
raise UserError(_('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
elif self.salary_type == 'related_levels':
|
||||
levels_ids = self.salary_amount_ids.filtered(
|
||||
lambda item: item.salary_scale_level.id == contract.salary_level.id)
|
||||
if levels_ids:
|
||||
for l in levels_ids:
|
||||
try:
|
||||
return l.salary, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
except:
|
||||
raise UserError(
|
||||
_('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
else:
|
||||
return 0, 0, 0
|
||||
elif self.salary_type == 'related_groups':
|
||||
groups_ids = self.salary_amount_ids.filtered(
|
||||
lambda item: item.salary_scale_group.id == contract.salary_group.id)
|
||||
if groups_ids:
|
||||
for g in groups_ids:
|
||||
try:
|
||||
return g.salary, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
except:
|
||||
raise UserError(
|
||||
_('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
else:
|
||||
return 0, 0, 0
|
||||
elif self.salary_type == 'related_degrees':
|
||||
degrees_ids = self.salary_amount_ids.filtered(
|
||||
lambda item: item.salary_scale_degree.id == contract.salary_degree.id)
|
||||
if degrees_ids:
|
||||
for d in degrees_ids:
|
||||
try:
|
||||
return d.salary, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
except:
|
||||
raise UserError(
|
||||
_('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
else:
|
||||
return 0, 0, 0
|
||||
else:
|
||||
raise UserError(_('Error, Select Salary type to calculate rule'))
|
||||
|
||||
else:
|
||||
try:
|
||||
safe_eval(self.amount_python_compute, localdict, mode='exec', nocopy=True)
|
||||
return float(localdict.get('result', 0.0)), \
|
||||
localdict.get('result_qty', 1.0), \
|
||||
localdict.get('result_rate', 100.0)
|
||||
except Exception as e:
|
||||
raise UserError(_('Error computing python rule %s: %s') % (self.name, e))
|
||||
# Override function compute rule in hr salary rule
|
||||
|
||||
# def _compute_rule(self, localdict):
|
||||
# payslip = localdict.get('payslip')
|
||||
# contract = localdict.get('contract')
|
||||
# if self.amount_select == 'percentage':
|
||||
# total_percent, total = 0, 0
|
||||
# if self.related_benefits_discounts:
|
||||
# for line in self.related_benefits_discounts:
|
||||
# calc_line = line._compute_rule(localdict)[0]
|
||||
#
|
||||
# if line.amount_select == 'fix':
|
||||
# if contract.advantages:
|
||||
# for con in contract.advantages:
|
||||
# if line.id == con.benefits_discounts.id:
|
||||
# if payslip:
|
||||
# if con.date_from > payslip.date_from:
|
||||
# total_percent = calc_line
|
||||
# elif con.date_to is not None and str(
|
||||
# con.date_to) >= payslip.date_to or con.date_to is None:
|
||||
# if con.type == 'exception':
|
||||
# if con.amount > calc_line or con.amount == calc_line:
|
||||
# pass
|
||||
# elif con.amount < calc_line:
|
||||
# total = calc_line - con.amount
|
||||
# elif con.type == 'customize':
|
||||
# total = con.amount
|
||||
# total_percent += total
|
||||
# else:
|
||||
# if str(con.date_from) < str(datetime.now().date()):
|
||||
# if con.date_to:
|
||||
# if datetime.strptime(str(con.date_to), "%Y-%m-%d").date().month \
|
||||
# >= datetime.now().date().month or not con.date_to:
|
||||
# if con.type == 'exception':
|
||||
# if con.amount > calc_line or con.amount == calc_line:
|
||||
# pass
|
||||
# elif con.amount < calc_line:
|
||||
# total = calc_line - con.amount
|
||||
# elif con.type == 'customize':
|
||||
# total = con.amount
|
||||
# total_percent += total
|
||||
# else:
|
||||
# total_percent = calc_line
|
||||
# else:
|
||||
# total_percent += calc_line
|
||||
#
|
||||
# elif line.amount_select == 'percentage':
|
||||
# if contract.advantages:
|
||||
# for con in contract.advantages:
|
||||
# if line.id == con.benefits_discounts.id:
|
||||
# if payslip:
|
||||
# if con.date_from > payslip.date_from:
|
||||
# total_percent = calc_line
|
||||
# elif con.date_to is not None and str(
|
||||
# con.date_to) >= payslip.date_to or con.date_to is None:
|
||||
# if con.type == 'exception':
|
||||
# if con.amount > calc_line or con.amount == calc_line:
|
||||
# pass
|
||||
# elif con.amount < calc_line:
|
||||
# total = calc_line - con.amount
|
||||
# elif con.type == 'customize':
|
||||
# total = con.amount
|
||||
# total_percent -= calc_line
|
||||
# total_percent += total
|
||||
# else:
|
||||
# if str(con.date_from) < str(datetime.now().date()):
|
||||
# if con.date_to:
|
||||
# if datetime.strptime(str(con.date_to), "%Y-%m-%d").date().month \
|
||||
# >= datetime.now().date().month or not con.date_to:
|
||||
# if con.type == 'exception':
|
||||
# if con.amount > calc_line or con.amount == calc_line:
|
||||
# pass
|
||||
# elif con.amount < calc_line:
|
||||
# total = calc_line - con.amount
|
||||
# elif con.type == 'customize':
|
||||
# total = con.amount
|
||||
# total_percent -= calc_line
|
||||
# total_percent += total
|
||||
# else:
|
||||
# if con.type != 'exception':
|
||||
# total_percent += calc_line
|
||||
# break
|
||||
# else:
|
||||
# total_percent += calc_line
|
||||
#
|
||||
# else:
|
||||
# if contract.advantages:
|
||||
# for con in contract.advantages:
|
||||
# if line.id == con.benefits_discounts.id:
|
||||
# if payslip:
|
||||
# if con.date_from > payslip.date_from:
|
||||
# total_percent = calc_line
|
||||
# elif con.date_to is not None and con.date_to >= payslip.date_to or con.date_to is None:
|
||||
# if con.type == 'exception':
|
||||
# if con.amount > calc_line or con.amount == calc_line:
|
||||
# pass
|
||||
# elif con.amount < calc_line:
|
||||
# total = calc_line - con.amount
|
||||
# elif con.type == 'customize':
|
||||
# total = con.amount
|
||||
# total_percent = 0
|
||||
# total_percent += total
|
||||
# else:
|
||||
# if con.date_from < (datetime.now().date()):
|
||||
# if con.date_to:
|
||||
# if datetime.strptime(str(con.date_to), "%Y-%m-%d").date().month \
|
||||
# >= datetime.now().date().month or not con.date_to:
|
||||
# if con.type == 'exception':
|
||||
# if con.amount > calc_line or con.amount == calc_line:
|
||||
# pass
|
||||
# elif con.amount < calc_line:
|
||||
# total = calc_line - con.amount
|
||||
# elif con.type == 'customize':
|
||||
# total = con.amount
|
||||
# total_percent = 0
|
||||
# total_percent += total
|
||||
# else:
|
||||
# if datetime.strptime(str(con.date_from),
|
||||
# "%Y-%m-%d").date().month >= datetime.now().date().month:
|
||||
# if con.type == 'exception':
|
||||
# if con.amount > calc_line or con.amount == calc_line:
|
||||
# pass
|
||||
# elif con.amount < calc_line:
|
||||
# total = calc_line - con.amount
|
||||
# elif con.type == 'customize':
|
||||
# total = con.amount + calc_line
|
||||
# total_percent = 0
|
||||
# total_percent += total
|
||||
#
|
||||
# else:
|
||||
# if not total_percent:
|
||||
# total_percent = calc_line
|
||||
# else:
|
||||
# total_percent += calc_line
|
||||
# if total_percent:
|
||||
# if self.salary_type == 'fixed':
|
||||
# try:
|
||||
# return float(total_percent * self.amount_percentage / 100), \
|
||||
# float(safe_eval(self.quantity, localdict)), self.amount_percentage
|
||||
# except:
|
||||
# raise UserError(
|
||||
# _('Wrong percentage base or quantity defined for salary rule %s (%s).') % (
|
||||
# self.name, self.code))
|
||||
# elif self.salary_type == 'related_levels':
|
||||
# levels_ids = self.salary_amount_ids.filtered(
|
||||
# lambda item: item.salary_scale_level.id == contract.salary_level.id)
|
||||
# if levels_ids:
|
||||
# for l in levels_ids:
|
||||
# try:
|
||||
# return float(l.salary * total_percent / 100), float(
|
||||
# safe_eval(self.quantity, localdict)), 100.0
|
||||
# except:
|
||||
# raise UserError(
|
||||
# _('Wrong quantity defined for salary rule %s (%s).') % (
|
||||
# self.name, self.code))
|
||||
# else:
|
||||
# return 0, 0, 0
|
||||
# elif self.salary_type == 'related_groups':
|
||||
# groups_ids = self.salary_amount_ids.filtered(
|
||||
# lambda item: item.salary_scale_group.id == contract.salary_group.id)
|
||||
# if groups_ids:
|
||||
# for g in groups_ids:
|
||||
# try:
|
||||
# return float(g.salary * total_percent / 100), float(
|
||||
# safe_eval(self.quantity, localdict)), 100.0
|
||||
# except:
|
||||
# raise UserError(
|
||||
# _('Wrong quantity defined for salary rule %s (%s).') % (
|
||||
# self.name, self.code))
|
||||
# else:
|
||||
# return 0, 0, 0
|
||||
# elif self.salary_type == 'related_degrees':
|
||||
# degrees_ids = self.salary_amount_ids.filtered(
|
||||
# lambda item: item.salary_scale_degree.id == contract.salary_degree.id)
|
||||
# if degrees_ids:
|
||||
# for d in degrees_ids:
|
||||
# try:
|
||||
# return float(d.salary * total_percent / 100), float(
|
||||
# safe_eval(self.quantity, localdict)), 100.0
|
||||
# except:
|
||||
# raise UserError(
|
||||
# _('Wrong quantity defined for salary rule %s (%s).') % (
|
||||
# self.name, self.code))
|
||||
# else:
|
||||
# return 0, 0, 0
|
||||
# else:
|
||||
# try:
|
||||
# return 0, 0, 0
|
||||
# except:
|
||||
# raise UserError(_('There is no total for rule : %s') % self.name)
|
||||
#
|
||||
# elif self.amount_select == 'fix':
|
||||
# if self.salary_type == 'fixed':
|
||||
# try:
|
||||
# return self.fixed_amount, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
# except:
|
||||
# raise UserError(_('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
# elif self.salary_type == 'related_levels':
|
||||
# levels_ids = self.salary_amount_ids.filtered(
|
||||
# lambda item: item.salary_scale_level.id == contract.salary_level.id)
|
||||
# if levels_ids:
|
||||
# for l in levels_ids:
|
||||
# try:
|
||||
# return l.salary, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
# except:
|
||||
# raise UserError(
|
||||
# _('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
# else:
|
||||
# return 0, 0, 0
|
||||
# elif self.salary_type == 'related_groups':
|
||||
# groups_ids = self.salary_amount_ids.filtered(
|
||||
# lambda item: item.salary_scale_group.id == contract.salary_group.id)
|
||||
# if groups_ids:
|
||||
# for g in groups_ids:
|
||||
# try:
|
||||
# return g.salary, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
# except:
|
||||
# raise UserError(
|
||||
# _('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
# else:
|
||||
# return 0, 0, 0
|
||||
# elif self.salary_type == 'related_degrees':
|
||||
# degrees_ids = self.salary_amount_ids.filtered(
|
||||
# lambda item: item.salary_scale_degree.id == contract.salary_degree.id)
|
||||
# if degrees_ids:
|
||||
# for d in degrees_ids:
|
||||
# try:
|
||||
# return d.salary, float(safe_eval(self.quantity, localdict)), 100.0
|
||||
# except:
|
||||
# raise UserError(
|
||||
# _('Wrong quantity defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
# else:
|
||||
# return 0, 0, 0
|
||||
# else:
|
||||
# raise UserError(_('Error, Select Salary type to calculate rule'))
|
||||
#
|
||||
# else:
|
||||
# try:
|
||||
# safe_eval(self.amount_python_compute, localdict, mode='exec', nocopy=True)
|
||||
# return float(localdict['result']), 'result_qty' in localdict and localdict[
|
||||
# 'result_qty'] or 1.0, 'result_rate' in localdict and localdict['result_rate'] or 100.0
|
||||
# except:
|
||||
# raise UserError(_('Wrong python code defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
return float(localdict['result']), 'result_qty' in localdict and localdict[
|
||||
'result_qty'] or 1.0, 'result_rate' in localdict and localdict['result_rate'] or 100.0
|
||||
except:
|
||||
raise UserError(_('Wrong python code defined for salary rule %s (%s).') % (self.name, self.code))
|
||||
|
||||
|
||||
class SalaryConfig(models.Model):
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class TestSalaryRuleComputation(TransactionCase):
|
|||
'name': 'Basic Salary', 'code': 'BASIC',
|
||||
'category_id': self.category_basic.id,
|
||||
'amount_select': 'fix',
|
||||
'amount_fix': 1000.0,
|
||||
'fixed_amount': 1000,
|
||||
'sequence': 1,
|
||||
'salary_type': 'fixed',
|
||||
})
|
||||
|
|
@ -37,7 +37,7 @@ class TestSalaryRuleComputation(TransactionCase):
|
|||
'name': 'Housing Allowance', 'code': 'HOUSING',
|
||||
'category_id': self.category_allowance.id,
|
||||
'amount_select': 'fix',
|
||||
'amount_fix': 500.0,
|
||||
'fixed_amount': 500,
|
||||
'sequence': 2,
|
||||
'salary_type': 'fixed',
|
||||
})
|
||||
|
|
@ -85,7 +85,7 @@ class TestSalaryRuleComputation(TransactionCase):
|
|||
'benefits_discounts': self.rule_basic.id,
|
||||
'type': 'exception',
|
||||
|
||||
'amount': 200.0,
|
||||
'amount': 200,
|
||||
'date_from': yesterday,
|
||||
'date_to': today + timedelta(days=30),
|
||||
})
|
||||
|
|
@ -114,7 +114,7 @@ class TestSalaryRuleComputation(TransactionCase):
|
|||
'employee_id': self.employee.id,
|
||||
'benefits_discounts': self.rule_basic.id,
|
||||
'type': 'exception',
|
||||
'amount': 200.0,
|
||||
'amount': 200,
|
||||
'date_from': old_date,
|
||||
'date_to': old_date + timedelta(days=30),
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue