Skip to content

Commit

Permalink
Merge PR #143 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by nimarosa
  • Loading branch information
OCA-git-bot committed Feb 13, 2024
2 parents 60a9f57 + 5a9d584 commit 985f7cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
14 changes: 10 additions & 4 deletions payroll/tests/test_payslip_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from datetime import timedelta

from odoo.fields import Date
from odoo.tests import Form
from odoo.tools import test_reports
Expand Down Expand Up @@ -222,12 +224,14 @@ def test_get_contracts_singleton(self):
len(contracts), 1, "There is one open contract for the employee"
)

self.sally.contract_id.date_end = Date.today().strftime("%Y-%m-15")
self.sally.contract_id.date_end = (Date.today() - timedelta(days=1)).strftime(
"%Y-%m-%d"
)
self.Contract.create(
{
"name": "Second contract for Sally",
"employee_id": self.sally.id,
"date_start": Date.today().strftime("%Y-%m-16"),
"date_start": Date.today().strftime("%Y-%m-%d"),
"struct_id": self.sales_pay_structure.id,
"wage": 6500.00,
"state": "open",
Expand All @@ -241,12 +245,14 @@ def test_get_contracts_singleton(self):

def test_get_contracts_multiple(self):

self.sally.contract_ids[0].date_end = Date.today().strftime("%Y-%m-15")
self.sally.contract_ids[0].date_end = (
Date.today() - timedelta(days=1)
).strftime("%Y-%m-%d")
self.Contract.create(
{
"name": "Second contract for Sally",
"employee_id": self.sally.id,
"date_start": Date.today().strftime("%Y-%m-16"),
"date_start": Date.today().strftime("%Y-%m-%d"),
"struct_id": self.sales_pay_structure.id,
"wage": 6500.00,
"state": "open",
Expand Down
20 changes: 11 additions & 9 deletions payroll_account/models/hr_payroll_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ def action_payslip_done(self):
debit_account_id = line.salary_rule_id.account_debit.id
credit_account_id = line.salary_rule_id.account_credit.id
account_id = debit_account_id or credit_account_id
analytic_salary_id = line.salary_rule_id.analytic_account_id.id
move_line_analytic_ids = []
if analytic_salary_id:
move_line_analytic_ids.append((4, analytic_salary_id.id))
elif slip.contract_id.analytic_account_id:
move_line_analytic_ids.append(
(4, slip.contract_id.analytic_account_id.id)
analytic_salary_id = line.salary_rule_id.analytic_account_id
move_line_analytic_ids = {}
if slip.contract_id.analytic_account_id:
move_line_analytic_ids.update(
{line.slip_id.contract_id.analytic_account_id.id: 100}
)
elif analytic_salary_id:
move_line_analytic_ids.update(
{line.salary_rule_id.analytic_account_id.id: 100}
)

tax_ids = False
Expand Down Expand Up @@ -188,7 +190,7 @@ def action_payslip_done(self):
"date": date,
"debit": amount > 0.0 and amount or 0.0,
"credit": amount < 0.0 and -amount or 0.0,
"analytic_line_ids": move_line_analytic_ids,
"analytic_distribution": move_line_analytic_ids,
"tax_line_id": line.salary_rule_id.account_tax_id.id,
"tax_ids": tax_ids,
"tax_repartition_line_id": tax_repartition_line_id,
Expand All @@ -211,7 +213,7 @@ def action_payslip_done(self):
"date": date,
"debit": amount < 0.0 and -amount or 0.0,
"credit": amount > 0.0 and amount or 0.0,
"analytic_line_ids": move_line_analytic_ids,
"analytic_distribution": move_line_analytic_ids,
"tax_line_id": line.salary_rule_id.account_tax_id.id,
"tax_ids": tax_ids,
"tax_repartition_line_id": tax_repartition_line_id,
Expand Down

0 comments on commit 985f7cf

Please sign in to comment.