Commit 6fde01ae authored by Damien Mat's avatar Damien Mat Committed by Vincent A

[boursorama] Feat: add card summaries on card accounts

When CSV is not availble (most cases),
we get card_summaries transactions on parent accounts history page.
In order to do that, and get as well summary details,
we now start from parent account history page,
parse card_summaries,
and follow detail page for each one.
parent 0ffb9506
......@@ -35,7 +35,7 @@ from import (
Account, AccountNotFound, TransferError, TransferInvalidAmount,
TransferInvalidEmitter, TransferInvalidLabel, TransferInvalidRecipient,
AddRecipientStep, Rate, TransferBankError, AccountOwnership, RecipientNotFound,
AddRecipientTimeout, TransferDateType, Emitter,
AddRecipientTimeout, TransferDateType, Emitter, TransactionType,
from weboob.capabilities.base import empty, find_object
from import Advisor
......@@ -51,7 +51,7 @@ from .pages import (
TransferAccounts, TransferRecipients, TransferCharac, TransferConfirm, TransferSent,
AddRecipientPage, StatusPage, CardHistoryPage, CardCalendarPage, CurrencyListPage, CurrencyConvertPage,
AccountsErrorPage, NoAccountPage, TransferMainPage, PasswordPage, NewTransferRecipients,
NewTransferAccounts, CardSumDetailPage,
from .transfer_pages import TransferListPage, TransferInfoPage
......@@ -96,6 +96,7 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
budget_transactions = URL('/budget/compte/(?P<webid>.*)/mouvements.*', HistoryPage)
other_transactions = URL('/compte/cav/(?P<webid>.*)/mouvements.*', HistoryPage)
saving_transactions = URL('/compte/epargne/csl/(?P<webid>.*)/mouvements.*', HistoryPage)
card_summary_detail_transactions = URL(r'/contre-valeurs-operation/.*', CardSumDetailPage)
saving_pep = URL('/compte/epargne/pep', PEPPage)
incident = URL('/compte/cav/(?P<webid>.*)/mes-incidents.*', IncidentPage)
......@@ -456,6 +457,25 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
for transaction in
yield transaction
def get_html_past_card_transactions(self, account):
""" Get card transactions from parent account page """
self.otp_location('%s/mouvements' % account.parent.url.rstrip('/'))
for tr in
# get card summaries
if (
tr.type == TransactionType.CARD_SUMMARY
and account.number in tr.label # in case of several cards per parent account
tr.amount = - tr.amount
yield tr
# for each summaries, get detailed transactions
for detail_tr in =
yield detail_tr
# Note: Checking accounts have a 'Mes prélèvements à venir' tab,
# but these transactions have no date anymore so we ignore them.
......@@ -497,8 +517,8 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
if self.get_card_transaction(coming, tr):
yield tr
for tr in
if self.get_card_transaction(coming, tr):
if not coming:
for tr in self.get_html_past_card_transactions(account):
yield tr
def get_invest_transactions(self, account, coming):
......@@ -700,6 +700,11 @@ class HistoryPage(LoggedPage, HTMLPage):
return date
def obj__card_sum_detail_link(self):
if Field('type')(self) == Transaction.TYPE_CARD_SUMMARY:
return Attr('.//div', 'data-action-url')(self.el)
return NotAvailable
def validate(self, obj):
# TYPE_DEFERRED_CARD transactions are already present in the card history
# so we only return TYPE_DEFERRED_CARD for the coming:
......@@ -740,6 +745,25 @@ class HistoryPage(LoggedPage, HTMLPage):
return Link('//a[contains(text(), "calendrier")]')(self.doc)
class CardSumDetailPage(LoggedPage, HTMLPage):
class iter_history(ListElement):
item_xpath = '//li[contains(@class, "deffered")]' # this quality website's got all-you-can-eat typos!
class item(ItemElement):
klass = Transaction
obj_amount = CleanDecimal.French('.//div[has-class("list-operation-item__amount")]')
obj_raw = Transaction.Raw(CleanText('.//div[has-class("list-operation-item__label-name")]'))
obj_id = Attr('.', 'data-id')
obj__is_coming = False
def obj_type(self):
# to override CARD typing done by obj.raw
return Transaction.TYPE_DEFERRED_CARD
class CardHistoryPage(LoggedPage, CsvPage):
ENCODING = 'latin-1'
FMTPARAMS = {'delimiter': str(';')}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment