Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
=================================================
AEAT 303 - Special Prorate Regularization Prorate
=================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b9ac8eb54ab0893ff2190fcc03617d5cd1ff2af820a81dbde69da5b10ce092d2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-NuoBiT%2Fodoo--addons-lightgray.png?logo=github
:target: https://github.com/NuoBiT/odoo-addons/tree/18.0/l10n_es_aeat_mod303_special_prorate_regularization_prorate
:alt: NuoBiT/odoo-addons

|badge1| |badge2| |badge3|

This module allows to regularize prorate differences on 303 report

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/NuoBiT/odoo-addons/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 <https://github.com/NuoBiT/odoo-addons/issues/new?body=module:%20l10n_es_aeat_mod303_special_prorate_regularization_prorate%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* NuoBiT Solutions SL

Contributors
------------

- `NuoBiT <https://www.nuobit.com>`__:

- Kilian Niubo [email protected]
- Deniz Gallo [email protected]

Maintainers
-----------

This module is part of the `NuoBiT/odoo-addons <https://github.com/NuoBiT/odoo-addons/tree/18.0/l10n_es_aeat_mod303_special_prorate_regularization_prorate>`_ project on GitHub.

You are welcome to contribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright NuoBiT Solutions SL - Kilian Niubo <[email protected]>
# Copyright 2026 NuoBiT Solutions SL - Deniz Gallo <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

