diff --git a/payroll_hr_public_holidays/README.rst b/payroll_hr_public_holidays/README.rst new file mode 100644 index 000000000..6252055fe --- /dev/null +++ b/payroll_hr_public_holidays/README.rst @@ -0,0 +1,97 @@ +======================= +Payroll Public Holidays +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9626246040af3f079fa4b82d4fe5555b571b289ddc26a4240d78d40b3fac75c3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github + :target: https://github.com/OCA/payroll/tree/18.0/payroll_hr_public_holidays + :alt: OCA/payroll +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/payroll-18-0/payroll-18-0-payroll_hr_public_holidays + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/payroll&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allows to link hr_holidays_public module with payroll. + +With this module installed, public holidats will automatically be +fetched and displayed in worked days table for payslip computation. This +is useful to countries that need to make salary rules with public +holidays data. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Set public holidays in holidays module +- Create a payslip +- Public holidays will be fetched automatically to the worked days table + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Nimarosa + +Contributors +------------ + +- Nimarosa (Nicolas Rodriguez) +- ``Heliconia Solutions Pvt. Ltd. ``\ \_ + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-nimarosa| image:: https://github.com/nimarosa.png?size=40px + :target: https://github.com/nimarosa + :alt: nimarosa + +Current `maintainer `__: + +|maintainer-nimarosa| + +This module is part of the `OCA/payroll `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/payroll_hr_public_holidays/__init__.py b/payroll_hr_public_holidays/__init__.py new file mode 100644 index 000000000..1ec1c0f42 --- /dev/null +++ b/payroll_hr_public_holidays/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 Nimarosa (Nicolas Rodriguez) (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/payroll_hr_public_holidays/__manifest__.py b/payroll_hr_public_holidays/__manifest__.py new file mode 100644 index 000000000..bc16ff6e9 --- /dev/null +++ b/payroll_hr_public_holidays/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright (C) 2021 Nimarosa (Nicolas Rodriguez) (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Payroll Public Holidays", + "version": "18.0.1.0.0", + "category": "Payroll", + "website": "https://github.com/OCA/payroll", + "summary": "Integration between payroll and hr_public_holidays", + "license": "AGPL-3", + "author": "Nimarosa, Odoo Community Association (OCA)", + "depends": ["payroll", "hr_holidays", "calendar_public_holiday"], + "data": [], + "installable": True, + "maintainers": ["nimarosa"], +} diff --git a/payroll_hr_public_holidays/i18n/es_AR.po b/payroll_hr_public_holidays/i18n/es_AR.po new file mode 100644 index 000000000..430eaa0fd --- /dev/null +++ b/payroll_hr_public_holidays/i18n/es_AR.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * payroll_hr_public_holidays +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-10-24 23:44+0000\n" +"Last-Translator: Nicolas Rodriguez Sande \n" +"Language-Team: none\n" +"Language: es_AR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip__display_name +msgid "Display Name" +msgstr "Nombre para mostrar" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip__id +msgid "ID" +msgstr "ID" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip____last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: payroll_hr_public_holidays +#: model:ir.model,name:payroll_hr_public_holidays.model_hr_payslip +msgid "Payslip" +msgstr "Liquidacion" + +#. module: payroll_hr_public_holidays +#: code:addons/payroll_hr_public_holidays/models/hr_payslip.py:0 +#, python-format +msgid "Public Holidays Leaves" +msgstr "Ausencias por feriados" diff --git a/payroll_hr_public_holidays/i18n/it.po b/payroll_hr_public_holidays/i18n/it.po new file mode 100644 index 000000000..08e91bfff --- /dev/null +++ b/payroll_hr_public_holidays/i18n/it.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * payroll_hr_public_holidays +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-01-05 19:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip__id +msgid "ID" +msgstr "ID" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: payroll_hr_public_holidays +#: model:ir.model,name:payroll_hr_public_holidays.model_hr_payslip +msgid "Payslip" +msgstr "Busta paga" + +#. module: payroll_hr_public_holidays +#: code:addons/payroll_hr_public_holidays/models/hr_payslip.py:0 +#, python-format +msgid "Public Holidays Leaves" +msgstr "Festività nazionali" diff --git a/payroll_hr_public_holidays/i18n/payroll_hr_public_holidays.pot b/payroll_hr_public_holidays/i18n/payroll_hr_public_holidays.pot new file mode 100644 index 000000000..96b961a00 --- /dev/null +++ b/payroll_hr_public_holidays/i18n/payroll_hr_public_holidays.pot @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * payroll_hr_public_holidays +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: payroll_hr_public_holidays +#: model:ir.model,name:payroll_hr_public_holidays.model_hr_payslip +msgid "Payslip" +msgstr "" + +#. module: payroll_hr_public_holidays +#. odoo-python +#: code:addons/payroll_hr_public_holidays/models/hr_payslip.py:0 +#, python-format +msgid "Public Holidays Leaves" +msgstr "" diff --git a/payroll_hr_public_holidays/i18n/pt.po b/payroll_hr_public_holidays/i18n/pt.po new file mode 100644 index 000000000..c48773a80 --- /dev/null +++ b/payroll_hr_public_holidays/i18n/pt.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * payroll_hr_public_holidays +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-01-07 17:01+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip__display_name +msgid "Display Name" +msgstr "Nome a Exibir" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip__id +msgid "ID" +msgstr "" + +#. module: payroll_hr_public_holidays +#: model:ir.model.fields,field_description:payroll_hr_public_holidays.field_hr_payslip____last_update +msgid "Last Modified on" +msgstr "Última Modificação em" + +#. module: payroll_hr_public_holidays +#: model:ir.model,name:payroll_hr_public_holidays.model_hr_payslip +msgid "Payslip" +msgstr "Recibo de Vencimento" + +#. module: payroll_hr_public_holidays +#: code:addons/payroll_hr_public_holidays/models/hr_payslip.py:0 +#, python-format +msgid "Public Holidays Leaves" +msgstr "Ausências em Feriados Públicos" diff --git a/payroll_hr_public_holidays/i18n/pt_BR.po b/payroll_hr_public_holidays/i18n/pt_BR.po new file mode 100644 index 000000000..a62fcc43b --- /dev/null +++ b/payroll_hr_public_holidays/i18n/pt_BR.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * payroll_hr_public_holidays +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" + +#. module: payroll_hr_public_holidays +#: model:ir.model,name:payroll_hr_public_holidays.model_hr_payslip +msgid "Payslip" +msgstr "" + +#. module: payroll_hr_public_holidays +#. odoo-python +#: code:addons/payroll_hr_public_holidays/models/hr_payslip.py:0 +#, python-format +msgid "Public Holidays Leaves" +msgstr "" diff --git a/payroll_hr_public_holidays/models/__init__.py b/payroll_hr_public_holidays/models/__init__.py new file mode 100644 index 000000000..9fbdccaff --- /dev/null +++ b/payroll_hr_public_holidays/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 Nimarosa (Nicolas Rodriguez) (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import hr_payslip diff --git a/payroll_hr_public_holidays/models/hr_payslip.py b/payroll_hr_public_holidays/models/hr_payslip.py new file mode 100644 index 000000000..e78895b7e --- /dev/null +++ b/payroll_hr_public_holidays/models/hr_payslip.py @@ -0,0 +1,47 @@ +# Copyright (C) 2021 Nimarosa (Nicolas Rodriguez) (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import _, api, models + + +class HrPayslip(models.Model): + _inherit = "hr.payslip" + + @api.model + def get_worked_day_lines(self, contracts, date_from, date_to): + res = super().get_worked_day_lines(contracts, date_from, date_to) + for contract in contracts.filtered( + lambda contract: contract.resource_calendar_id + ): + # only use payslip day_from if it's greather than contract start date + if date_from < contract.date_start: + date_from = contract.date_start + # == compute public holidays == # + pholidays = self._compute_public_holidays_days(contract, date_from, date_to) + if pholidays["number_of_days"] > 0: + res.append(pholidays) + return res + + def _compute_public_holidays_days(self, contract, date_from, date_to): + # get public holidays list + public_holidays = self.env["calendar.public.holiday"].get_holidays_list( + year=date_from.year, + start_dt=date_from, + end_dt=date_to, + partner_id=contract.employee_id.message_partner_ids.id, + ) + ph_days = len(public_holidays) + ph_hours = ( + ph_days * 8 + ) # Use 8 as default value if employee has no resource_calendar + if contract.employee_id.resource_calendar_id: + ph_hours = ph_days * contract.employee_id.resource_calendar_id.hours_per_day + return { + "name": _("Public Holidays Leaves"), + "sequence": 10, + "code": "PHOL", + "number_of_days": ph_days, + "number_of_hours": ph_hours, + "contract_id": contract.id, + } diff --git a/payroll_hr_public_holidays/pyproject.toml b/payroll_hr_public_holidays/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/payroll_hr_public_holidays/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/payroll_hr_public_holidays/readme/CONTRIBUTORS.md b/payroll_hr_public_holidays/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..2b6052d98 --- /dev/null +++ b/payroll_hr_public_holidays/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Nimarosa (Nicolas Rodriguez) \<\> +- `Heliconia Solutions Pvt. Ltd. `_ diff --git a/payroll_hr_public_holidays/readme/DESCRIPTION.md b/payroll_hr_public_holidays/readme/DESCRIPTION.md new file mode 100644 index 000000000..96a121f7b --- /dev/null +++ b/payroll_hr_public_holidays/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +Allows to link hr_holidays_public module with payroll. + +With this module installed, public holidats will automatically be +fetched and displayed in worked days table for payslip computation. This +is useful to countries that need to make salary rules with public +holidays data. diff --git a/payroll_hr_public_holidays/readme/USAGE.md b/payroll_hr_public_holidays/readme/USAGE.md new file mode 100644 index 000000000..9336d2a65 --- /dev/null +++ b/payroll_hr_public_holidays/readme/USAGE.md @@ -0,0 +1,3 @@ +- Set public holidays in holidays module +- Create a payslip +- Public holidays will be fetched automatically to the worked days table diff --git a/payroll_hr_public_holidays/static/description/icon.png b/payroll_hr_public_holidays/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/payroll_hr_public_holidays/static/description/icon.png differ diff --git a/payroll_hr_public_holidays/static/description/index.html b/payroll_hr_public_holidays/static/description/index.html new file mode 100644 index 000000000..9027f9987 --- /dev/null +++ b/payroll_hr_public_holidays/static/description/index.html @@ -0,0 +1,439 @@ + + + + + +Payroll Public Holidays + + + +
+

