Skip to content

Employeur : Correctif de la logique Convergence ACI (PHC CVG) pour les antennes [GEN-2411]#6025

Merged
dejafait merged 5 commits into
masterfrom
dejafait/fix_phc_cvg_for_antennas
May 7, 2025
Merged

Employeur : Correctif de la logique Convergence ACI (PHC CVG) pour les antennes [GEN-2411]#6025
dejafait merged 5 commits into
masterfrom
dejafait/fix_phc_cvg_for_antennas

Conversation

@dejafait

Copy link
Copy Markdown
Contributor

🤔 Pourquoi ?

Le dispositif Convergence ACI s'applique actuellement aux entreprises dont le SIRET fait partie d'une liste blanche.

Le SIRET de leurs antennes ne fait a priori pas partie de cette liste blanche du coup elles ne sont pas considérées comme PHC CVG, ce qui cause une frustration légitime.

🍰 Comment ?

  • Un refacto DRY de la logique antenne/parent, qui retouche à du code de Pilotage en passant.
  • Un refacto DRY de la logique PHC CVG qui touche aussi à Pilotage.
  • Le correctif lui-même.

Revue

  • Tonial qui était au tout début la discussion.
  • Rsebille pour le refacto côté Pilotage.

@dejafait dejafait added the modifié Modifié dans le changelog. label Apr 24, 2025
@dejafait dejafait self-assigned this Apr 24, 2025
@dejafait dejafait changed the title Employeur : Correctif de la logique Convergence ACI (PHC CVG) pour les antennes Employeur : Correctif de la logique Convergence ACI (PHC CVG) pour les antennes [GEN-2411] Apr 24, 2025
@notion-workspace

Copy link
Copy Markdown

@dejafait
dejafait requested review from rsebille and tonial April 24, 2025 12:45
Comment thread itou/companies/enums.py Outdated
choices.remove(cls.FIXED_TERM_I_CVG)

if kind == CompanyKind.ACI and aci_convergence:
if aci_convergence:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Réflexion en passant, mais je me demande si la logique de ces contrats ne devrait pas être remonté dans choices_for_company() car ce n'est pas lié au type de la SIAE mais spécifique à certaines et vu qu'on ne peux le savoir qu'avec .is_aci_convergence donc un objet Company() ça peut être bien de séparer ça aussi dans le code.

Comment thread itou/companies/models.py
Comment on lines +479 to +493
@property
def official_company(self):
"""
Return the official authoritative company (e.g. ASP SIAE) for the current company.
If the current company is an antenna, return the corresponding ASP SIAE.
If the current company is itself an ASP SIAE, return itself.
"""
if self.convention_id and self.source == self.SOURCE_USER_CREATED:
# Iterate on all() to take advantage of a potential prefetch_related upstream
# e.g. by populate_metabase_emplois.
for convention_siae in self.convention.siaes.all():
if convention_siae.source == self.SOURCE_ASP:
return convention_siae
return self

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que ça doit aussi pouvoir se factoriser ici :

@staticmethod
def siret_from_asp_source(siae):
"""
Fetch SIRET number of ASP source structure ("mother" SIAE)
"""
if siae.source != Company.SOURCE_ASP:
main_siae = Company.objects.get(convention=siae.convention, source=Company.SOURCE_ASP)
return main_siae.siret
return siae.siret

Par contre petit truc qui me grattouille l'esprit par rapport au commentaire c'est qu'en testant .convention_id on peux se retrouver à renvoyer des Company(source=SOURCE_USER _CREATED, convention=None) comme structure officielle :/.
Donc je me demande si ici il ne faudrait pas renvoyer None dans ce cas et laisser l'appelant gérer si utiliser l'entreprise courante est OK pour lui (ie. pour le pilotage) ou pas (ie. les fiches salarié).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En fait c'est mon official_company qui est mal nommé. Pour une antenne sans mère on peut parfaitement renvoyer une structure non officielle. Je vais proposer un meilleur wording.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voilà c'est refactorisé. Nouvelle revue stp @rsebille 🙏

@dejafait
dejafait requested a review from Copilot May 3, 2025 13:11

This comment was marked as off-topic.

@gip-inclusion gip-inclusion deleted a comment from Copilot AI May 5, 2025
@dejafait
dejafait force-pushed the dejafait/fix_phc_cvg_for_antennas branch from 9af660b to 542b857 Compare May 5, 2025 12:25
Comment thread itou/companies/enums.py Outdated

if kind == CompanyKind.ACI and aci_convergence:
if aci_convergence:
choices[-1:-1] = [

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arf ce [-1:-1] fait je pense autre chose que ce que l'auteur pensait (probablement append en fin de liste).

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected. C'est bien testé. Le but est de mettre à la fin juste avant le OTHER final.

@dejafait
dejafait requested a review from rsebille May 5, 2025 13:47

@rsebille rsebille left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que le commit "companies: Improve confusing property name" pourrais être fixup dans le premier "companies: Refactor official_company (DRY)" vu que cette version remplace presque tout :).

Comment thread itou/employee_record/models.py
@dejafait
dejafait force-pushed the dejafait/fix_phc_cvg_for_antennas branch from 6cd641f to b8be4c8 Compare May 7, 2025 08:43
@dejafait
dejafait force-pushed the dejafait/fix_phc_cvg_for_antennas branch from e104666 to 2eb8a8e Compare May 7, 2025 09:04
@dejafait
dejafait force-pushed the dejafait/fix_phc_cvg_for_antennas branch from 2eb8a8e to 8fe35e0 Compare May 7, 2025 09:13
@dejafait
dejafait added this pull request to the merge queue May 7, 2025
Merged via the queue into master with commit d188378 May 7, 2025
@dejafait
dejafait deleted the dejafait/fix_phc_cvg_for_antennas branch May 7, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

modifié Modifié dans le changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants