Skip to content
Snippets Groups Projects
Commit fbb8400f authored by Arthur Maniet's avatar Arthur Maniet
Browse files

[FIX] account: OFX import test

parent 1b05d9df
Branches
Tags
No related merge requests found
......@@ -8,8 +8,8 @@ class TestOfxFile(TransactionCase):
def setUp(self):
super(TestOfxFile, self).setUp()
self.BankStatementImport = self.env['account.bank.statement.import']
self.BankStatement = self.env['account.bank.statement']
self.statement_import_model = self.env['account.bank.statement.import']
self.bank_statement_model = self.env['account.bank.statement']
def test_ofx_file_import(self):
try:
......@@ -19,10 +19,19 @@ class TestOfxFile(TransactionCase):
return True
ofx_file_path = get_module_resource('account_bank_statement_import_ofx', 'test_ofx_file', 'test_ofx.ofx')
ofx_file = open(ofx_file_path, 'rb').read().encode('base64')
bank_statement_id = self.BankStatementImport.create(dict(
data_file=ofx_file,
))
bank_statement_id.import_file()
statement = self.BankStatement.search([('name', '=', '000000123')], limit=1)
self.assertEquals(statement.balance_start, 2516.56)
self.assertEquals(statement.balance_end_real, 2156.56)
import_wizard = self.statement_import_model.create(dict(data_file=ofx_file))
create_journal_wizard = self.env['account.bank.statement.import.journal.creation']\
.with_context(statement_import_transient_id=import_wizard.id)\
.create({'name': 'Bank 123456', 'currency_id': self.env.ref("base.USD").id, 'account_number': '123456'})
create_journal_wizard.create_journal() # Note: also finishes import
bank_st_record = self.bank_statement_model.search([('name', '=', '000000123')])[0]
self.assertEqual(bank_st_record.balance_start, 2516.56)
self.assertEqual(bank_st_record.balance_end_real, 2156.56)
line = bank_st_record.line_ids[-1]
self.assertEqual(line.name, 'Agrolait')
self.assertEqual(line.ref, '219378')
self.assertEqual(line.partner_id.id, self.ref('base.res_partner_2'))
self.assertEqual(line.bank_account_id.id, self.ref('account_bank_statement_import.ofx_partner_bank_1'))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment