diff --git a/weboob/capabilities/bank.py b/weboob/capabilities/bank.py index 8659ad63..8f802c3c 100644 --- a/weboob/capabilities/bank.py +++ b/weboob/capabilities/bank.py @@ -20,6 +20,7 @@ import re from datetime import date, datetime +from binascii import crc32 from .base import CapBaseObject, Field, StringField, DateField, DecimalField, IntField, UserError from .collection import ICapCollection @@ -147,6 +148,22 @@ class Transaction(CapBaseObject): return "" % (self.date, label, self.amount) + def unique_id(self, seen=None, account_id=None): + crc = crc32(str(self.date)) + crc = crc32(str(self.amount), crc) + crc = crc32(self.label.encode("utf-8"), crc) + + if account_id is not None: + crc = crc32(str(account_id), crc) + + if seen is not None: + while crc in seen: + crc = crc32("*", crc) + + seen.add(crc) + + return "%08x" % (crc & 0xffffffff) + class Investment(CapBaseObject): """