Use transactions parsing tools for Compte Courant
This commit is contained in:
parent
9e6fb48dee
commit
bdaebf89bc
1 changed files with 16 additions and 16 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
@ -24,19 +25,21 @@ from datetime import date
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.bank import Transaction
|
from weboob.capabilities.bank import Transaction
|
||||||
from weboob.capabilities.base import NotAvailable
|
from weboob.capabilities.base import NotAvailable
|
||||||
|
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AccountHistoryCC', 'AccountHistoryLA']
|
__all__ = ['AccountHistoryCC', 'AccountHistoryLA']
|
||||||
|
|
||||||
|
|
||||||
class AccountHistoryCC(BasePage):
|
class TransactionCC(FrenchTransaction):
|
||||||
types = {
|
PATTERNS = [(re.compile(u'^retrait dab (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{4}) (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL),
|
||||||
'Carte achat': Transaction.TYPE_CARD,
|
(re.compile(u'^carte (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{4}) (?P<text>.*)'), Transaction.TYPE_CARD),
|
||||||
'Virement': Transaction.TYPE_TRANSFER,
|
(re.compile(u'^virement ((sepa emis vers|recu)?) (?P<text>.*)'), Transaction.TYPE_TRANSFER),
|
||||||
'Carte retrait': Transaction.TYPE_WITHDRAWAL,
|
(re.compile(u'^prelevement (?P<text>.*)'), Transaction.TYPE_ORDER),
|
||||||
u'Prélèvement': Transaction.TYPE_ORDER,
|
]
|
||||||
'Autre': Transaction.TYPE_UNKNOWN,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
class AccountHistoryCC(BasePage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
self.transactions = []
|
self.transactions = []
|
||||||
table = self.document.findall('//tbody')[0]
|
table = self.document.findall('//tbody')[0]
|
||||||
|
|
@ -44,16 +47,13 @@ class AccountHistoryCC(BasePage):
|
||||||
for tr in table.xpath('tr'):
|
for tr in table.xpath('tr'):
|
||||||
id = i
|
id = i
|
||||||
texte = tr.text_content().split('\n')
|
texte = tr.text_content().split('\n')
|
||||||
op = Transaction(id)
|
op = TransactionCC(id)
|
||||||
op.label = texte[2]
|
op.parse(date = date(*reversed([int(x) for x in texte[0].split('/')])),
|
||||||
op.raw = texte[2] # nothing to parse
|
raw = texte[2])
|
||||||
op.date = date(*reversed([int(x) for x in texte[0].split('/')]))
|
# force the use of website category
|
||||||
op.category = texte[4]
|
op.category = texte[4]
|
||||||
op.type = self.types.get(texte[4], Transaction.TYPE_UNKNOWN)
|
|
||||||
|
|
||||||
amount = texte[5].replace('\t', '').strip().replace(u'€', '').\
|
op.amount = Decimal(op.clean_amount(texte[5]))
|
||||||
replace(',', '.').replace(u'\xa0', u'')
|
|
||||||
op.amount = Decimal(amount)
|
|
||||||
|
|
||||||
self.transactions.append(op)
|
self.transactions.append(op)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue