Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entreprises mandataires #1302

Merged
merged 33 commits into from
Dec 5, 2024
Merged

Entreprises mandataires #1302

merged 33 commits into from
Dec 5, 2024

Conversation

alemangui
Copy link
Collaborator

@alemangui alemangui commented Nov 19, 2024

Closes #925

Entreprises mandataires

Frontend : Désigner une entreprise mandataire

Un personne avec rôle gestionnaire peut mandater une entreprise pour faire des déclarations en leur nom. Pour ceci, une nouvelle

Screencast.from.2024-11-28.11-46-43.mp4

Le ou la gestionnaire peut aussi enlever une entreprise mandatée de la liste :

Screencast.from.2024-12-02.17-57-56.mp4

En cas d'ajout d'une entreprise qui n'existe pas chez nous :

Screencast.from.2024-12-02.17-59-22.mp4

Frontend : choisir une entreprise mandataire

Un·e déclarant·e peut choisir dans le menu déroulant une entreprise mandataire. Ceci est explicité directement dans les options :

Screencast.from.2024-11-28.11-52-17.mp4

Backend : modèles

mandated_companies dans Company

Le champ champ many-2-many mandated_companies contient les entreprises ayant droit de déclarer au nom de la compagnie.

mandated_company dans Declaration

Le champ mandated_company spécifie l'entreprise mandataire qui gère la déclaration. Lors que la déclaration n'a pas été faite par mandat, ce champ est null.

Ceci nous permet de gérer les permissions : on peut donc montrer seulement les déclarations mandatées par une entreprise à ses déclarants, et non pas la totalité de déclarations.

API

Deux endpoints RPC-like ont été ajoutés :

  • companies/int:pk/add-mandated-company/
    📧 La view correspondante envoie aussi un email aux gestionnaires de l'entreprise mandatée pour notifier de l'ajout du mandat.
  • companies/int:pk/remove-mandated-company/
    🚫 Pour l'instant il n'y a pas d'email envoyé lors de l’enlèvement d'une entreprise mandatée. Ceci pourrait être ajoute après.

Évolutions possibles

@alemangui alemangui requested a review from pletelli November 28, 2024 11:02
@alemangui alemangui marked this pull request as ready for review November 28, 2024 11:02
@hfroot
Copy link
Collaborator

hfroot commented Dec 3, 2024

Modal de confirmation avant de supprimer un mandat

T'as fait ça :)

def test_mandated_companies(self):
"""
Un·e utilisateur·ice doit voir les entreprises representées par son
entreprise - et ce avec le même rôle de déclarant
Copy link
Collaborator

Choose a reason for hiding this comment

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

can managers without a declarant role also see the companies their company represents ?
Edit to add : in general I am a little confused over the different permissions both the declarant role and the supervisor role have in relation to the companies they represent

Copy link
Collaborator Author

@alemangui alemangui Dec 3, 2024

Choose a reason for hiding this comment

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

That's correct : managers of a company have also a view on the mandated declarations. The only difference is they can't create or modify declarations.

Merci bcp pour ta vigilance ! En effet il y a une différence de droits d'accès entre superviseurs et déclarant·e·s.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix : 061fe06

reverse("api:list_create_declaration", kwargs={"user_pk": authenticate.user.id}), payload, format="json"
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should there be a test for listing declarations of the companies represented by my company?
I'm wondering what the behaviour should be if company A creates a declaration for company B and then A is removed from B's mandated_companies

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ça c'est justement un sujet un peu plus large qu'on attaquera par la suite car il s'applique aussi aux déclarant·e·s au sens large... par ex, si une compagnie enlève une personne déclarante comment on le gère ? Est-ce que cette personne est encore l'auteur·ice ? J'ai volontairement laissé ce sujet pour après.


const companiesSelectOptions = computed(() => {
return companies.value?.map((x) => ({
text: `${x.socialName} ${x.representedBy ? "(représenté par " + x.representedBy.socialName + ")" : ""}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

with a many-to-many model, how does the list work?

Copy link
Collaborator Author

@alemangui alemangui Dec 3, 2024

Choose a reason for hiding this comment

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

Un petit hack : chaque option du select a comme value une combinaison des deux IDs : celui de la compagnie et celui de l'entreprise mandatée pour la compagnie. Par exemple, une valeur avec le texte « Guichard (représenté par Prevost) » aurait comme value < id de Guichard >|< id de Prévost >, par exemple 23|94.

Lors que le v-model du select change, on parse les deux IDs et on les assigne aux vraies valeurs, donc le 23 irait dans payload.company et le 94 irait dans payload.mandatedCompany.

@alemangui alemangui requested a review from hfroot December 3, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pouvoir nommer une stté en tant que mandataire
2 participants