Skip to content

Commit

Permalink
[IMP] l10n_es_aeat_mod303: update 2024-10
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Oct 17, 2024
1 parent d55b49c commit 8fdd714
Show file tree
Hide file tree
Showing 13 changed files with 656 additions and 232 deletions.
17 changes: 17 additions & 0 deletions l10n_es_aeat_mod303/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Known issues / Roadmap
Foral.
* Posibilidad de marcar en el resultado el ingreso/devolución en la cuenta
corriente tributaria.
* No se pueden rellenar las casillas [108] y [111] de rectificación de autoliquidación.
* No se puede rellenar la casilla [109]: Devoluciones acordadas por la Agencia
Tributaria como consecuencia de la tramitación de anteriores autoliquidaciones
correspondientes al ejercicio y período objeto de la autoliquidación.
Expand All @@ -77,6 +78,10 @@ Known issues / Roadmap
posiciones fiscales.

Más información en https://www.boe.es/diario_boe/txt.php?id=BOE-A-2014-12329
* No se han mapeado las ventas con el nuevo IVA a la electricidad del 5%, a la
espera de si Hacienda cambia el modelo para alojar dicho valor.
* No se ha comprobado en producción la funcionalidad de comunicaciones usando
la opción de cuenta tributaria (tipos de resultado "G" y "V").

Bug Tracker
===========
Expand Down Expand Up @@ -111,6 +116,18 @@ Contributors
* Antonio Espinosa
* Luis M. Ontalba
* Pedro M. Baeza
* `Sygel <https://www.sygel.es>`__:

* Harald Panten
* Valentin Vinagre
* `Ozono Multimedia <https://www.ozonomultimedia.com>`__:

* Iván Antón

* `Moduon <https://www.moduon.team/>`__:

* Arantxa Sudón
* Rafael Blasco

Maintainers
~~~~~~~~~~~
Expand Down
9 changes: 5 additions & 4 deletions l10n_es_aeat_mod303/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-spain",
"license": "AGPL-3",
"depends": [
"l10n_es",
"l10n_es_aeat",
],
"depends": ["l10n_es", "l10n_es_aeat", "l10n_es_extra_data"],
"data": [
"data/2021-07/aeat.model.export.config.csv",
"data/2021-07/aeat.model.export.config.line.csv",
Expand All @@ -31,6 +28,10 @@
"data/2023/aeat.model.export.config.line.csv",
"data/2023/l10n.es.aeat.map.tax.csv",
"data/2023/l10n.es.aeat.map.tax.line.csv",
"data/2024-10/aeat.model.export.config.csv",
"data/2024-10/aeat.model.export.config.line.csv",
"data/2024-10/l10n.es.aeat.map.tax.csv",
"data/2024-10/l10n.es.aeat.map.tax.line.csv",
"data/tax_code_map_mod303_data.xml",
"data/aeat_export_mod303_data.xml",
"data/aeat_export_mod303_2017_data.xml",
Expand Down
2 changes: 1 addition & 1 deletion l10n_es_aeat_mod303/data/2023/aeat.model.export.config.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"id","name","date_end","model_number","model_id:id","date_start","date_end","active"
"aeat_mod303_2023_main_export_config","Mod.303 2023-actualidad",,"303","model_l10n_es_aeat_mod303_report","2023-01-01",,True
"aeat_mod303_2023_main_export_config","Mod.303 2023-2024-08",,"303","model_l10n_es_aeat_mod303_report","2023-01-01","2024-08-31",True
"aeat_mod303_2023_sub01_export_config","Exportación modelo 303 2023 - Régimen general/simplificado",,"303",0,,,0
"aeat_mod303_2023_sub03_export_config","Exportación modelo 303 2023 - Información adicional + Resultado",,"303",0,,,0
"aeat_mod303_2023_subdid_export_config","Exportación modelo 303 2023 - Devolución",,"303",0,,,0
2 changes: 1 addition & 1 deletion l10n_es_aeat_mod303/data/2023/l10n.es.aeat.map.tax.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id,model,date_from,date_to
aeat_mod303_2023_map,303,2023-01-01,
aeat_mod303_2023_map,303,2023-01-01,2024-09-30
4 changes: 4 additions & 0 deletions l10n_es_aeat_mod303/data/2024-10/aeat.model.export.config.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"id","name","date_end","model_number","model_id:id","date_start","date_end","active"
"aeat_mod303_2024_10_main_export_config","Mod. 303 2024-09-actualidad",,"303","model_l10n_es_aeat_mod303_report","2024-09-01",,True
"aeat_mod303_2024_10_sub01_export_config","Exportación modelo 303 2024-10 - Régimen general/simplificado",,"303",0,,,0
"aeat_mod303_2024_10_sub03_export_config","Exportación modelo 303 2024-10 - Información adicional + Resultado",,"303",0,,,0
147 changes: 147 additions & 0 deletions l10n_es_aeat_mod303/data/2024-10/aeat.model.export.config.line.csv

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions l10n_es_aeat_mod303/data/2024-10/l10n.es.aeat.map.tax.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,model,date_from,date_to
aeat_mod303_2024_10_map,303,2024-10-01,
63 changes: 63 additions & 0 deletions l10n_es_aeat_mod303/data/2024-10/l10n.es.aeat.map.tax.line.csv

Large diffs are not rendered by default.

167 changes: 131 additions & 36 deletions l10n_es_aeat_mod303/models/mod303.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ def _default_counterpart_303(self):
devolucion_mensual = fields.Boolean(
string="Montly Return",
states=NON_EDITABLE_ON_DONE,
help="Registered in the Register of Monthly Return")
help="Registered in the Register of Monthly Return",
)
return_last_period = fields.Boolean(
string="Last Period Return",
states=NON_EDITABLE_ON_DONE,
help="Check if you are submitting the last period return",
compute="_compute_return_last_period",
store=True,
readonly=False,
)
total_devengado = fields.Float(
string="[27] VAT payable", readonly=True, compute_sudo=True,
compute='_compute_total_devengado', store=True)
Expand Down Expand Up @@ -74,6 +83,9 @@ def _default_counterpart_303(self):
regularizacion_anual = fields.Float(
string="[68] Annual regularization",
states=NON_EDITABLE_ON_DONE,
compute="_compute_regularizacion_anual",
readonly=False,
store=True,
help="In the last auto settlement of the year, shall be recorded "
"(the fourth period or 12th month), with the appropriate sign, "
"the result of the annual adjustment as have the laws by the "
Expand All @@ -98,8 +110,18 @@ def _default_counterpart_303(self):
"exercise and period",
states=NON_EDITABLE_ON_DONE)
resultado_liquidacion = fields.Float(
string="[71] Settlement result", readonly=True,
compute='_compute_resultado_liquidacion', store=True)
string="[71] Settlement result",
readonly=True,
compute="_compute_resultado_liquidacion",
store=True,
)
use_aeat_account = fields.Boolean(
"Usar cuenta corriente tributaria",
help=(
"Si está suscrito a la cuenta corriente en materia tributaria, "
"active esta opción para usarla en el ingreso o devolución."
),
)
result_type = fields.Selection(
selection=[
("I", "To enter"),
Expand Down Expand Up @@ -243,10 +265,21 @@ def _default_counterpart_303(self):
],
compute='_compute_marca_sepa')

@api.depends("partner_bank_id")
def _get_export_config(self, date):
# Force the configuration of 2024-10 for 2024/09, as it can't be obtained with
# the usual dates search
if self.period_type == "3T" and self.year == 2024:
return self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_2024_10_main_export_config"
)
return super()._get_export_config(date)

@api.depends("partner_bank_id", "use_aeat_account")
def _compute_marca_sepa(self):
for record in self:
if record.partner_bank_id.bank_id.country == self.env.ref("base.es"):
if record.use_aeat_account:
record.marca_sepa = "0"
elif record.partner_bank_id.bank_id.country == self.env.ref("base.es"):
record.marca_sepa = "1"
elif record.partner_bank_id.bank_id.country in \
self.env.ref("base.europe").country_ids:
Expand Down Expand Up @@ -285,14 +318,41 @@ def _compute_exception_msg(self):
"field '[67] Fees to compensate' in this declaration."
)

@api.multi
@api.depends('tax_line_ids', 'tax_line_ids.amount')
@api.depends("company_id", "result_type")
def _compute_counterpart_account_id(self):
for record in self:
code = ("%s%%" % _ACCOUNT_PATTERN_MAP.get(record.result_type, "4750"),)
record.counterpart_account_id = self.env["account.account"].search(
[("code", "=like", code[0]), ("company_id", "=", record.company_id.id)],
limit=1,
)

@api.depends("period_type")
def _compute_regularizacion_anual(self):
for record in self:
if record.period_type not in ("4T", "12"):
record.regularizacion_anual = 0

@api.depends("period_type")
def _compute_exonerated_390(self):
for record in self:
if record.period_type not in ("4T", "12"):
record.exonerated_390 = "2"

@api.depends("period_type")
def _compute_return_last_period(self):
for record in self:
if record.period_type not in ("4T", "12"):
record.return_last_period = False

@api.depends("tax_line_ids", "tax_line_ids.amount")
def _compute_total_devengado(self):
casillas_devengado = (152, 3, 155, 6, 9, 11, 13, 15, 158, 18, 21, 24, 26)
cells = (152, 167, 3, 155, 6, 9, 11, 13, 15, 158, 170, 18, 21, 24, 26)
for report in self:
tax_lines = report.tax_line_ids.filtered(
lambda x: x.field_number in casillas_devengado)
report.total_devengado = sum(tax_lines.mapped('amount'))
tax_lines = report.tax_line_ids.filtered(lambda x: x.field_number in cells)
report.total_devengado = report.currency_id.round(
sum(tax_lines.mapped("amount"))
)

@api.multi
@api.depends('tax_line_ids', 'tax_line_ids.amount')
Expand Down Expand Up @@ -361,7 +421,12 @@ def _compute_allow_posting(self):

@api.multi
@api.depends(
"resultado_liquidacion", "period_type", "devolucion_mensual", "marca_sepa"
"resultado_liquidacion",
"period_type",
"devolucion_mensual",
"marca_sepa",
"use_aeat_account",
"return_last_period",
)
def _compute_result_type(self):
for report in self:
Expand All @@ -373,10 +438,21 @@ def _compute_result_type(self):
if result == 0:
report.result_type = "N"
elif result == 1:
report.result_type = "I"
if report.use_aeat_account:
report.result_type = "G"
elif report.marca_sepa in {"1", "2"}:
# Domiciliar ingreso porque se indicó un banco SEPA
report.result_type = "U"
else:
report.result_type = "I"
else:
if report.devolucion_mensual or report.period_type in ("4T", "12"):
report.result_type = "D" if report.marca_sepa == "1" else "X"
if report.use_aeat_account:
report.result_type = "V"
elif report.return_last_period or report.devolucion_mensual:
report.result_type = "D" if report.marca_sepa == "1" else "X"
else:
report.result_type = "C"
else:
report.result_type = 'C'

Expand All @@ -395,29 +471,48 @@ def onchange_type(self):
@api.multi
def calculate(self):
res = super(L10nEsAeatMod303Report, self).calculate()
self.cuota_compensar = 0
for mod303 in self:
vals = {
"counterpart_account_id": self.env['account.account'].search([
('code', '=like', '%s%%' % _ACCOUNT_PATTERN_MAP.get(
mod303.result_type, '4750')),
('company_id', '=', mod303.company_id.id),
], limit=1).id,
}
prev_reports = mod303._get_previous_fiscalyear_reports(
mod303.date_start
).filtered(lambda x: x.state not in ['draft', 'cancelled'])
if not prev_reports:
continue
prev_report = min(
prev_reports, key=lambda x: abs(
fields.Date.to_date(x.date_end) -
fields.Date.to_date(mod303.date_start)
),
)
if prev_report.result_type == 'C':
vals["cuota_compensar"] = abs(prev_report.resultado_liquidacion)
vals["potential_cuota_compensar"] = vals["cuota_compensar"]
mod303.write(vals)
prev_reports = self.search(
[("date_start", "<", mod303.date_start)]
).filtered(lambda m: m.state not in ["draft", "cancelled"])
if prev_reports:
prev_report = min(
prev_reports,
key=lambda x: abs(
fields.Date.to_date(x.date_end)
- fields.Date.to_date(mod303.date_start)
),
)
if prev_report and (
prev_report.remaining_cuota_compensar > 0
or prev_report.result_type == "C"
):
mod303.write(
{
"potential_cuota_compensar": (
prev_report.remaining_cuota_compensar
- prev_report.resultado_liquidacion
),
}
)
if mod303.return_last_period:
cuota_compensar = mod303.potential_cuota_compensar
elif (
float_compare(
mod303.resultado_liquidacion,
0,
precision_digits=mod303.currency_id.decimal_places,
)
!= -1
):
cuota_compensar = min(
mod303.potential_cuota_compensar, mod303.resultado_liquidacion
)
else:
cuota_compensar = 0
mod303.cuota_compensar = cuota_compensar

