Coverage for invoices/utils.py: 29%
10 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-03-29 14:03 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-03-29 14:03 -0600
1import re
3COMMON_SOCIAL_REGIMES = [
4 "\sS.?\s?A.?\sDE\sC.?\s?V.?$",
5 "\sS.?\sDE\sR.?\s?L.?\s?DE\sC.?\s?V.?$",
6 "\sS.?\sDE\sR.?\s?L.?$",
7 "\sS.?\s?A.?\s?S.?\sDE\sC.?\s?V.?$",
8 "\sS.?\s?A.?\s?P.?\s?I.?\s?DE\sC.?\s?V.?$",
9 "\sA.?\s?R.?$",
10 "\sS.?\s?C.?$",
11 "\sA.?\s?C.?$",
12]
14ACCENTS = [["Á", "A"], ["É", "E"], ["Í", "I"], ["Ó", "O"], ["Ú", "U"]]
17def remove_social_regime_from_business_name(name: str) -> str:
18 """
19 Find common social regimes in name string and remove them.
20 Name in UpperCase and without accents
21 Necessary for Invoices 4.0
22 """
23 name = name.upper()
24 for social_regime_regex in COMMON_SOCIAL_REGIMES:
25 name = re.sub(social_regime_regex, "", name)
26 for accent, vowel in ACCENTS:
27 name = name.replace(accent, vowel)
28 return name