Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][FW] payroll: ported 111, 117, 119, 151 #159

Open
wants to merge 15 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions payroll/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"views/res_config_settings_views.xml",
"wizard/hr_payroll_send_email.xml",
"wizard/hr_payslip_change_state_view.xml",
"views/hr_leave_type.xml",
],
"demo": ["demo/hr_payroll_demo.xml"],
"application": True,
Expand Down
268 changes: 267 additions & 1 deletion payroll/models/base_browsable.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"""a class that will be used into the python code, mainly for
usability purposes"""

def sum(self, code, from_date, to_date=None):
def sum_rule(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()
self.env.cr.execute(
Expand All @@ -99,3 +99,269 @@
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

def sum(self, code, from_date, to_date=None):
_logger.warning(

Check warning on line 104 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L104

Added line #L104 was not covered by tests
"Payslips Object: sum() method is DEPRECATED. Use sum_rule() instead."
)
return self.sum_rule(code, from_date, to_date)

Check warning on line 107 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L107

Added line #L107 was not covered by tests

def average_rule(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()
self.env.cr.execute(

Check warning on line 112 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L111-L112

Added lines #L111 - L112 were not covered by tests
"""SELECT avg(case when hp.credit_note = False then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND
hp.id = pl.slip_id AND pl.code = %s""",
(self.employee_id, from_date, to_date, code),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 122 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L121-L122

Added lines #L121 - L122 were not covered by tests

def average_rule_monthly(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()
self.env.cr.execute(

Check warning on line 127 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L126-L127

Added lines #L126 - L127 were not covered by tests
"""SELECT avg(total) FROM (SELECT max(case when hp.credit_note = False then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND
hp.id = pl.slip_id AND pl.code = %s) AS monthly_sum""",
(self.employee_id, from_date, to_date, code),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 137 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L136-L137

Added lines #L136 - L137 were not covered by tests

def max_rule(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()
self.env.cr.execute(

Check warning on line 142 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L141-L142

Added lines #L141 - L142 were not covered by tests
"""SELECT max(case when hp.credit_note = False then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND
hp.id = pl.slip_id AND pl.code = %s""",
(self.employee_id, from_date, to_date, code),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 152 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L151-L152

Added lines #L151 - L152 were not covered by tests

def max_rule_monthly(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()
self.env.cr.execute(

Check warning on line 157 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L156-L157

Added lines #L156 - L157 were not covered by tests
"""SELECT max(total) FROM (SELECT max(case when hp.credit_note = False then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND
hp.id = pl.slip_id AND pl.code = %s) AS monthly_sum""",
(self.employee_id, from_date, to_date, code),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 167 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L166-L167

Added lines #L166 - L167 were not covered by tests

def min_rule(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()
self.env.cr.execute(

Check warning on line 172 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L171-L172

Added lines #L171 - L172 were not covered by tests
"""SELECT min(case when hp.credit_note = False then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND
hp.id = pl.slip_id AND pl.code = %s""",
(self.employee_id, from_date, to_date, code),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 182 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L181-L182

Added lines #L181 - L182 were not covered by tests

def min_rule_monthly(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()
self.env.cr.execute(

Check warning on line 187 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L186-L187

Added lines #L186 - L187 were not covered by tests
"""SELECT min(total) FROM (SELECT max(case when hp.credit_note = False then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND
hp.id = pl.slip_id AND pl.code = %s) AS monthly_sum""",
(self.employee_id, from_date, to_date, code),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 197 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L196-L197

Added lines #L196 - L197 were not covered by tests

def sum_category(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()

Check warning on line 201 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L201

Added line #L201 was not covered by tests

hierarchy_codes = (

Check warning on line 203 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L203

Added line #L203 was not covered by tests
self.env["hr.salary.rule.category"]
.search([("code", "=", code)])
.children_ids.mapped("code")
)
hierarchy_codes.append(code)

Check warning on line 208 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L208

Added line #L208 was not covered by tests

self.env.cr.execute(

Check warning on line 210 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L210

Added line #L210 was not covered by tests
"""SELECT sum(case when hp.credit_note is not True then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl, hr_salary_rule_category as rc
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id
AND rc.id = pl.category_id AND rc.code in %s""",
(self.employee_id, from_date, to_date, tuple(hierarchy_codes)),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 220 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L219-L220

Added lines #L219 - L220 were not covered by tests

def average_category(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()

Check warning on line 224 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L224

Added line #L224 was not covered by tests

hierarchy_codes = (

Check warning on line 226 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L226

Added line #L226 was not covered by tests
self.env["hr.salary.rule.category"]
.search([("code", "=", code)])
.children_ids.mapped("code")
)
hierarchy_codes.append(code)

Check warning on line 231 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L231

Added line #L231 was not covered by tests

self.env.cr.execute(

Check warning on line 233 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L233

Added line #L233 was not covered by tests
"""SELECT avg(case when hp.credit_note is not True then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl, hr_salary_rule_category as rc
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id
AND rc.id = pl.category_id AND rc.code in %s""",
(self.employee_id, from_date, to_date, tuple(hierarchy_codes)),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 243 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L242-L243

Added lines #L242 - L243 were not covered by tests

def average_category_monthly(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()

Check warning on line 247 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L247

Added line #L247 was not covered by tests

hierarchy_codes = (

Check warning on line 249 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L249

Added line #L249 was not covered by tests
self.env["hr.salary.rule.category"]
.search([("code", "=", code)])
.children_ids.mapped("code")
)
hierarchy_codes.append(code)

Check warning on line 254 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L254

Added line #L254 was not covered by tests

self.env.cr.execute(

Check warning on line 256 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L256

Added line #L256 was not covered by tests
"""SELECT avg(total) FROM (
SELECT DATE_TRUNC('month',hp.date_from) AS date_month,
sum(case when hp.credit_note is not True then
(pl.total) else (-pl.total) end) AS total
FROM hr_payslip as hp, hr_payslip_line as pl, hr_salary_rule_category as rc
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id
AND rc.id = pl.category_id AND rc.code in %s
GROUP BY date_month) AS monthly_sum""",
(self.employee_id, from_date, to_date, tuple(hierarchy_codes)),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 269 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L268-L269

Added lines #L268 - L269 were not covered by tests

def max_category(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()

Check warning on line 273 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L273

Added line #L273 was not covered by tests

hierarchy_codes = (

Check warning on line 275 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L275

Added line #L275 was not covered by tests
self.env["hr.salary.rule.category"]
.search([("code", "=", code)])
.children_ids.mapped("code")
)
hierarchy_codes.append(code)

Check warning on line 280 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L280

Added line #L280 was not covered by tests

self.env.cr.execute(

Check warning on line 282 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L282

Added line #L282 was not covered by tests
"""SELECT max(case when hp.credit_note is not True then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl, hr_salary_rule_category as rc
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id
AND rc.id = pl.category_id AND rc.code in %s""",
(self.employee_id, from_date, to_date, tuple(hierarchy_codes)),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 292 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L291-L292

Added lines #L291 - L292 were not covered by tests

def max_category_monthly(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()

Check warning on line 296 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L296

Added line #L296 was not covered by tests

hierarchy_codes = (

Check warning on line 298 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L298

Added line #L298 was not covered by tests
self.env["hr.salary.rule.category"]
.search([("code", "=", code)])
.children_ids.mapped("code")
)
hierarchy_codes.append(code)

Check warning on line 303 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L303

Added line #L303 was not covered by tests

self.env.cr.execute(

Check warning on line 305 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L305

Added line #L305 was not covered by tests
"""SELECT max(total) FROM (
SELECT DATE_TRUNC('month',hp.date_from) AS date_month,
sum(case when hp.credit_note is not True then
(pl.total) else (-pl.total) end) AS total
FROM hr_payslip as hp, hr_payslip_line as pl, hr_salary_rule_category as rc
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id
AND rc.id = pl.category_id AND rc.code in %s
GROUP BY date_month) AS monthly_sum""",
(self.employee_id, from_date, to_date, tuple(hierarchy_codes)),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 318 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L317-L318

Added lines #L317 - L318 were not covered by tests

def min_category(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()

Check warning on line 322 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L322

Added line #L322 was not covered by tests

hierarchy_codes = (

Check warning on line 324 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L324

Added line #L324 was not covered by tests
self.env["hr.salary.rule.category"]
.search([("code", "=", code)])
.children_ids.mapped("code")
)
hierarchy_codes.append(code)

Check warning on line 329 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L329

Added line #L329 was not covered by tests

self.env.cr.execute(

Check warning on line 331 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L331

Added line #L331 was not covered by tests
"""SELECT min(case when hp.credit_note is not True then
(pl.total) else (-pl.total) end)
FROM hr_payslip as hp, hr_payslip_line as pl, hr_salary_rule_category as rc
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id
AND rc.id = pl.category_id AND rc.code in %s""",
(self.employee_id, from_date, to_date, tuple(hierarchy_codes)),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 341 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L340-L341

Added lines #L340 - L341 were not covered by tests

def min_category_monthly(self, code, from_date, to_date=None):
if to_date is None:
to_date = fields.Date.today()

Check warning on line 345 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L345

Added line #L345 was not covered by tests

hierarchy_codes = (

Check warning on line 347 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L347

Added line #L347 was not covered by tests
self.env["hr.salary.rule.category"]
.search([("code", "=", code)])
.children_ids.mapped("code")
)
hierarchy_codes.append(code)

Check warning on line 352 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L352

Added line #L352 was not covered by tests

self.env.cr.execute(

Check warning on line 354 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L354

Added line #L354 was not covered by tests
"""SELECT min(total) FROM (
SELECT DATE_TRUNC('month',hp.date_from) AS date_month,
sum(case when hp.credit_note is not True then
(pl.total) else (-pl.total) end) AS total
FROM hr_payslip as hp, hr_payslip_line as pl, hr_salary_rule_category as rc
WHERE hp.employee_id = %s AND hp.state = 'done'
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id
AND rc.id = pl.category_id AND rc.code in %s
GROUP BY date_month) AS monthly_sum""",
(self.employee_id, from_date, to_date, tuple(hierarchy_codes)),
)
res = self.env.cr.fetchone()
return res and res[0] or 0.0

Check warning on line 367 in payroll/models/base_browsable.py

View check run for this annotation

Codecov / codecov/patch

payroll/models/base_browsable.py#L366-L367

Added lines #L366 - L367 were not covered by tests
28 changes: 23 additions & 5 deletions payroll/models/hr_payslip.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,10 @@ def get_current_contract_dict(self, contract, contracts):
def _get_tools_dict(self):
# _get_tools_dict() is intended to be inherited by other private modules
# to add tools or python libraries available in localdict
return {"math": math} # "math" object is useful for doing calculations
return {
"math": math,
"datetime": datetime,
} # "math" object is useful for doing calculations

def _get_baselocaldict(self, contracts):
self.ensure_one()
Expand Down Expand Up @@ -533,10 +536,10 @@ def _get_lines_dict(
total = values["quantity"] * values["rate"] * values["amount"] / 100.0
values["total"] = total
# set/overwrite the amount computed for this rule in the localdict
if rule.code:
localdict[rule.code] = total
localdict["rules"].dict[rule.code] = rule
localdict["result_rules"].dict[rule.code] = BaseBrowsableObject(values)
code = rule.code or rule.id
localdict[code] = total
localdict["rules"].dict[code] = rule
localdict["result_rules"].dict[code] = BaseBrowsableObject(values)
# sum the amount for its salary category
localdict = self._sum_salary_rule_category(
localdict, rule.category_id, total - previous_amount
Expand Down Expand Up @@ -781,3 +784,18 @@ def get_salary_line_total(self, code):
return line[0].total
else:
return 0.0

def line_sum_where(self, field_name, value, rules, result_rules):
"""
The method may be used in salary rule code.
It will sum the total of the previously computed rules
where the given field has the given value.
E.g.: total_seq_10 = payslip.line_sum_where("sequence", 10, rules, result_rules)
"""
return sum(
[
result_rules.dict[code].dict["total"]
for code, rule in rules.dict.items()
if getattr(rule, field_name) == value
]
)
6 changes: 4 additions & 2 deletions payroll/models/hr_salary_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ def _compute_rule(self, localdict):
:rtype: {"name": string, "quantity": float, "rate": float, "amount": float}
"""
self.ensure_one()
method = f"_compute_rule_{self.amount_select}"
return api.call_kw(self, method, [self.ids, localdict], {})
method = "_compute_rule_{}".format(self.amount_select)
return api.call_kw(
self, method, [self.ids, localdict], {"context": self.env.context}
)

def _compute_rule_fix(self, localdict):
try:
Expand Down
45 changes: 45 additions & 0 deletions payroll/tests/test_hr_salary_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,48 @@ def test_rule_and_category_with_and_without_code(self):
lambda record: record.name == "rule without category"
)
self.assertEqual(len(line), 1, "Line found: rule without category")

def test_line_sum_where(self):
rule_fix_1 = self.SalaryRule.create(
{
"name": "Fixed rule 1",
"sequence": 1,
"condition_select": "none",
"amount_select": "fix",
"amount_fix": 100.0,
}
)
rule_fix_2 = self.SalaryRule.create(
{
"name": "Fixed rule 2",
"sequence": 2,
"condition_select": "none",
"amount_select": "fix",
"amount_fix": 200.0,
}
)
rule_line_sum_where = self.Rule.create(
{
"name": "Total fixed values",
"sequence": 3,
"amount_select": "code",
"amount_python_compute": """result = payslip.line_sum_where(
"amount_select", "fix", rules, result_rules
)""",
}
)
self.sales_pay_structure.rule_ids = [
(4, rule_fix_1.id),
(4, rule_fix_2.id),
(4, rule_line_sum_where.id),
]
payslip = self.Payslip.create(
{
"employee_id": self.richard_emp.id,
"contract_id": self.richard_contract.id,
"struct_id": self.sales_pay_structure.id,
}
)
payslip.compute_sheet()
line = payslip.line_ids.filtered(lambda l: l.name == "Total fixed values")
self.assertEqual(line.total, 300, "Fixed rules: 100 + 200 = 300")
Loading
Loading