diff --git a/account_bank_statement_import_online/models/online_bank_statement_provider.py b/account_bank_statement_import_online/models/online_bank_statement_provider.py index 61077c2..960098c 100644 --- a/account_bank_statement_import_online/models/online_bank_statement_provider.py +++ b/account_bank_statement_import_online/models/online_bank_statement_provider.py @@ -249,7 +249,7 @@ class OnlineBankStatementProvider(models.Model): date = date.replace(tzinfo=utc) date = date.astimezone(utc).replace(tzinfo=None) - if date < statement_date_since or date < date_since: + if date < statement_date_since: if 'balance_start' in statement_values: statement_values['balance_start'] = ( Decimal( @@ -259,7 +259,7 @@ class OnlineBankStatementProvider(models.Model): ) ) continue - elif date >= statement_date_until or date >= date_until: + elif date >= statement_date_until: if 'balance_end_real' in statement_values: statement_values['balance_end_real'] = ( Decimal( diff --git a/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py b/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py index 9e347ba..566f5f0 100644 --- a/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py +++ b/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py @@ -77,30 +77,6 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): self.assertFalse(journal.online_bank_statement_provider_id) self.assertFalse(self.OnlineBankStatementProvider.search([])) - def test_pull_boundary(self): - journal = self.AccountJournal.create({ - 'name': 'Bank', - 'type': 'bank', - 'code': 'BANK', - 'bank_statements_source': 'online', - 'online_bank_statement_provider': 'dummy', - }) - - provider = journal.online_bank_statement_provider_id - provider.active = True - provider.with_context( - expand_by=1, - )._pull( - self.now - relativedelta(hours=1), - self.now, - ) - - statement = self.AccountBankStatement.search( - [('journal_id', '=', journal.id)], - ) - self.assertEqual(len(statement), 1) - self.assertEqual(len(statement.line_ids), 12) - def test_pull_mode_daily(self): journal = self.AccountJournal.create({ 'name': 'Bank', @@ -212,7 +188,11 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): provider.active = True provider.statement_creation_mode = 'weekly' - provider.with_context(step={'hours': 8})._pull( + provider.with_context( + step={'hours': 8}, + data_since=self.now - relativedelta(weeks=2), + data_until=self.now, + )._pull( self.now - relativedelta(weeks=2), self.now, ) @@ -223,7 +203,11 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): 14 * (24 / 8) ) - provider.with_context(step={'hours': 8})._pull( + provider.with_context( + step={'hours': 8}, + data_since=self.now - relativedelta(weeks=3), + data_until=self.now - relativedelta(weeks=1), + )._pull( self.now - relativedelta(weeks=3), self.now - relativedelta(weeks=1), ) @@ -234,7 +218,11 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): 21 * (24 / 8) ) - provider.with_context(step={'hours': 8})._pull( + provider.with_context( + step={'hours': 8}, + data_since=self.now - relativedelta(weeks=1), + data_until=self.now, + )._pull( self.now - relativedelta(weeks=1), self.now, ) @@ -440,12 +428,14 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): provider_context = { 'step': {'hours': 24}, 'data_since': datetime(2020, 1, 1), - 'data_until': datetime(2020, 2, 29), 'amount': 1.0, 'balance_start': 0, } - provider.with_context(**provider_context)._pull( + provider.with_context( + **provider_context, + data_until=datetime(2020, 1, 31), + )._pull( datetime(2020, 1, 1), datetime(2020, 1, 31), ) @@ -457,9 +447,12 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): self.assertEqual(statements[0].balance_start, 0.0) self.assertEqual(statements[0].balance_end_real, 30.0) - provider.with_context(**provider_context)._pull( + provider.with_context( + **provider_context, + data_until=datetime(2020, 2, 15), + )._pull( datetime(2020, 1, 1), - datetime(2020, 2, 15), + datetime(2020, 2, 29), ) statements = self.AccountBankStatement.search( [('journal_id', '=', journal.id)], @@ -471,7 +464,10 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): self.assertEqual(statements[1].balance_start, 31.0) self.assertEqual(statements[1].balance_end_real, 45.0) - provider.with_context(**provider_context)._pull( + provider.with_context( + **provider_context, + data_until=datetime(2020, 2, 29), + )._pull( datetime(2020, 1, 1), datetime(2020, 2, 29), ) @@ -499,6 +495,8 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): provider.tz = 'UTC' provider.with_context( step={'hours': 1}, + data_since=datetime(2020, 4, 17, 22, 0), + data_until=datetime(2020, 4, 18, 2, 0), tz='UTC', )._pull( datetime(2020, 4, 17, 22, 0), @@ -531,6 +529,8 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): provider.tz = 'Etc/GMT-2' provider.with_context( step={'hours': 1}, + data_since=datetime(2020, 4, 17, 22, 0), + data_until=datetime(2020, 4, 18, 2, 0), tz='UTC', )._pull( datetime(2020, 4, 17, 22, 0), @@ -624,6 +624,8 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): provider.active = True provider.with_context( step={'hours': 1}, + data_since=datetime(2020, 4, 18, 0, 0), + data_until=datetime(2020, 4, 18, 4, 0), timestamp_mode='str', )._pull( datetime(2020, 4, 18, 0, 0), diff --git a/account_bank_statement_import_online/wizards/online_bank_statement_pull_wizard.xml b/account_bank_statement_import_online/wizards/online_bank_statement_pull_wizard.xml index 665c67d..99f7162 100644 --- a/account_bank_statement_import_online/wizards/online_bank_statement_pull_wizard.xml +++ b/account_bank_statement_import_online/wizards/online_bank_statement_pull_wizard.xml @@ -15,10 +15,10 @@ - + - +