Payroll Public Holidays

+ + +

Beta License: AGPL-3 OCA/payroll Translate me on Weblate Try me on Runboat

+

Allows to link hr_holidays_public module with payroll.

+

With this module installed, public holidats will automatically be +fetched and displayed in worked days table for payslip computation. This +is useful to countries that need to make salary rules with public +holidays data.

+

Table of contents

+ +
+

Usage

+
    +
  • Set public holidays in holidays module
  • +
  • Create a payslip
  • +
  • Public holidays will be fetched automatically to the worked days table
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Nimarosa
  • +
+
+
+

Contributors

+
    +
  • Nimarosa (Nicolas Rodriguez) <nicolarsande@gmail.com>
  • +
  • Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>_
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

nimarosa

+

This module is part of the OCA/payroll project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/payroll_hr_public_holidays/tests/__init__.py b/payroll_hr_public_holidays/tests/__init__.py new file mode 100644 index 000000000..da08fdd69 --- /dev/null +++ b/payroll_hr_public_holidays/tests/__init__.py @@ -0,0 +1 @@ +from . import test_hr_payslip diff --git a/payroll_hr_public_holidays/tests/test_hr_payslip.py b/payroll_hr_public_holidays/tests/test_hr_payslip.py new file mode 100644 index 000000000..20e789db2 --- /dev/null +++ b/payroll_hr_public_holidays/tests/test_hr_payslip.py @@ -0,0 +1,93 @@ +from datetime import date + +from odoo.tests.common import TransactionCase + + +class TestPublicHolidays(TransactionCase): + def setUp(self): + super().setUp() + # Create a resource calendar with 8 hours per day + self.calendar = self.env["resource.calendar"].create( + {"name": "Standard 8h/day", "hours_per_day": 8} + ) + + # Create an employee with the above resource calendar + self.employee = self.env["hr.employee"].create( + { + "name": "Test Employee", + "resource_calendar_id": self.calendar.id, + } + ) + + # Create a contract for the employee + self.contract = self.env["hr.contract"].create( + { + "name": "Test Contract", + "employee_id": self.employee.id, + "resource_calendar_id": self.calendar.id, + "date_start": date(2024, 1, 1), + "wage": 1, + } + ) + + # Create a public holiday + self.public_holiday = self.env["calendar.public.holiday"].create( + { + "year": 2024, + "line_ids": [ + ( + 0, + 0, + { + "date": date(2024, 1, 2), + "name": "Test Public Holiday", + }, + ) + ], + } + ) + + def test_compute_public_holidays_days(self): + """Test public holidays computation for a contract.""" + date_from = date(2024, 1, 1) + date_to = date(2024, 1, 3) + + public_holidays = self.env["hr.payslip"]._compute_public_holidays_days( + self.contract, date_from, date_to + ) + + self.assertEqual( + public_holidays["number_of_days"], 1, "Should have 1 public holiday" + ) + self.assertEqual( + public_holidays["number_of_hours"], + 8, + "Should calculate 8 hours for 1 public holiday", + ) + + def test_get_worked_day_lines(self): + """Test worked day lines including public holidays.""" + date_from = date(2024, 1, 1) + date_to = date(2024, 1, 3) + + worked_day_lines = self.env["hr.payslip"].get_worked_day_lines( + self.contract, date_from, date_to + ) + + # Check that public holidays are included + public_holiday_lines = [ + line for line in worked_day_lines if line["code"] == "PHOL" + ] + self.assertEqual( + len(public_holiday_lines), 1, "Should include 1 public holiday line" + ) + self.assertEqual( + public_holiday_lines[0]["number_of_days"], + 1, + "Should have 1 public holiday day", + ) + self.assertEqual( + public_holiday_lines[0]["number_of_hours"], + 8, + "Should have 8 hours for public holiday", + )