Browse Source

[ENH] Support both old and new style parse results.

pull/15/head
Ronald Portier (Therp BV) 10 years ago
parent
commit
aaf375018a
  1. 10
      account_bank_statement_import/account_bank_statement_import.py
  2. 8
      account_bank_statement_import_ofx/account_bank_statement_import_ofx.py
  3. 4
      account_bank_statement_import_qif/account_bank_statement_import_qif.py

10
account_bank_statement_import/account_bank_statement_import.py

@ -77,7 +77,15 @@ class AccountBankStatementImport(models.TransientModel):
# The appropriate implementation module returns the required data
statement_ids = []
notifications = []
statements = self._parse_file(data_file)
parse_result = self._parse_file(data_file)
# Check for old version result, with separate currency and account
if isinstance(parse_result, tuple) and len(parse_result) == 3:
(currency_code, account_number, statements) = parse_result
for stmt_vals in statements:
stmt_vals['currency_code'] = currency_code
stmt_vals['account_number'] = account_number
else:
statements = parse_result
# Check raw data:
self._check_parsed_data(statements)
# Import all statements:

8
account_bank_statement_import_ofx/account_bank_statement_import_ofx.py

@ -67,12 +67,12 @@ class AccountBankStatementImport(models.TransientModel):
raise Warning(_("The following problem occurred during import. "
"The file might not be valid.\n\n %s" % e.message))
return [{
'currency_code': ofx.account.statement.currency,
'account_number': ofx.account.number,
vals_bank_statement = {
'name': ofx.account.routing_number,
'transactions': transactions,
'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]

4
account_bank_statement_import_qif/account_bank_statement_import_qif.py

@ -84,9 +84,7 @@ class AccountBankStatementImport(models.TransientModel):
'not correctly formed.'))
vals_bank_statement.update({
'currency_code': None,
'account_number': None,
'balance_end_real': total,
'transactions': transactions
})
return [vals_bank_statement]
return None, None, [vals_bank_statement]
Loading…
Cancel
Save