use raw label to calculate unique_id

This commit is contained in:
Romain Bignon 2013-11-15 15:46:36 +01:00
commit cd0f61d078

View file

@ -20,6 +20,7 @@
from datetime import date, datetime from datetime import date, datetime
from binascii import crc32 from binascii import crc32
import re
from .base import CapBaseObject, Field, StringField, DateField, DecimalField, IntField, UserError, Currency from .base import CapBaseObject, Field, StringField, DateField, DecimalField, IntField, UserError, Currency
from .collection import ICapCollection from .collection import ICapCollection
@ -112,7 +113,7 @@ class Transaction(CapBaseObject):
def unique_id(self, seen=None, account_id=None): def unique_id(self, seen=None, account_id=None):
crc = crc32(str(self.date)) crc = crc32(str(self.date))
crc = crc32(str(self.amount), crc) crc = crc32(str(self.amount), crc)
crc = crc32(self.label.encode("utf-8"), crc) crc = crc32(re.sub('[ ]+', ' ', self.raw.encode("utf-8")), crc)
if account_id is not None: if account_id is not None:
crc = crc32(str(account_id), crc) crc = crc32(str(account_id), crc)