-
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.
[PAYLOAD]Use
nom commercial
(siege) in ul nom complet
Merge pull request #403 from annuaire-entreprises-data-gouv-fr/update-denomination
- Loading branch information
Showing
3 changed files
with
46 additions
and
29 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
42 changes: 27 additions & 15 deletions
42
aio/aio-proxy/aio_proxy/response/formatters/nom_complet.py
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,36 @@ | ||
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() |