use datetime.date objects and transform coming labels
This commit is contained in:
parent
70a3effae4
commit
0278af175f
3 changed files with 25 additions and 8 deletions
|
|
@ -16,6 +16,9 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.bank import Operation
|
from weboob.capabilities.bank import Operation
|
||||||
|
|
||||||
|
|
@ -24,6 +27,12 @@ __all__ = ['AccountComing']
|
||||||
|
|
||||||
|
|
||||||
class AccountComing(BasePage):
|
class AccountComing(BasePage):
|
||||||
|
LABEL_PATTERNS = [('^FACTURECARTEDU(?P<dd>\d{2})(?P<mm>\d{2})(?P<yy>\d{2})(?P<text>.*)',
|
||||||
|
u'CB %(yy)s-%(mm)s-%(dd)s: %(text)s'),
|
||||||
|
('^PRELEVEMENT(?P<text>.*)', 'Order: %(text)s'),
|
||||||
|
('^ECHEANCEPRET(?P<text>.*)', u'Loan payment n°%(text)s'),
|
||||||
|
]
|
||||||
|
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
self.operations = []
|
self.operations = []
|
||||||
|
|
||||||
|
|
@ -32,7 +41,8 @@ class AccountComing(BasePage):
|
||||||
tds = tr.findall('td')
|
tds = tr.findall('td')
|
||||||
if len(tds) != 3:
|
if len(tds) != 3:
|
||||||
continue
|
continue
|
||||||
date = tds[0].getchildren()[0].attrib.get('name', '')
|
d = tds[0].getchildren()[0].attrib.get('name', '')
|
||||||
|
d = date(int(d[0:4]), int(d[4:6]), int(d[6:8]))
|
||||||
label = u''
|
label = u''
|
||||||
label += tds[1].text or u''
|
label += tds[1].text or u''
|
||||||
label = label.replace(u'\xa0', u'')
|
label = label.replace(u'\xa0', u'')
|
||||||
|
|
@ -41,10 +51,16 @@ class AccountComing(BasePage):
|
||||||
if child.tail: label += child.tail
|
if child.tail: label += child.tail
|
||||||
if tds[1].tail: label += tds[1].tail
|
if tds[1].tail: label += tds[1].tail
|
||||||
label = label.strip()
|
label = label.strip()
|
||||||
|
|
||||||
|
for pattern, text in self.LABEL_PATTERNS:
|
||||||
|
m = re.match(pattern, label)
|
||||||
|
if m:
|
||||||
|
label = text % m.groupdict()
|
||||||
|
|
||||||
amount = tds[2].text.replace('.', '').replace(',', '.')
|
amount = tds[2].text.replace('.', '').replace(',', '.')
|
||||||
|
|
||||||
operation = Operation(len(self.operations))
|
operation = Operation(len(self.operations))
|
||||||
operation.date = date
|
operation.date = d
|
||||||
operation.label = label
|
operation.label = label
|
||||||
operation.amount = float(amount)
|
operation.amount = float(amount)
|
||||||
self.operations.append(operation)
|
self.operations.append(operation)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.bank import Operation
|
from weboob.capabilities.bank import Operation
|
||||||
|
|
||||||
|
|
@ -32,8 +34,7 @@ class AccountHistory(BasePage):
|
||||||
tds = tr.findall('td')
|
tds = tr.findall('td')
|
||||||
if len(tds) != 4:
|
if len(tds) != 4:
|
||||||
continue
|
continue
|
||||||
date = u''
|
d = date(*reversed([int(x) for x in tds[0].text.split('/')]))
|
||||||
date = tds[0].text
|
|
||||||
label = u''
|
label = u''
|
||||||
label += tds[1].text
|
label += tds[1].text
|
||||||
label = label.replace(u'\xa0', u'')
|
label = label.replace(u'\xa0', u'')
|
||||||
|
|
@ -51,7 +52,7 @@ class AccountHistory(BasePage):
|
||||||
else:
|
else:
|
||||||
operation.amount = - float(amount)
|
operation.amount = - float(amount)
|
||||||
|
|
||||||
operation.date = date
|
operation.date = d
|
||||||
operation.label = label
|
operation.label = label
|
||||||
self.operations.append(operation)
|
self.operations.append(operation)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime, date
|
||||||
|
|
||||||
from .base import IBaseCap, CapBaseObject
|
from .base import IBaseCap, CapBaseObject
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Account(CapBaseObject):
|
||||||
class Operation(CapBaseObject):
|
class Operation(CapBaseObject):
|
||||||
def __init__(self, id):
|
def __init__(self, id):
|
||||||
CapBaseObject.__init__(self, id)
|
CapBaseObject.__init__(self, id)
|
||||||
self.add_field('date', (basestring,datetime))
|
self.add_field('date', (basestring,datetime,date))
|
||||||
self.add_field('label', unicode)
|
self.add_field('label', unicode)
|
||||||
self.add_field('amount', float)
|
self.add_field('amount', float)
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ class Transfer(CapBaseObject):
|
||||||
def __init__(self, id):
|
def __init__(self, id):
|
||||||
CapBaseObject.__init__(self, id)
|
CapBaseObject.__init__(self, id)
|
||||||
self.add_field('amount', float)
|
self.add_field('amount', float)
|
||||||
self.add_field('date', (basestring,datetime))
|
self.add_field('date', (basestring,datetime,date))
|
||||||
self.add_field('origin', (int,long,basestring))
|
self.add_field('origin', (int,long,basestring))
|
||||||
self.add_field('recipient', (int,long,basestring))
|
self.add_field('recipient', (int,long,basestring))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue