From e63b54bdea1df6d09d5d3294ba49a7a9dfb8821f Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Tue, 20 Nov 2018 18:46:42 +0100 Subject: [PATCH] [hsbc] Revised account typing using Regexps The account typing was sometimes biaised by the person's name: for example, if the label is "Compte Mr Pelletier", it will find "pel" in the label and therefore type it as a "PEL". The Regexp looking for actual words should reduce wrong account typing. Closes: 8229@zendesk --- modules/hsbc/pages/account_pages.py | 60 +++++++++++++++-------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/modules/hsbc/pages/account_pages.py b/modules/hsbc/pages/account_pages.py index e72d8544ea..71dbb72347 100644 --- a/modules/hsbc/pages/account_pages.py +++ b/modules/hsbc/pages/account_pages.py @@ -82,40 +82,42 @@ def on_load(self): class AccountsType(Filter): PATTERNS = [ - ('c.aff', Account.TYPE_CHECKING), - ('pea', Account.TYPE_PEA), - ('invest', Account.TYPE_MARKET), - ('ptf', Account.TYPE_MARKET), - ('ldd', Account.TYPE_SAVINGS), - ('cel', Account.TYPE_SAVINGS), - ('pel', Account.TYPE_SAVINGS), - ('livret', Account.TYPE_SAVINGS), - ('livjeu', Account.TYPE_SAVINGS), - ('compte', Account.TYPE_CHECKING), - ('cpte', Account.TYPE_CHECKING), - ('scpi', Account.TYPE_MARKET), - ('account', Account.TYPE_CHECKING), - ('pret', Account.TYPE_LOAN), - ('vie', Account.TYPE_LIFE_INSURANCE), - ('strategie patr.', Account.TYPE_LIFE_INSURANCE), - ('essentiel', Account.TYPE_LIFE_INSURANCE), - ('elysee', Account.TYPE_LIFE_INSURANCE), - ('abondance', Account.TYPE_LIFE_INSURANCE), - ('ely. retraite', Account.TYPE_LIFE_INSURANCE), - ('lae option assurance', Account.TYPE_LIFE_INSURANCE), - ('carte ', Account.TYPE_CARD), - ('business ', Account.TYPE_CARD), - ('plan assur. innovat.', Account.TYPE_LIFE_INSURANCE), - ('hsbc evol pat transf', Account.TYPE_LIFE_INSURANCE), - ('hsbc evol pat capi', Account.TYPE_CAPITALISATION), - ('bourse libre', Account.TYPE_MARKET), - ('plurival', Account.TYPE_LIFE_INSURANCE), + (r'c\.aff', Account.TYPE_CHECKING), + (r'\bssmouv\b', Account.TYPE_CHECKING), + (r'\bpea\b', Account.TYPE_PEA), + (r'invest', Account.TYPE_MARKET), + (r'\bptf\b', Account.TYPE_MARKET), + (r'\bldd\b', Account.TYPE_SAVINGS), + (r'\bcel\b', Account.TYPE_SAVINGS), + (r'\bpel\b', Account.TYPE_SAVINGS), + (r'livret', Account.TYPE_SAVINGS), + (r'livjeu', Account.TYPE_SAVINGS), + (r'csljun', Account.TYPE_SAVINGS), + (r'compte', Account.TYPE_CHECKING), + (r'cpte', Account.TYPE_CHECKING), + (r'scpi', Account.TYPE_MARKET), + (r'account', Account.TYPE_CHECKING), + (r'\bpret\b', Account.TYPE_LOAN), + (r'\bvie\b', Account.TYPE_LIFE_INSURANCE), + (r'strategie patr.', Account.TYPE_LIFE_INSURANCE), + (r'essentiel', Account.TYPE_LIFE_INSURANCE), + (r'elysee', Account.TYPE_LIFE_INSURANCE), + (r'abondance', Account.TYPE_LIFE_INSURANCE), + (r'ely\. retraite', Account.TYPE_LIFE_INSURANCE), + (r'lae option assurance', Account.TYPE_LIFE_INSURANCE), + (r'carte ', Account.TYPE_CARD), + (r'business ', Account.TYPE_CARD), + (r'plan assur\. innovat\.', Account.TYPE_LIFE_INSURANCE), + (r'hsbc evol pat transf', Account.TYPE_LIFE_INSURANCE), + (r'hsbc evol pat capi', Account.TYPE_CAPITALISATION), + (r'bourse libre', Account.TYPE_MARKET), + (r'plurival', Account.TYPE_LIFE_INSURANCE), ] def filter(self, label): label = label.lower() for pattern, type in self.PATTERNS: - if pattern in label: + if re.search(pattern, label): return type return Account.TYPE_UNKNOWN -- GitLab