[weboob] Update of ICapBank

Romain Bignon romain at symlink.me
Sun Feb 26 19:33:09 CET 2012


Hi maintainers of bank modules,

As you have probably seen, I've update the ICapBank API to introduce the
following changes:

- renamed Operation class to Transaction;
- added a 'type' field into Transaction;
- added a 'raw' field into Transaction;

'type' is an enumeration which can take one of this values:

* TYPE_UNKNOWN
* TYPE_TRANSFER
* TYPE_ORDER
* TYPE_CHECK
* TYPE_DEPOSIT
* TYPE_PAYBACK
* TYPE_WITHDRAWAL
* TYPE_CARD
* TYPE_LOAN_PAYMENT
* TYPE_BANK

Currently, only my modules (BNPorc and HSBC) support it. For example, if you
read modules/hsbc/pages/accounts.py, you will see:

LABEL_PATTERNS = [(re.compile('^VIR(EMENT)? (?P<text>.*)'), Transaction.TYPE_TRANSFER,   '%(text)s'),
                  (re.compile('^PRLV (?P<text>.*)'),        Transaction.TYPE_ORDER,      '%(text)s'),
                  (re.compile('^CB (?P<text>.*)\s+(?P<dd>\d+)/(?P<mm>\d+)\s*(?P<loc>.*)'),
                                                            Transaction.TYPE_CARD,       '%(mm)s/%(dd)s: %(text)s'),
                  (re.compile('^DAB (?P<text>.*)'),         Transaction.TYPE_WITHDRAWAL, '%(text)s'),
                  (re.compile('^CHEQUE$'),                  Transaction.TYPE_CHECK,      'CHEQUE'),
                  (re.compile('^COTIS\.? (?P<text>.*)'),    Transaction.TYPE_BANK,       '%(text)s'),
                  (re.compile('^REMISE (?P<text>.*)'),      Transaction.TYPE_DEPOSIT,    '%(text)s'),
                 ]

# ...
op.raw = m.group(4)
for pattern, _type, _label in self.LABEL_PATTERNS:
    mm = pattern.match(op.raw)
    if mm:
        op.type = _type
        op.label = re.sub('[ ]+', ' ', _label % mm.groupdict()).strip()
        break

The idea is to store the raw label of the transaction into Transaction.raw, and
to parse it to determine what kind of transaction it is, store it into
Transaction.type and have a human readable label into Transaction.label.

Please, hack on your own modules to do similar things to fill 'type' and 'label'
fields.

Also, a field 'category' has been added several months ago and isn't used by all
modules. It is a text field to store the bank category if any. I don't know if
it is useful since there is now 'type', I'm open to your opinion.

Finally, I have another request. Currently, the field Transaction.date accepts
datetime.date, datetime.datetime, but also basestring types. I want to force
modules to store a datetime.date(time) object in this field.
Please, Julien (CreditMutuel), Nicolas (BP) and Xavier (CrAgr), fix this
behavior quickly!

Thanks.

Romain
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <https://lists.symlink.me/pipermail/weboob/attachments/20120226/96746e12/attachment.sig>


More information about the weboob mailing list