From 65c6fbe26229597935413fb8b28ec9dff41a3269 Mon Sep 17 00:00:00 2001 From: Guillaume Risbourg Date: Thu, 12 Sep 2019 14:36:11 +0200 Subject: [PATCH] [boursorama] Fix deferred card transactions date The 'dateVal' key in the CSV with the list of all the deferred transactions is now empty. The 'obj_date' for deferred cards is now determined with the list of deferred dates available on the website (calendar.ics). Fixed 'obj_bdate' to get the correct format from the CSV : YYYY-MM-DD (previously it took YYYY-DD-MM) Removed `replace_dots` for CleanDecimal in CardHistoryPage because amounts in the CSV already are in the dot format. Closes: 46551@sibi --- modules/boursorama/browser.py | 1 + modules/boursorama/pages.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/boursorama/browser.py b/modules/boursorama/browser.py index 6b27d782b4..1ccef1d7c7 100644 --- a/modules/boursorama/browser.py +++ b/modules/boursorama/browser.py @@ -356,6 +356,7 @@ def get_card_transactions(self, account, coming): if self.deferred_card_calendar is None: self.location(self.page.get_calendar_link()) + params = {} params['movementSearch[fromDate]'] = (date.today() - relativedelta(years=3)).strftime('%d/%m/%Y') params['fullSearch'] = 1 diff --git a/modules/boursorama/pages.py b/modules/boursorama/pages.py index 0aa47f1093..a34047d6a1 100644 --- a/modules/boursorama/pages.py +++ b/modules/boursorama/pages.py @@ -266,7 +266,6 @@ def condition(self): return not self.is_external() and not any(x in Field('url')(self) for x in ('automobile', 'assurance/protection', 'assurance/comptes', 'assurance/famille')) obj_label = CleanText('.//a[has-class("account--name")] | .//div[has-class("account--name")]') - obj_currency = FrenchTransaction.Currency('.//a[has-class("account--balance")]') obj_valuation_diff = Async('details') & CleanDecimal('//li[h4[text()="Total des +/- values"]]/h3 |\ //li[span[text()="Total des +/- values latentes"]]/span[has-class("overview__value")]', replace_dots=True, default=NotAvailable) @@ -306,6 +305,8 @@ def obj_id(self): raise SkipItem() return id + obj_number = obj_id + def obj_type(self): # card url is /compte/cav/xxx/carte/yyy so reverse to match "carte" before "cav" for word in Field('url')(self).lower().split('/')[::-1]: @@ -567,16 +568,19 @@ class item(ItemElement): klass = Transaction obj_raw = Transaction.Raw(Dict('label')) - obj_date = Date(Dict('dateVal'), dayfirst=True) - obj_bdate = Date(Dict('dateOp'), dayfirst=True) + obj_bdate = Date(Dict('dateOp')) + + def obj_date(self): + return self.page.browser.get_debit_date(Field('bdate')(self)) + obj__account_label = Dict('accountLabel') obj__is_coming = False def obj_amount(self): if Field('type')(self) == Transaction.TYPE_CARD_SUMMARY: # '-' so the reimbursements appear positively in the card transactions: - return -CleanDecimal(Dict('amount'), replace_dots=True)(self) - return CleanDecimal(Dict('amount'), replace_dots=True)(self) + return -CleanDecimal.US(Dict('amount'))(self) + return CleanDecimal.US(Dict('amount'))(self) def obj_rdate(self): if self.obj.rdate: -- GitLab