diff --git a/account_vat_period_end_statement/README.rst b/account_vat_period_end_statement/README.rst index 1f05259a55f4..73d88ce2613d 100644 --- a/account_vat_period_end_statement/README.rst +++ b/account_vat_period_end_statement/README.rst @@ -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 > @@ -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 =========== diff --git a/account_vat_period_end_statement/__manifest__.py b/account_vat_period_end_statement/__manifest__.py index df62f8d355cf..440c8a6b5cb2 100644 --- a/account_vat_period_end_statement/__manifest__.py +++ b/account_vat_period_end_statement/__manifest__.py @@ -4,6 +4,7 @@ # Copyright 2015 Associazione Odoo Italia () # Copyright 2021 Gianmarco Conte # - Dinamiche Aziendali Srl () +# Copyright 2022 ~ 2023 Simone Rubino - TAKOBI # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { diff --git a/account_vat_period_end_statement/models/account.py b/account_vat_period_end_statement/models/account.py index 5b61e7ef7b8f..fac2f98e949e 100644 --- a/account_vat_period_end_statement/models/account.py +++ b/account_vat_period_end_statement/models/account.py @@ -2,7 +2,7 @@ # Copyright 2012-15 Agile Business Group sagl () # Copyright 2015 Associazione Odoo Italia () # Copyright 2021 Gianmarco Conte - Dinamiche Aziendali Srl () -# 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). @@ -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 @@ -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 diff --git a/account_vat_period_end_statement/models/config.py b/account_vat_period_end_statement/models/config.py index b55566ac00d3..ded47204a4c1 100644 --- a/account_vat_period_end_statement/models/config.py +++ b/account_vat_period_end_statement/models/config.py @@ -1,4 +1,5 @@ # Copyright 2015 Alessandro Camilli (a.camilli@openforce.it) +# Copyright 2023 Simone Rubino - TAKOBI # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import fields, models @@ -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.", + ) diff --git a/account_vat_period_end_statement/readme/CONFIGURE.md b/account_vat_period_end_statement/readme/CONFIGURE.md index 14163013741b..3c0f9daef3ba 100644 --- a/account_vat_period_end_statement/readme/CONFIGURE.md +++ b/account_vat_period_end_statement/readme/CONFIGURE.md @@ -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 \> @@ -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. diff --git a/account_vat_period_end_statement/static/description/index.html b/account_vat_period_end_statement/static/description/index.html index b5033f9db96d..3fc97f49b8e5 100644 --- a/account_vat_period_end_statement/static/description/index.html +++ b/account_vat_period_end_statement/static/description/index.html @@ -455,6 +455,10 @@

Configuration

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 > Configuration > Accounting > Date ranges > Generate Date Ranges (visible @@ -479,6 +483,9 @@

Configuration

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

diff --git a/account_vat_period_end_statement/tests/test_vat_statement.py b/account_vat_period_end_statement/tests/test_vat_statement.py index 34ea9caf7248..bbe18fc9978a 100644 --- a/account_vat_period_end_statement/tests/test_vat_statement.py +++ b/account_vat_period_end_statement/tests/test_vat_statement.py @@ -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, + ) diff --git a/account_vat_period_end_statement/views/config.xml b/account_vat_period_end_statement/views/config.xml index a75f97efa3db..c89380622414 100644 --- a/account_vat_period_end_statement/views/config.xml +++ b/account_vat_period_end_statement/views/config.xml @@ -18,6 +18,7 @@ +