From e5cffb59e2b98d8513f38e39f8f20a3ea6b850b5 Mon Sep 17 00:00:00 2001 From: Maxime Gasselin Date: Tue, 29 Jan 2019 16:24:34 +0100 Subject: [PATCH] =?UTF-8?q?[palatine]=20Handle=20"R=C3=A9capitulatif=20de?= =?UTF-8?q?=20frais=20bancaires"=20document?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's an annual summary consequenlty we give it the last day of the year. closes: 34998@sibi --- modules/caissedepargne/pages.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index 48fcb5e14c..f2ddc83b15 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -1384,14 +1384,23 @@ class iter_documents(ListElement): class item(ItemElement): klass = Document - obj_label = Format('%s %s', CleanText('./preceding::h3[1]'), CleanText('./span')) - obj_date = Date(CleanText('./span'), dayfirst=True) obj_type = DocumentTypes.OTHER obj_format = 'pdf' obj_url = Regexp(Link('.'), r'WebForm_PostBackOptions\("(\S*)"') - obj_id = Format('%s_%s_%s', Env('sub_id'), CleanText('./span', symbols='/'), Regexp(Field('url'), r'ctl(.*)')) + obj_id = Format('%s_%s_%s', Env('sub_id'), CleanText('./span', symbols='/', replace=[(' ', '_')]), Regexp(Field('url'), r'ctl(.*)')) obj__event_id = Regexp(Attr('.', 'onclick'), r"val\('(.*)'\);", default=None) + def obj_label(self): + if 'Récapitulatif de frais bancaires' in CleanText('./span')(self.el): + return CleanText('./span')(self.el) + return Format('%s %s', CleanText('./preceding::h3[1]'), CleanText('./span'))(self.el) + + def obj_date(self): + if 'Récapitulatif de frais bancaires' in CleanText('./span')(self.el): + year = Regexp(CleanText('./span'), r'(\d{4})')(self.el) + return Date(dayfirst=True).filter('31/12/%s' %year) + return Date(CleanText('./span'), dayfirst=True)(self.el) + def download_document(self, document): form = self.get_form(id='main') form['m_ScriptManager'] = document.url -- GitLab