{
"name": "AEAT 303 - Special Prorate Regularization Prorate",
"summary": "This module allows to regularize prorate differences on 303 report",
"version": "18.0.1.0.0",
"category": "Accounting",
"author": "NuoBiT Solutions SL",
"website": "https://github.com/NuoBiT/odoo-addons",
"license": "AGPL-3",
"depends": [
"l10n_es_aeat_mod303_special_prorate_regularization",
],
"data": [
"views/mod303_views.xml",
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_es_aeat_mod303_special_prorate_regularization_prorate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-10-04 15:02+0000\n"
"PO-Revision-Date: 2022-10-04 15:02+0000\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: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model,name:l10n_es_aeat_mod303_special_prorate_regularization_prorate.model_l10n_es_aeat_mod303_report
msgid "AEAT 303 Report"
msgstr "Modelo AEAT 303"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model,name:l10n_es_aeat_mod303_special_prorate_regularization_prorate.model_l10n_es_aeat_report
msgid "AEAT report base module"
msgstr "Módulo base para declaraciones AEAT"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model_terms:ir.ui.view,arch_db:l10n_es_aeat_mod303_special_prorate_regularization_prorate.view_l10n_es_aeat_mod303_report_form
msgid "Counterpart Account Payable"
msgstr "Cuenta contrapartida de pago"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model_terms:ir.ui.view,arch_db:l10n_es_aeat_mod303_special_prorate_regularization_prorate.view_l10n_es_aeat_mod303_report_form
msgid "Counterpart Account Receivable"
msgstr "Cuenta contrapartida de cobro"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_mod303_report__counterpart_prorate_receivable_account_id
msgid "Counterpart Prorate Account Receivable"
msgstr "Cuenta contrapartida de pago de prorrata"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_mod303_report__counterpart_prorate_payable_account_id
msgid "Counterpart Prorate Payable Account"
msgstr "Cuenta contrapartida de cobro de prorrata"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_mod303_report__display_name
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_report__display_name
msgid "Display Name"
msgstr "Nombre a mostrar"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_mod303_report__id
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_report__id
msgid "ID"
msgstr "Identificador"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_mod303_report____last_update
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_report____last_update
msgid "Last Modified on"
msgstr "Última modificación en"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model_terms:ir.ui.view,arch_db:l10n_es_aeat_mod303_special_prorate_regularization_prorate.view_l10n_es_aeat_mod303_report_form
msgid "Prorate Regularization Parameters"
msgstr "Parámetros de regularización de la prorrata"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model.fields,help:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_mod303_report__field_44
msgid "Prorate regularization by application of the final percentage."
msgstr "Regularización de prorrata por aplicación del porcentaje final."

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: code:addons/l10n_es_aeat_mod303_special_prorate_regularization_prorate/models/mod303.py:0
#, python-format
msgid "The account move cannot be created because it already exists"
msgstr "El asiento contable no puede ser creado porque ya existe"

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: code:addons/l10n_es_aeat_mod303_special_prorate_regularization_prorate/models/mod303.py:0
#, python-format
msgid "You must fill both journal and counterpart receivable/payable account."
msgstr "Se debe rellenar tanto el diario como las cuentas de contrapartida de pago y de cobro."

#. module: l10n_es_aeat_mod303_special_prorate_regularization_prorate
#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_special_prorate_regularization_prorate.field_l10n_es_aeat_mod303_report__field_44
msgid "[44] Prorate Regularization"
msgstr "[44] Regularización de prorrata"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mod303
from . import l10n_es_aeat_report
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright NuoBiT Solutions SL - Kilian Niubo <[email protected]>
# Copyright NuoBiT Solutions SL - Eric Antones <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


class L10nEsAeatReport(models.AbstractModel):
_inherit = "l10n.es.aeat.report"

move_prorate_id = fields.Many2one(
comodel_name="account.move",
string="Prorate Account entry",
readonly=True,
domain=[("move_type", "=", "entry")],
)

def _prepare_prorate_moves(self):
return self.mapped("move_prorate_id").ids
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Copyright NuoBiT Solutions SL - Kilian Niubo <[email protected]>
# Copyright NuoBiT Solutions SL - Eric Antones <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
import datetime

from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError


class L10nEsAeatMod303Report(models.AbstractModel):
_inherit = "l10n.es.aeat.mod303.report"

field_44 = fields.Float(
string="[44] Prorate Regularization",
default=0,
compute="_compute_field_44",
help="Prorate regularization by application of the final percentage.",
)

@api.depends("tax_line_ids", "tax_line_ids.amount")
def _compute_field_44(self):
for report in self:
report.field_44 = report.tax_line_ids.filtered(
lambda x: x.field_number == 44
).amount

counterpart_prorate_receivable_account_id = fields.Many2one(
comodel_name="account.account",
string="Counterpart Prorate Account Receivable",
domain="[('company_ids', 'in', company_id)]",
compute="_compute_counterpart_prorate_receivable_account_id",
store=True,
readonly=False,
)

@api.depends("company_id")
def _compute_counterpart_prorate_receivable_account_id(self):
for rec in self:
rec.counterpart_prorate_receivable_account_id = (
rec.company_id._get_account_id_from_xmlid("account_common_6391")
)

counterpart_prorate_payable_account_id = fields.Many2one(
comodel_name="account.account",
string="Counterpart Prorate Payable Account",
compute="_compute_counterpart_prorate_payable_account_id",
domain="[('company_ids', 'in', company_id)]",
store=True,
readonly=False,
)

@api.depends("company_id")
def _compute_counterpart_prorate_payable_account_id(self):
for rec in self:
rec.counterpart_prorate_payable_account_id = (
rec.company_id._get_account_id_from_xmlid("account_common_6341")
)

def _process_tax_line_regularization_prorate(self, tax_lines):
self.ensure_one()
groups = []
for tax_line in tax_lines:
groups += self.env["account.move.line"].read_group(
[
("id", "in", tax_line.move_line_ids.ids),
("parent_state", "=", "posted"),
],
["account_id", "tax_line_id", "debit", "credit"],
["account_id", "tax_line_id"],
lazy=False,
)

lines = []
prorate_year = self.prorate_year_id
precision = self.env["decimal.precision"].precision_get("Account")
for group in groups:
old_balance = group["debit"] - group["credit"]
if not prorate_year.tax_percentage:
new_balance = 0.0
else:
new_balance = round(
old_balance
* (
1
- prorate_year.tax_final_percentage
/ prorate_year.tax_percentage
),
precision,
)
# prorate
if new_balance:
group["debit"] = new_balance if new_balance > 0 else 0
group["credit"] = -new_balance if new_balance < 0 else 0
line = self._prepare_regularization_move_line(group)
line["tax_line_id"] = group["tax_line_id"][0]
lines.append(line)
return lines

def _prepare_tax_line_vals(self, map_line):
self.ensure_one()
res = super()._prepare_tax_line_vals(map_line)
if not self._eligible_prorate_period():
if map_line.field_number == 44:
res["amount"] = 0
res["move_line_ids"] = False
else:
if map_line.field_number == 44:
res = self._prepare_tax_line_vals_dates(
datetime.date(self.year, 1, 1),
datetime.date(self.year, 12, 31),
map_line,
)
prorate_year = self.prorate_year_id
self.env["decimal.precision"].precision_get("Account")
if prorate_year.tax_percentage:
res["amount"] = res["amount"] * (
1
- prorate_year.tax_final_percentage
/ prorate_year.tax_percentage
)
else:
res["amount"] = 0
return res

def create_regularization_move(self):
res = super().create_regularization_move()
if self._eligible_prorate_period():
if any(
[
not self.counterpart_prorate_receivable_account_id,
not self.counterpart_prorate_payable_account_id,
not self.journal_id,
]
):
raise UserError(
_(
"You must fill both journal and counterpart "
"receivable/payable account."
)
)
self.create_regularization_move_prorate()
return res

def create_regularization_move_prorate(self):
self.ensure_one()
move_vals = self._prepare_move_vals()
line_vals_list = self._prepare_regularization_move_lines_prorate()
move_vals["line_ids"] = [(0, 0, x) for x in line_vals_list]
if line_vals_list:
if self.move_prorate_id:
raise ValidationError(
_("The account move cannot be created because it already exists")
)
self.move_prorate_id = self.env["account.move"].create(move_vals)

def _prepare_regularization_move_lines_prorate(self):
self.ensure_one()
# Compute regular lines
lines = self._process_tax_line_regularization_prorate(
self.tax_line_ids.filtered(lambda x: x.field_number == 44)
)
# Compute counterpart lines
debit = sum(x["debit"] for x in lines)
credit = sum(x["credit"] for x in lines)
account = (
self.counterpart_prorate_receivable_account_id
if credit - debit < 0
else self.counterpart_prorate_payable_account_id
)
regularize_line = self._prepare_counterpart_move_line(account, debit, credit)
regularize_line["name"] = "Prorate Regularization"
lines.append(regularize_line)
return lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [NuoBiT](https://www.nuobit.com):
- Kilian Niubo <[email protected]>
- Deniz Gallo <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to regularize prorate differences on 303 report
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading