Skip to content

Commit

Permalink
[IMP] account_vat_period_end_statement: Lock date on confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTakobi authored and SirAionTech committed Dec 11, 2024
1 parent ec25425 commit 60bc968
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 2 deletions.
9 changes: 9 additions & 0 deletions account_vat_period_end_statement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ Per calcolare gli interessi, è possibile aggiungere le informazioni da
utilizzare (conto e percentuale) nei dati aziendali, nella scheda
'Liquidazione IVA'.

Per impostare la "Data di blocco dichiarazione fiscale" alla conferma
della dichiarazione, abilitare "Impostare data di chiusura per
non-consulenti" nella scheda "Liquidazione IVA" della vista scheda
dell'azienda.

**English**

In order to generate VAT statement's periods, open Accounting >
Expand All @@ -146,6 +151,10 @@ associated to the account involved in the statement:
If you need to calculate interest, you can add default information in
your company data (percentage and account), in the 'VAT statement' tab.

In order to set the "Tax Return Lock Date" when a statement is
confirmed, enable "Set Lock Date on Confirmation" in the "VAT statement"
tab of the Company form view.

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

Expand Down
1 change: 1 addition & 0 deletions account_vat_period_end_statement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Copyright 2015 Associazione Odoo Italia (<http://www.odoo-italia.org>)
# Copyright 2021 Gianmarco Conte
# - Dinamiche Aziendali Srl (<www.dinamicheaziendali.it>)
# Copyright 2022 ~ 2023 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
Expand Down
26 changes: 24 additions & 2 deletions account_vat_period_end_statement/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2012-15 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright 2015 Associazione Odoo Italia (<http://www.odoo-italia.org>)
# Copyright 2021 Gianmarco Conte - Dinamiche Aziendali Srl (<www.dinamicheaziendali.it>)
# Copyright 2022 Simone Rubino - TAKOBI
# Copyright 2022 ~ 2023 Simone Rubino - TAKOBI
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

Expand Down Expand Up @@ -392,9 +392,31 @@ def statement_paid(self):
for statement in self:
statement.state = "paid"

def _get_end_date(self):
self.ensure_one()
periods = self.date_range_ids
end_date = max(
periods.mapped("date_end"),
default=None,
)
return end_date

def _set_company_lock_date(self):
self.ensure_one()
company = self.company_id or self.env.company
if company.account_vat_period_end_statement_set_lock_date:
end_date = self._get_end_date()
if end_date:
lock_date_values = {
"tax_lock_date": end_date,
}
company.update(lock_date_values)
return True

def statement_confirmed(self):
for statement in self:
statement.state = "confirmed"
statement._set_company_lock_date()

def _prepare_account_move_line(
self, name, account_id, move_id, statement, statement_date, partner_id=False
Expand Down Expand Up @@ -452,7 +474,7 @@ def create_move(self):

move.line_ids = lines_to_create
move.action_post()
statement.state = "confirmed"
statement.statement_confirmed()

return True

Expand Down
6 changes: 6 additions & 0 deletions account_vat_period_end_statement/models/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2015 Alessandro Camilli ([email protected])
# Copyright 2023 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
Expand All @@ -18,3 +19,8 @@ class ResCompany(models.Model):
"Interest on End Vat Statement - Account",
help="Apply interest on end vat statement",
)
account_vat_period_end_statement_set_lock_date = fields.Boolean(
string="Set Lock Date on Confirmation",
help="When confirming the VAT period end statement, "
"the Tax Return Lock Date is set to the Statement's end date.",
)
4 changes: 4 additions & 0 deletions account_vat_period_end_statement/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Per calcolare gli interessi, è possibile aggiungere le informazioni da
utilizzare (conto e percentuale) nei dati aziendali, nella scheda
'Liquidazione IVA'.

Per impostare la "Data di blocco dichiarazione fiscale" alla conferma della dichiarazione, abilitare "Impostare data di chiusura per non-consulenti" nella scheda "Liquidazione IVA" della vista scheda dell'azienda.

**English**

In order to generate VAT statement's periods, open Accounting \>
Expand All @@ -52,3 +54,5 @@ associated to the account involved in the statement:
If you need to calculate interest, you can add default information in
your company data (percentage and account), in the 'VAT statement'
tab.

In order to set the "Tax Return Lock Date" when a statement is confirmed, enable "Set Lock Date on Confirmation" in the "VAT statement" tab of the Company form view.
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>Per calcolare gli interessi, è possibile aggiungere le informazioni da
utilizzare (conto e percentuale) nei dati aziendali, nella scheda
‘Liquidazione IVA’.</p>
<p>Per impostare la “Data di blocco dichiarazione fiscale” alla conferma
della dichiarazione, abilitare “Impostare data di chiusura per
non-consulenti” nella scheda “Liquidazione IVA” della vista scheda
dell’azienda.</p>
<p><strong>English</strong></p>
<p>In order to generate VAT statement’s periods, open Accounting &gt;
Configuration &gt; Accounting &gt; Date ranges &gt; Generate Date Ranges (visible
Expand All @@ -479,6 +483,9 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
</ol>
<p>If you need to calculate interest, you can add default information in
your company data (percentage and account), in the ‘VAT statement’ tab.</p>
<p>In order to set the “Tax Return Lock Date” when a statement is
confirmed, enable “Set Lock Date on Confirmation” in the “VAT statement”
tab of the Company form view.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand Down
33 changes: 33 additions & 0 deletions account_vat_period_end_statement/tests/test_vat_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,36 @@ def test_report_multiple_payment_info(self):
report_content.decode(),
)
self.assertEqual(len(payment_infos), 1)

def test_set_lock_date(self):
"""
Confirming the statement sets the lock date.
"""
# Arrange
period = self.current_period
self.init_invoice(
"out_invoice",
invoice_date=self.recent_date,
amounts=[100],
taxes=self.account_tax_22,
post=True,
)
statement = self._get_statement(
period,
self.last_year_date,
self.env["account.account"].browse(),
payment_term=self.env.ref("account.account_payment_term_advance_60days"),
)
company = statement.company_id
company.account_vat_period_end_statement_set_lock_date = True
# pre-condition
self.assertFalse(company.tax_lock_date)

# Act
statement.create_move()

# Assert
self.assertEqual(
period.date_end,
company.tax_lock_date,
)
1 change: 1 addition & 0 deletions account_vat_period_end_statement/views/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<field
name="of_account_end_vat_statement_interest_account_id"
/>
<field name="account_vat_period_end_statement_set_lock_date" />
</group>
</page>
</xpath>
Expand Down

0 comments on commit 60bc968

Please sign in to comment.