|
@ -3,7 +3,7 @@ |
|
|
import logging |
|
|
import logging |
|
|
import StringIO |
|
|
import StringIO |
|
|
|
|
|
|
|
|
from odoo import api, models, fields, _ |
|
|
|
|
|
|
|
|
from odoo import api, models, _ |
|
|
from odoo.exceptions import UserError |
|
|
from odoo.exceptions import UserError |
|
|
from odoo.tools import float_is_zero |
|
|
from odoo.tools import float_is_zero |
|
|
|
|
|
|
|
@ -65,30 +65,23 @@ class AccountBankStatementImport(models.TransientModel): |
|
|
|
|
|
|
|
|
transactions = [] |
|
|
transactions = [] |
|
|
total_amt = 0.00 |
|
|
total_amt = 0.00 |
|
|
start_date = end_date = False |
|
|
|
|
|
try: |
|
|
try: |
|
|
for transaction in ofx.account.statement.transactions: |
|
|
for transaction in ofx.account.statement.transactions: |
|
|
vals = self._prepare_ofx_transaction_line(transaction) |
|
|
vals = self._prepare_ofx_transaction_line(transaction) |
|
|
if vals: |
|
|
if vals: |
|
|
transactions.append(vals) |
|
|
transactions.append(vals) |
|
|
total_amt += vals['amount'] |
|
|
total_amt += vals['amount'] |
|
|
tdate = fields.Date.to_string(vals['date']) |
|
|
|
|
|
if not start_date or tdate < start_date: |
|
|
|
|
|
start_date = tdate |
|
|
|
|
|
if not end_date or tdate > end_date: |
|
|
|
|
|
end_date = tdate |
|
|
|
|
|
except Exception, e: |
|
|
except Exception, e: |
|
|
raise UserError(_( |
|
|
raise UserError(_( |
|
|
"The following problem occurred during import. " |
|
|
"The following problem occurred during import. " |
|
|
"The file might not be valid.\n\n %s") % e.message) |
|
|
"The file might not be valid.\n\n %s") % e.message) |
|
|
|
|
|
|
|
|
|
|
|
balance = float(ofx.account.statement.balance) |
|
|
vals_bank_statement = { |
|
|
vals_bank_statement = { |
|
|
'name': _('Account %s %s > %s') % ( |
|
|
|
|
|
ofx.account.number, start_date, end_date), |
|
|
|
|
|
|
|
|
'name': ofx.account.number, |
|
|
'transactions': transactions, |
|
|
'transactions': transactions, |
|
|
'balance_start': ofx.account.statement.balance, |
|
|
|
|
|
'balance_end_real': |
|
|
|
|
|
float(ofx.account.statement.balance) + total_amt, |
|
|
|
|
|
|
|
|
'balance_start': balance - total_amt, |
|
|
|
|
|
'balance_end_real': balance, |
|
|
} |
|
|
} |
|
|
return ofx.account.statement.currency, ofx.account.number, [ |
|
|
return ofx.account.statement.currency, ofx.account.number, [ |
|
|
vals_bank_statement] |
|
|
vals_bank_statement] |