|
|
@ -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), |
|
|
|