Browse Source

[IMP] Backport from master at 04daefd2d1

pull/142/head
Laurent Mignon 10 years ago
committed by Nicolas JEUDY
parent
commit
6e683d8db3
  1. 3
      account_bank_statement_import_ofx/__init__.py
  2. 3
      account_bank_statement_import_ofx/__openerp__.py
  3. 7
      account_bank_statement_import_ofx/account_bank_statement_import_ofx.py
  4. 6
      account_bank_statement_import_ofx/tests/test_import_bank_statement.py

3
account_bank_statement_import_ofx/__init__.py

@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
from . import account_bank_statement_import_ofx
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import account_bank_statement_import_ofx

3
account_bank_statement_import_ofx/__openerp__.py

@ -25,9 +25,10 @@ base account_bank_statement_import module has been imported, or manually
create periods for the year 2013. create periods for the year 2013.
""", """,
'data' : [], 'data' : [],
'depends': ['account_bank_statement_import'],
'demo': [ 'demo': [
'demo/demo_data.xml', 'demo/demo_data.xml',
], ],
'auto_install': False,
'auto_install': True,
'installable': True, 'installable': True,
} }

7
account_bank_statement_import_ofx/account_bank_statement_import_ofx.py

@ -14,8 +14,7 @@ _logger = logging.getLogger(__name__)
try: try:
from ofxparse import OfxParser as ofxparser from ofxparse import OfxParser as ofxparser
except ImportError: except ImportError:
_logger.error("OFX parser unavailable because the `ofxparse` Python library cannot be found."
"It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.")
_logger.warn("ofxparse not found, OFX parsing disabled.")
ofxparser = None ofxparser = None
class account_bank_statement_import(osv.TransientModel): class account_bank_statement_import(osv.TransientModel):
@ -63,7 +62,7 @@ class account_bank_statement_import(osv.TransientModel):
vals_bank_statement = { vals_bank_statement = {
'name': ofx.account.routing_number, 'name': ofx.account.routing_number,
'transactions': transactions, 'transactions': transactions,
'balance_start': float(ofx.account.statement.balance) - total_amt,
'balance_end_real': float(ofx.account.statement.balance),
'balance_start': ofx.account.statement.balance,
'balance_end_real': float(ofx.account.statement.balance) + total_amt,
} }
return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement] return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement]

6
account_bank_statement_import_ofx/tests/test_import_bank_statement.py

@ -25,8 +25,8 @@ class TestOfxFile(TransactionCase):
bank_statement_id = self.statement_import_model.create(cr, uid, dict( bank_statement_id = self.statement_import_model.create(cr, uid, dict(
data_file=ofx_file, data_file=ofx_file,
)) ))
self.statement_import_model.import_file(cr, uid, [bank_statement_id], {'allow_auto_create_journal': True})
self.statement_import_model.import_file(cr, uid, [bank_statement_id])
statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0]
bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
self.assertEquals(bank_st_record.balance_start, 2516.56)
self.assertEquals(bank_st_record.balance_end_real, 2156.56)
self.assertEquals(bank_st_record.balance_start, 2156.56)
self.assertEquals(bank_st_record.balance_end_real, 1796.56)
Loading…
Cancel
Save