You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 KiB

  1. # Copyright 2015 Odoo S. A.
  2. # Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
  3. # Copyright 2015 Ronald Portier <rportier@therp.nl>
  4. # Copyright 2016-2017 Tecnativa - Pedro M. Baeza
  5. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  6. from odoo.tests.common import TransactionCase
  7. from odoo.modules.module import get_module_resource
  8. import base64
  9. class TestQifFile(TransactionCase):
  10. """Tests for import bank statement qif file format
  11. (account.bank.statement.import)
  12. """
  13. def setUp(self):
  14. super(TestQifFile, self).setUp()
  15. self.statement_import_model = self.env['account.bank.statement.import']
  16. self.statement_line_model = self.env['account.bank.statement.line']
  17. self.journal = self.env['account.journal'].create({
  18. 'name': 'Test bank journal',
  19. 'code': 'TEST',
  20. 'type': 'bank',
  21. })
  22. self.partner = self.env['res.partner'].create({
  23. # Different case for trying insensitive case search
  24. 'name': 'EPIC Technologies',
  25. })
  26. def test_qif_file_import(self):
  27. qif_file_path = get_module_resource(
  28. 'account_bank_statement_import_qif', 'tests', 'test_qif.qif',
  29. )
  30. qif_file = base64.b64encode(open(qif_file_path, 'rb').read())
  31. wizard = self.statement_import_model.with_context(
  32. journal_id=self.journal.id
  33. ).create(
  34. dict(data_file=qif_file)
  35. )
  36. wizard.import_file()
  37. statement = self.statement_line_model.search(
  38. [('name', '=', 'YOUR LOCAL SUPERMARKET')], limit=1,
  39. )[0].statement_id
  40. self.assertAlmostEqual(statement.balance_end_real, -1896.09, 2)
  41. line = self.statement_line_model.search(
  42. [('name', '=', 'Epic Technologies')], limit=1,
  43. )
  44. self.assertEqual(line.partner_id, self.partner)