Browse Source

[FIX] Better message for not determined journal. (#86)

* [FIX] Better message for not determined journal.

* [FIX] Only check first (and constant) part of message in text.

Test on import bank statement checked exception message for wrong journal. Part of message has become variable,
so test had to be adapted.
pull/96/head
Ronald Portier 8 years ago
committed by Stefan Rijnhart (Opener)
parent
commit
f1900c6a33
  1. 6
      account_bank_statement_import/models/account_bank_statement_import.py
  2. 5
      account_bank_statement_import/tests/test_import_bank_statement.py

6
account_bank_statement_import/models/account_bank_statement_import.py

@ -150,7 +150,11 @@ class AccountBankStatementImport(models.TransientModel):
journal_id = self._get_journal(currency_id, bank_account_id) journal_id = self._get_journal(currency_id, bank_account_id)
# By now journal and account_number must be known # By now journal and account_number must be known
if not journal_id: if not journal_id:
raise UserError(_('Can not determine journal for import.'))
raise UserError(
_('Can not determine journal for import'
' for account number %s and currency %s.') %
(account_number, currency_code)
)
# Prepare statement data to be used for bank statements creation # Prepare statement data to be used for bank statements creation
stmt_vals = self._complete_statement( stmt_vals = self._complete_statement(
stmt_vals, journal_id, account_number) stmt_vals, journal_id, account_number)

5
account_bank_statement_import/tests/test_import_bank_statement.py

@ -75,8 +75,9 @@ class TestAccountBankStatementImport(TransactionCase):
self.statement_import_model._create_bank_account('123456789') self.statement_import_model._create_bank_account('123456789')
with self.assertRaises(UserError) as e: with self.assertRaises(UserError) as e:
self.statement_import_model._import_statement(stmt_vals.copy()) self.statement_import_model._import_statement(stmt_vals.copy())
self.assertEqual(e.exception.message,
'Can not determine journal for import.')
self.assertEqual(
e.exception.message[:25], 'Can not determine journal'
)
def test_create_bank_account(self): def test_create_bank_account(self):
"""Checks that the bank_account created by the import belongs to the """Checks that the bank_account created by the import belongs to the

Loading…
Cancel
Save