Browse Source

Merge PR #306 into 12.0

Signed-off-by alexey-pelykh
12.0
OCA-git-bot 4 years ago
parent
commit
23aed13ed1
  1. 4
      account_bank_statement_import_online/models/online_bank_statement_provider.py
  2. 66
      account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py
  3. 4
      account_bank_statement_import_online/wizards/online_bank_statement_pull_wizard.xml

4
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(

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

4
account_bank_statement_import_online/wizards/online_bank_statement_pull_wizard.xml

@ -15,10 +15,10 @@
<group name="filter">
<group name="date_range" colspan="2">
<group>
<field name="date_since"/>
<field name="date_since" string="Since (at least)"/>
</group>
<group>
<field name="date_until"/>
<field name="date_until" string="Until (at least)"/>
</group>
</group>
</group>

Loading…
Cancel
Save