diff --git a/modules/ing/browser.py b/modules/ing/browser.py index 6c6a35aa..6b4f67da 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . - +import hashlib from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword from .pages import AccountsList, LoginPage, LoginPage2, \ @@ -99,7 +99,11 @@ class Ing(BaseBrowser): else: raise NotImplementedError() while 1: + hashlist = [] for transaction in self.page.get_transactions(): + while transaction.id in hashlist: + transaction.id = hashlib.md5(transaction.id + "1") + hashlist.append(transaction.id) yield transaction if self.page.islast(): return diff --git a/modules/ing/pages/account_history.py b/modules/ing/pages/account_history.py index 077af0ae..26b47857 100644 --- a/modules/ing/pages/account_history.py +++ b/modules/ing/pages/account_history.py @@ -18,6 +18,7 @@ # along with weboob. If not, see . import re +import hashlib from decimal import Decimal from datetime import date @@ -45,19 +46,20 @@ class AccountHistory(BasePage): def get_transactions(self): table = self.document.findall('//tbody')[0] - i = 1 for tr in table.xpath('tr'): - id = i - op = Transaction(id) textdate = tr.find('td[@class="op_date"]').text_content() textraw = tr.find('td[@class="op_label"]').text_content() + # The id will be rewrite + op = Transaction(1) + amount = op.clean_amount(tr.find('td[@class="op_amount"]').text_content()) + id = hashlib.md5(textdate + textraw.encode('utf-8') + amount.encode('utf-8')).hexdigest() + op.id = id op.parse(date = date(*reversed([int(x) for x in textdate.split('/')])), raw = textraw) # force the use of website category op.category = unicode(tr.find('td[@class="op_type"]').text) - op.amount = Decimal(op.clean_amount(tr.find('td[@class="op_amount"]').text_content())) - i += 1 + op.amount = Decimal(amount) yield op