-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from annuaire-entreprises-data-gouv-fr/fix-regressions
- Loading branch information
Showing
5 changed files
with
48 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
def get_nom_commercial(siege): | ||
return siege.get("nom_commercial", None) if siege else None | ||
|
||
|
||
def format_nom_complet( | ||
nom_complet, | ||
sigle=None, | ||
nom_commercial_siege=None, | ||
denomination_usuelle_1=None, | ||
denomination_usuelle_2=None, | ||
denomination_usuelle_3=None, | ||
): | ||
"""Add `denomination usuelle` fields and `sigle` to `nom_complet`.""" | ||
all_denomination_usuelle = "" | ||
for item in [ | ||
denomination_usuelle_1, | ||
denomination_usuelle_2, | ||
denomination_usuelle_3, | ||
]: | ||
if item: | ||
all_denomination_usuelle += f"{item} " | ||
if all_denomination_usuelle: | ||
nom_complet = f"{nom_complet} ({all_denomination_usuelle.strip()})" | ||
if not nom_complet: | ||
return None | ||
|
||
# Handle denomination usuelle | ||
if nom_commercial_siege: | ||
denomination = nom_commercial_siege | ||
else: | ||
denomination = " ".join( | ||
filter( | ||
None, | ||
[ | ||
denomination_usuelle_1, | ||
denomination_usuelle_2, | ||
denomination_usuelle_3, | ||
], | ||
) | ||
) | ||
|
||
# Add denomination to nom_complet if it exists | ||
if denomination: | ||
nom_complet += f" ({denomination.strip()})" | ||
|
||
# Add sigle if it exists | ||
if sigle: | ||
nom_complet = f"{nom_complet} ({sigle})" | ||
if nom_complet: | ||
return nom_complet.upper() | ||
# if nom_complet is null | ||
return None | ||
nom_complet += f" ({sigle})" | ||
|
||
return nom_complet.upper() |