Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
# Copyright(C) 2019 Antoine BOSSY
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.browser.elements import method, ItemElement, ListElement, SkipItem
from weboob.browser.filters.standard import CleanDecimal, CleanText, Field, Format, Date
from weboob.browser.filters.html import Attr
from weboob.browser.pages import HTMLPage, LoggedPage
from weboob.capabilities.bank import Account, Transaction
from weboob.capabilities.base import NotAvailable
class LoginPage(HTMLPage):
def login(self, login, password):
form = self.get_form('//form[@id="frmMain"]')
form['UserLogin'] = login
form['UserPass'] = password
form.submit()
class ProfilePage(HTMLPage):
pass
class AccountsPage(LoggedPage, HTMLPage):
def go_to_transaction_page(self, page):
form = self.get_form('//form[@id="frmMain"]')
form['%s.x' % page] = 1
form['%s.y' % page] = 1
form.submit()
@method
class get_accounts(ListElement):
item_xpath = '//tr[has-class("ItemH23")]'
class item(ItemElement):
klass = Account
obj_id = CleanText('./td[position()=2]')
obj_balance = CleanDecimal('./td[position()=6]', replace_dots=True)
obj_label = Format('Millésime %s', Field('id'))
obj_number = Field('id')
obj_currency = 'EUR'
obj__page = Attr('./td//input', 'name')
@method
class get_transactions(ListElement):
item_xpath = '//tr[has-class("ItemH23")]'
class item(ItemElement):
klass = Transaction
def obj_date(self):
maybe_date = CleanText('./td[position()=2]')(self)
if maybe_date == '-':
raise SkipItem()
return Date(CleanText('./td[position()=2]'), dayfirst=True)(self)
obj_id = CleanText('./td[position()=3]')
def obj_amount(self):
amount = CleanDecimal('./td[position()=4]', replace_dots=True,
default=NotAvailable)(self)
if amount is NotAvailable:
return CleanDecimal('./td[position()=5]', replace_dots=True)(self)
return amount * -1
obj_currency = 'EUR'
def obj_label(self):
label = CleanText('./td[position()=6]')(self)
if label == '-':
return CleanText('./td[position()=7]')(self)
return label
obj_raw = Field('label')