diff --git a/modules/boursedirect/browser.py b/modules/boursedirect/browser.py index 982a26980ee43c7fdf2bfe3459c4eb0638832de8..d46aaceeeb2598f0f8d38cea7af777dbdd5c13ca 100644 --- a/modules/boursedirect/browser.py +++ b/modules/boursedirect/browser.py @@ -41,12 +41,12 @@ class BoursedirectBrowser(LoginBrowser): password_renewal = URL(r'/fr/changer-mon-mot-de-passe', PasswordRenewalPage) home = URL(r'/fr/page/inventaire', HomePage) accounts = URL( - r'/priv/compte.php$', - r'/priv/compte.php\?nc=(?P\d+)', + r'/priv/new/compte.php$', + r'/priv/new/compte.php\?nc=(?P\d+)', r'/priv/listeContrats.php\?nc=(?P\d+)', AccountsPage ) - history = URL(r'/priv/compte.php\?ong=3&nc=(?P\d+)', HistoryPage) + history = URL(r'/priv/new/historique-de-compte.php\?ong=3&nc=(?P\d+)', HistoryPage) portfolio = URL(r'/fr/page/portefeuille', PortfolioPage) pre_invests = URL(r'/priv/portefeuille-TR.php\?nc=(?P\d+)') invests = URL(r'/streaming/compteTempsReelCK.php\?stream=0', InvestPage) diff --git a/modules/boursedirect/pages.py b/modules/boursedirect/pages.py index a88e2069884f352b53aa050d654fecf5278ee979..37c45853dfc2e85f7ae8618962791d4c8d4361d4 100644 --- a/modules/boursedirect/pages.py +++ b/modules/boursedirect/pages.py @@ -337,16 +337,39 @@ class fill_market_order(ItemElement): class HistoryPage(BasePage): @method - class iter_history(ListElement): - item_xpath = '//table[@class="datas retour"]//tr[@class="row1" or @class="row2"]' + class iter_history(TableElement): + item_xpath = '//table[contains(@class,"datas retour")]//tr[@class="row1" or @class="row2"]' + head_xpath = '//table[contains(@class,"datas retour")]//th' + + col_rdate = 'Date opération' + col_date = 'Date affectation' + col_investment_label = 'Libellé' + col_label = 'Opération' + col_investment_quantity = 'Qté' + col_investment_unitvalue = 'Cours' + col_amount = 'Montant net' class item(ItemElement): klass = Transaction - obj_date = Date(CleanText('./td[2]'), dayfirst=True) # Date affectation - obj_rdate = Date(CleanText('./td[1]'), dayfirst=True) # Date opération - obj_label = Format('%s - %s', CleanText('./td[3]/a'), CleanText('./td[4]')) - obj_amount = CleanDecimal.French('./td[7]') + obj_date = Date(CleanText(TableCell('date')), dayfirst=True) # Date affectation + obj_rdate = Date(CleanText(TableCell('rdate')), dayfirst=True) # Date opération + obj_label = Format('%s - %s', CleanText(TableCell('investment_label')), CleanText(TableCell('label'))) + obj_amount = CleanDecimal.French(TableCell('amount')) + + def obj_investments(self): + if CleanDecimal.French(TableCell('unitvalue'), default=None) is None: + return NotAvailable + + investment = Investment() + investment.label = CleanText(TableCell('investment_label'))(self) + investment.valuation = CleanDecimal.French(TableCell('amount'))(self) + investment.unitvalue = CleanDecimal.French( + TableCell('investment_unitvalue'), + default=NotAvailable + )(self) + investment.quantity = CleanDecimal.French(TableCell('investment_quantity'), default=NotAvailable)(self) + return [investment] class IsinPage(HTMLPage):