From 212d90ff072a16b81f270b66a3b9f9bbf9b80255 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Wed, 15 Mar 2023 21:05:06 +0100 Subject: [PATCH] [CHG] *_online_import: empty statements make no sense anymore As journal_id is now computed from statement lines, we do not want to create statements without lines, that will not be linked to a journal --- .../i18n/account_statement_import_online.pot | 5 --- account_statement_import_online/i18n/it.po | 5 --- account_statement_import_online/i18n/nl.po | 5 --- .../models/online_bank_statement_provider.py | 3 +- ...st_account_bank_statement_import_online.py | 37 ------------------- .../views/online_bank_statement_provider.xml | 1 - 6 files changed, 1 insertion(+), 55 deletions(-) diff --git a/account_statement_import_online/i18n/account_statement_import_online.pot b/account_statement_import_online/i18n/account_statement_import_online.pot index 94269fd5e4..f57a1cbc97 100644 --- a/account_statement_import_online/i18n/account_statement_import_online.pot +++ b/account_statement_import_online/i18n/account_statement_import_online.pot @@ -29,11 +29,6 @@ msgstr "" msgid "Active" msgstr "" -#. module: account_statement_import_online -#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__allow_empty_statements -msgid "Allow empty statements" -msgstr "" - #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__api_base msgid "Api Base" diff --git a/account_statement_import_online/i18n/it.po b/account_statement_import_online/i18n/it.po index 46ffaee317..29e47ace2d 100644 --- a/account_statement_import_online/i18n/it.po +++ b/account_statement_import_online/i18n/it.po @@ -32,11 +32,6 @@ msgstr "" msgid "Active" msgstr "" -#. module: account_statement_import_online -#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__allow_empty_statements -msgid "Allow empty statements" -msgstr "" - #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__api_base msgid "Api Base" diff --git a/account_statement_import_online/i18n/nl.po b/account_statement_import_online/i18n/nl.po index 081a817f4f..7564c5a17e 100644 --- a/account_statement_import_online/i18n/nl.po +++ b/account_statement_import_online/i18n/nl.po @@ -32,11 +32,6 @@ msgstr "Actie vereist" msgid "Active" msgstr "Actief" -#. module: account_statement_import_online -#: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__allow_empty_statements -msgid "Allow empty statements" -msgstr "" - #. module: account_statement_import_online #: model:ir.model.fields,field_description:account_statement_import_online.field_online_bank_statement_provider__api_base msgid "Api Base" diff --git a/account_statement_import_online/models/online_bank_statement_provider.py b/account_statement_import_online/models/online_bank_statement_provider.py index e317abe4fd..37f6130460 100644 --- a/account_statement_import_online/models/online_bank_statement_provider.py +++ b/account_statement_import_online/models/online_bank_statement_provider.py @@ -94,7 +94,6 @@ class OnlineBankStatementProvider(models.Model): certificate_public_key = fields.Text() certificate_private_key = fields.Text() certificate_chain = fields.Text() - allow_empty_statements = fields.Boolean() _sql_constraints = [ ( @@ -227,7 +226,7 @@ def _create_or_update_statement( statement_date_since, statement_date_until, ) - if not filtered_lines and not self.allow_empty_statements: + if not filtered_lines: return if filtered_lines: statement_values.update( diff --git a/account_statement_import_online/tests/test_account_bank_statement_import_online.py b/account_statement_import_online/tests/test_account_bank_statement_import_online.py index 5af59557fe..dd5944ea78 100644 --- a/account_statement_import_online/tests/test_account_bank_statement_import_online.py +++ b/account_statement_import_online/tests/test_account_bank_statement_import_online.py @@ -447,43 +447,6 @@ def test_dont_create_empty_statements(self): self.assertEqual(statements[1].balance_end, 200) self.assertEqual(len(statements[1].line_ids), 1) - def test_create_empty_statements(self): - """Test creating empty bank statements - ('Allow empty statements' field is check at the provider level). - """ - journal = self._make_journal() - provider = self._make_provider(journal) - provider.allow_empty_statements = True - with mock.patch(mock_obtain_statement_data) as mock_data: - mock_data.side_effect = [ - self._get_statement_line_data(date(2021, 8, 10)), - ([], {}), # August 8th, doesn't have statement - ([], {}), # August 9th, doesn't have statement - self._get_statement_line_data(date(2021, 8, 13)), - ] - provider._pull(datetime(2021, 8, 10), datetime(2021, 8, 14)) - statements = self.AccountBankStatement.search( - [("journal_id", "=", journal.id)], order="name" - ) - # 4 Statements: 2 with movements and 2 empty - self.assertEqual(len(statements), 4) - # With movement - self.assertEqual(statements[0].balance_start, 0) - self.assertEqual(statements[0].balance_end, 100) - self.assertEqual(len(statements[0].line_ids), 1) - # Empty - self.assertEqual(statements[1].balance_start, 100) - self.assertEqual(statements[1].balance_end, 100) - self.assertEqual(len(statements[1].line_ids), 0) - # Empty - self.assertEqual(statements[2].balance_start, 100) - self.assertEqual(statements[2].balance_end, 100) - self.assertEqual(len(statements[2].line_ids), 0) - # With movement - self.assertEqual(statements[3].balance_start, 100) - self.assertEqual(statements[3].balance_end, 200) - self.assertEqual(len(statements[3].line_ids), 1) - def _make_journal(self): """Create a journal for testing.""" journal = self.AccountJournal.create( diff --git a/account_statement_import_online/views/online_bank_statement_provider.xml b/account_statement_import_online/views/online_bank_statement_provider.xml index 4afc2affdc..c21a9ce6ee 100644 --- a/account_statement_import_online/views/online_bank_statement_provider.xml +++ b/account_statement_import_online/views/online_bank_statement_provider.xml @@ -84,7 +84,6 @@ -