return res

@api.multi
Expand Down
12 changes: 12 additions & 0 deletions l10n_es_aeat_mod303/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@
* Antonio Espinosa
* Luis M. Ontalba
* Pedro M. Baeza
* `Sygel <https://www.sygel.es>`__:

* Harald Panten
* Valentin Vinagre
* `Ozono Multimedia <https://www.ozonomultimedia.com>`__:

* Iván Antón

* `Moduon <https://www.moduon.team/>`__:

* Arantxa Sudón
* Rafael Blasco
5 changes: 5 additions & 0 deletions l10n_es_aeat_mod303/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Foral.
* Posibilidad de marcar en el resultado el ingreso/devolución en la cuenta
corriente tributaria.
* No se pueden rellenar las casillas [108] y [111] de rectificación de autoliquidación.
* No se puede rellenar la casilla [109]: Devoluciones acordadas por la Agencia
Tributaria como consecuencia de la tramitación de anteriores autoliquidaciones
correspondientes al ejercicio y período objeto de la autoliquidación.
Expand All @@ -24,3 +25,7 @@
posiciones fiscales.

Más información en https://www.boe.es/diario_boe/txt.php?id=BOE-A-2014-12329
* No se han mapeado las ventas con el nuevo IVA a la electricidad del 5%, a la
espera de si Hacienda cambia el modelo para alojar dicho valor.
* No se ha comprobado en producción la funcionalidad de comunicaciones usando
la opción de cuenta tributaria (tipos de resultado "G" y "V").
23 changes: 23 additions & 0 deletions l10n_es_aeat_mod303/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -407,6 +408,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Known issues / Roadmap</a></h1>
<li><p class="first">Posibilidad de marcar en el resultado el ingreso/devolución en la cuenta
corriente tributaria.</p>
</li>
<li><p class="first">No se pueden rellenar las casillas [108] y [111] de rectificación de autoliquidación.</p>
</li>
<li><p class="first">No se puede rellenar la casilla [109]: Devoluciones acordadas por la Agencia
Tributaria como consecuencia de la tramitación de anteriores autoliquidaciones
correspondientes al ejercicio y período objeto de la autoliquidación.</p>
Expand All @@ -428,6 +431,12 @@ <h1><a class="toc-backref" href="#toc-entry-1">Known issues / Roadmap</a></h1>
posiciones fiscales.</p>
<p>Más información en <a class="reference external" href="https://www.boe.es/diario_boe/txt.php?id=BOE-A-2014-12329">https://www.boe.es/diario_boe/txt.php?id=BOE-A-2014-12329</a></p>
</li>
<li><p class="first">No se han mapeado las ventas con el nuevo IVA a la electricidad del 5%, a la
espera de si Hacienda cambia el modelo para alojar dicho valor.</p>
</li>
<li><p class="first">No se ha comprobado en producción la funcionalidad de comunicaciones usando
la opción de cuenta tributaria (tipos de resultado “G” y “V”).</p>
</li>
</ul>
</div>
<div class="section" id="bug-tracker">
Expand Down Expand Up @@ -462,6 +471,20 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Pedro M. Baeza</li>
</ul>
</li>
<li><a class="reference external" href="https://www.sygel.es">Sygel</a>:<ul>
<li>Harald Panten</li>
<li>Valentin Vinagre</li>
</ul>
</li>
<li><a class="reference external" href="https://www.ozonomultimedia.com">Ozono Multimedia</a>:<ul>
<li>Iván Antón</li>
</ul>
</li>
<li><a class="reference external" href="https://www.moduon.team/">Moduon</a>:<ul>
<li>Arantxa Sudón</li>
<li>Rafael Blasco</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Loading

0 comments on commit 8fdd714

Please sign in to comment.