Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaubert committed Sep 16, 2024
1 parent 8ff7467 commit dac576b
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,36 @@ describe('vérifie l’arbre des procédures spécifique', () => {
ETES.recevabiliteDeLaDemande.FAVORABLE,
ETES.notificationAuDemandeur.FAIT,
])
expect(service).canOnlyTransitionTo({ machine, date: dateFin }, ['NOTIFIER_DEMANDEUR'])
expect(service).canOnlyTransitionTo({ machine, date: dateFin }, ['FAIRE_MISE_EN_CONCURRENCE', 'NOTIFIER_DEMANDEUR'])
})

// FIXMACHINE pour le moment on ne peut pas écrire ce test
// test('on peut notifier le demandeur apres une recevabilité favorable pour un PER ou une concession qui n'est pas la première demande pour la mise en concurrence', () => {
// const { service, dateFin, machine } = setDateAndOrderAndInterpretMachine(psCxmOctMachine, '1999-04-14', [
// ETES.demande.FAIT,
// ETES.depotDeLaDemande.FAIT,
// ETES.recevabiliteDeLaDemande.FAVORABLE,
// ETES.notificationAuDemandeur.FAIT,
// ])
// expect(service).canOnlyTransitionTo({ machine, date: dateFin }, ['NOTIFIER_DEMANDEUR'])
// })
test('on ne peut pas notifier le demandeur apres une recevabilité favorable pour pcc', () => {
expect(() =>
setDateAndOrderAndInterpretMachine(psPccOctMachine, '1999-04-14', [ETES.demande.FAIT, ETES.depotDeLaDemande.FAIT, ETES.recevabiliteDeLaDemande.FAVORABLE, ETES.notificationAuDemandeur.FAIT])
).toThrowErrorMatchingInlineSnapshot(
`[Error: Error: cannot execute step: '{"etapeTypeId":"mno","etapeStatutId":"fai","date":"1999-04-18"}' after '["mfr_fai","mdp_fai","mcr_fav"]'. The event {"type":"NOTIFIER_DEMANDEUR","date":"1999-04-18","status":"fai"} should be one of '']`
`[Error: Error: cannot execute step: '{"etapeTypeId":"mno","etapeStatutId":"fai","date":"1999-04-18"}' after '["mfr_fai","mdp_fai","mcr_fav"]'. The event {"type":"NOTIFIER_DEMANDEUR","date":"1999-04-18","status":"fai"} should be one of 'FAIRE_MISE_EN_CONCURRENCE']`
)
})
test("après la recevabilité favorable la démarche devient publique si il n'y a pas de mise en concurrence", () => {
test("après la recevabilité favorable la démarche reste confidentielle si il n'y a pas de mise en concurrence", () => {
const { service, dateFin, machine } = setDateAndOrderAndInterpretMachine(psPrmProMachine, '1999-04-14', [ETES.demande.FAIT, ETES.depotDeLaDemande.FAIT, ETES.recevabiliteDeLaDemande.FAVORABLE])

expect(service).canOnlyTransitionTo({ machine, date: dateFin }, ['RENDRE_AVIS_CGE_IGEDD', 'NOTIFIER_DEMANDEUR'])
expect(service.getSnapshot().context.visibilite).toBe('publique')
expect(service.getSnapshot().context.visibilite).toBe('confidentielle')
})
test('après la recevabilité favorable la démarche reste confidentielle si il y a une mise en concurrence', () => {
const { service, dateFin, machine } = setDateAndOrderAndInterpretMachine(psCxmOctMachine, '1999-04-14', [ETES.demande.FAIT, ETES.depotDeLaDemande.FAIT, ETES.recevabiliteDeLaDemande.FAVORABLE])

expect(service).canOnlyTransitionTo({ machine, date: dateFin }, ['NOTIFIER_DEMANDEUR'])
expect(service).canOnlyTransitionTo({ machine, date: dateFin }, ['NOTIFIER_DEMANDEUR', 'FAIRE_MISE_EN_CONCURRENCE'])
expect(service.getSnapshot().context.visibilite).toBe('confidentielle')
})
test("ne peut pas rendre la décision de l'administration si la participation du public n'est pas terminée", () => {
Expand Down Expand Up @@ -161,10 +172,10 @@ describe('vérifie l’arbre des procédures spécifique', () => {
"RIEN (confidentielle, en construction ) -> [FAIRE_DEMANDE]",
"FAIRE_DEMANDE (confidentielle, en instruction ) -> [DEPOSER_DEMANDE]",
"DEPOSER_DEMANDE (confidentielle, en instruction ) -> [FAIRE_RECEVABILITE_DEFAVORABLE,FAIRE_RECEVABILITE_FAVORABLE]",
"FAIRE_RECEVABILITE_FAVORABLE (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_COLLECTIVITES,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_COLLECTIVITES (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_SERVICES_COMMISSIONS (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_PREFET]",
"RENDRE_AVIS_PREFET (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC]",
"FAIRE_RECEVABILITE_FAVORABLE (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_COLLECTIVITES,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_COLLECTIVITES (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_SERVICES_COMMISSIONS (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_PREFET]",
"RENDRE_AVIS_PREFET (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC]",
"OUVRIR_PARTICIPATION_DU_PUBLIC (publique , en instruction ) -> [RENDRE_DECISION_ADMINISTRATION_ACCEPTEE,RENDRE_DECISION_ADMINISTRATION_REJETEE,RENDRE_DECISION_ADMINISTRATION_REJETEE_DECISION_IMPLICITE]",
"RENDRE_DECISION_ADMINISTRATION_ACCEPTEE (publique , accepté ) -> [PUBLIER_DECISION_ACCEPTEE_AU_JORF,PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS]",
"PUBLIER_DECISION_ACCEPTEE_AU_JORF (publique , accepté et publié ) -> [FAIRE_ABROGATION,NOTIFIER_DEMANDEUR]",
Expand Down Expand Up @@ -194,10 +205,10 @@ describe('vérifie l’arbre des procédures spécifique', () => {
"RIEN (confidentielle, en construction ) -> [FAIRE_DEMANDE]",
"FAIRE_DEMANDE (confidentielle, en instruction ) -> [DEPOSER_DEMANDE]",
"DEPOSER_DEMANDE (confidentielle, en instruction ) -> [FAIRE_RECEVABILITE_DEFAVORABLE,FAIRE_RECEVABILITE_FAVORABLE]",
"FAIRE_RECEVABILITE_FAVORABLE (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_COLLECTIVITES,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_COLLECTIVITES (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_SERVICES_COMMISSIONS (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_PREFET]",
"RENDRE_AVIS_PREFET (publique , en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC]",
"FAIRE_RECEVABILITE_FAVORABLE (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_COLLECTIVITES,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_COLLECTIVITES (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_SERVICES_COMMISSIONS]",
"RENDRE_AVIS_SERVICES_COMMISSIONS (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC,RENDRE_AVIS_PREFET]",
"RENDRE_AVIS_PREFET (confidentielle, en instruction ) -> [OUVRIR_ENQUETE_PUBLIQUE,OUVRIR_PARTICIPATION_DU_PUBLIC]",
"OUVRIR_PARTICIPATION_DU_PUBLIC (publique , en instruction ) -> [RENDRE_DECISION_ADMINISTRATION_ACCEPTEE,RENDRE_DECISION_ADMINISTRATION_REJETEE,RENDRE_DECISION_ADMINISTRATION_REJETEE_DECISION_IMPLICITE]",
"RENDRE_DECISION_ADMINISTRATION_ACCEPTEE (publique , accepté ) -> [PUBLIER_DECISION_ACCEPTEE_AU_JORF,PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS]",
"PUBLIER_DECISION_ACCEPTEE_AU_JORF (publique , accepté et publié ) -> [FAIRE_ABROGATION,NOTIFIER_DEMANDEUR]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ type EnqueteDuPublic = {
status: EtapeStatutId
type: 'OUVRIR_ENQUETE_PUBLIQUE'
}

type FaireMiseEnConcurrence = {
status: EtapeStatutId
type: 'FAIRE_MISE_EN_CONCURRENCE'
}

type ProcedureSpecifiqueXStateEvent =
| { type: 'FAIRE_DEMANDE' }
| { type: 'DEPOSER_DEMANDE' }
Expand All @@ -29,6 +35,7 @@ type ProcedureSpecifiqueXStateEvent =
| { type: 'FAIRE_DEMANDE_DE_COMPLEMENTS' }
| { type: 'RECEVOIR_COMPLEMENTS' }
| { type: 'FAIRE_DECLARATION_IRRECEVABILITE' }
| FaireMiseEnConcurrence
| { type: 'NOTIFIER_DEMANDEUR' }
| { type: 'RENDRE_AVIS_CGE_IGEDD' }
| { type: 'FAIRE_LETTRE_SAISINE_PREFET' }
Expand All @@ -55,6 +62,7 @@ const trad: { [key in Event]: { db: DBEtat; mainStep: boolean } } = {
FAIRE_DEMANDE_DE_COMPLEMENTS: { db: ETES.demandeDeComplements, mainStep: false },
RECEVOIR_COMPLEMENTS: { db: ETES.receptionDeComplements, mainStep: false },
FAIRE_DECLARATION_IRRECEVABILITE: { db: ETES.declarationDIrrecevabilite, mainStep: false },
FAIRE_MISE_EN_CONCURRENCE: { db: ETES.avisDeMiseEnConcurrenceAuJORF, mainStep: true },
NOTIFIER_DEMANDEUR: { db: ETES.notificationAuDemandeur, mainStep: false },
RENDRE_AVIS_CGE_IGEDD: { db: ETES.avisDuConseilGeneralDeLeconomie_CGE_, mainStep: true },
FAIRE_LETTRE_SAISINE_PREFET: { db: ETES.saisineDuPrefet, mainStep: true },
Expand Down Expand Up @@ -90,6 +98,12 @@ export class ProcedureSpecifiqueMachine extends CaminoMachine<ProcedureSpecifiqu
{ type: event, status: ETAPES_STATUTS.EN_COURS, surface: km2Validator.parse(0.26) },
{ type: event, status: ETAPES_STATUTS.TERMINE, surface: km2Validator.parse(0.26) },
]
case 'FAIRE_MISE_EN_CONCURRENCE':
return [
{ type: event, status: ETAPES_STATUTS.PROGRAMME },
{ type: event, status: ETAPES_STATUTS.EN_COURS },
{ type: event, status: ETAPES_STATUTS.TERMINE },
]
default:
return super.toPotentialCaminoXStateEvent(event, date)
}
Expand All @@ -105,9 +119,11 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
isAxm: () => TITRES_TYPES_IDS.AUTORISATION_D_EXPLOITATION_METAUX === titreTypeId,
isPerOuConcession: () => [TITRES_TYPES_TYPES_IDS.PERMIS_EXCLUSIF_DE_RECHERCHES, TITRES_TYPES_TYPES_IDS.CONCESSION].includes(getTitreTypeType(titreTypeId)),
// FIXMACHINE la condition a changé
hasMiseEnConcurrence: () =>
canHaveMiseEnConcurrence: () =>
[DEMARCHES_TYPES_IDS.Octroi, DEMARCHES_TYPES_IDS.ExtensionDePerimetre].includes(demarcheTypeId) ||
(isDemarcheTypeProlongations(demarcheTypeId) && getTitreTypeType(titreTypeId) === TITRES_TYPES_TYPES_IDS.CONCESSION),
//FIXMACHINE
isPremiereDemandePourMiseEnConcurrence: () => true,
isAxmOuAr: () => TITRES_TYPES_IDS.AUTORISATION_D_EXPLOITATION_METAUX === titreTypeId || TITRES_TYPES_TYPES_IDS.AUTORISATION_DE_RECHERCHE === getTitreTypeType(titreTypeId),
// FIXMACHINE à vérifier et à tester
isEnquetePubliqueRequired: ({ event }) =>
Expand Down Expand Up @@ -186,31 +202,47 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
recevabiliteFavorableFaite: {
always: [
{
guard: and([not('hasMiseEnConcurrence'), not('isVisibilitePublique')]),
actions: assign({ visibilite: 'publique' }),
target: 'avisCollectivitesEtServicesEtCommissionsAFaireMachine',
guard: and([not('canHaveMiseEnConcurrence'), 'isAxmOuAr']),
},
{
target: 'avisCollectivitesEtServicesEtCommissionsAFaireMachine',
guard: and([not('hasMiseEnConcurrence'), 'isAxmOuAr']),
target: 'resultatMiseEnConcurrenceAFaire',
guard: and(['canHaveMiseEnConcurrence', not('isPremiereDemandePourMiseEnConcurrence')]),
},
],
on: {
// FIXMACHINE ajouter la mise en concurrence
FAIRE_MISE_EN_CONCURRENCE: [
{
target: 'resultatMiseEnConcurrenceAFaire',
guard: and(['canHaveMiseEnConcurrence', 'isPremiereDemandePourMiseEnConcurrence', ({ event }) => event.status === ETAPES_STATUTS.TERMINE]),
actions: assign({ visibilite: 'publique' }),
},
{
target: 'enAttente',
guard: and(['canHaveMiseEnConcurrence', 'isPremiereDemandePourMiseEnConcurrence', ({ event }) => event.status === ETAPES_STATUTS.EN_COURS]),
actions: assign({ visibilite: 'publique' }),
},
],
RENDRE_AVIS_CGE_IGEDD: {
// FIXMACHINE ajouter la demande de modification de l'aes
target: 'notificationAuDemandeurAFaire',
guard: and([not('hasMiseEnConcurrence'), not('isAxmOuAr')]),
guard: and([not('canHaveMiseEnConcurrence'), not('isAxmOuAr')]),
},
NOTIFIER_DEMANDEUR: {
target: 'recevabiliteFavorableFaite',
guard: 'isPerOuConcession',
},
},
},

enAttente: {},
notificationAuDemandeurAFaire: {
on: { NOTIFIER_DEMANDEUR: 'lettreDeSaisineDuPrefetOuReponseDuDemandeurAFaire' },
},
resultatMiseEnConcurrenceAFaire: {
on: {
//FIXMACHINE
},
},
lettreDeSaisineDuPrefetOuReponseDuDemandeurAFaire: {
on: {
// FIXMACHINE brouillon
Expand Down Expand Up @@ -270,20 +302,32 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
{
target: 'fin',
guard: and([or(['isEnquetePubliqueRequired', 'isEnquetePubliquePossible']), ({ event }) => event.status === ETAPES_STATUTS.TERMINE]),
actions: assign({ visibilite: 'publique' }),
},
{
target: 'enAttente',
guard: ({ event }) => event.status === ETAPES_STATUTS.EN_COURS,
actions: assign({ visibilite: 'publique' }),
},
{
target: 'enAttente',
guard: ({ event }) => event.status !== ETAPES_STATUTS.TERMINE,
guard: ({ event }) => event.status === ETAPES_STATUTS.PROGRAMME,
},
],
OUVRIR_PARTICIPATION_DU_PUBLIC: [
{
target: 'fin',
guard: and([not('isEnquetePubliqueRequired'), ({ event }) => event.status === ETAPES_STATUTS.TERMINE]),
actions: assign({ visibilite: 'publique' }),
},
{
target: 'enAttente',
guard: ({ event }) => event.status !== ETAPES_STATUTS.TERMINE,
guard: ({ event }) => event.status === ETAPES_STATUTS.EN_COURS,
actions: assign({ visibilite: 'publique' }),
},
{
target: 'enAttente',
guard: ({ event }) => event.status === ETAPES_STATUTS.PROGRAMME,
},
],
},
Expand All @@ -299,7 +343,10 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
},
decisionAdministrationAFaire: {
on: {
RENDRE_DECISION_ADMINISTRATION_ACCEPTEE: { target: 'publicationAuRecueilDesActesAdministratifsOupublicationAuJORFAFaire', actions: assign({ demarcheStatut: DemarchesStatutsIds.Accepte }) },
RENDRE_DECISION_ADMINISTRATION_ACCEPTEE: {
target: 'publicationAuRecueilDesActesAdministratifsOupublicationAuJORFAFaire',
actions: assign({ demarcheStatut: DemarchesStatutsIds.Accepte, visibilite: 'publique' }),
},
RENDRE_DECISION_ADMINISTRATION_REJETEE: {
target: 'notificationAuDemandeurApresDecisionRejetAFaire',
actions: assign({ visibilite: 'confidentielle' }),
Expand All @@ -308,6 +355,7 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
target: 'finDeMachine',
actions: assign({
demarcheStatut: DemarchesStatutsIds.Rejete,
visibilite: 'publique',
}),
},
},
Expand Down Expand Up @@ -403,3 +451,5 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
// - Pour l'enquête et la participation du public, la démarche est déjà publique => Heuuuu non, modif à faire dans le logigramme
//
// - « Mesures de publicité» ça bloque tout ? -> NON
//
// - Pour la mise en concurrence, si ce n'est pas la demande initiale. L'utilisateur a le choix entre 2 « Notification au demandeur », sachant que celle après la mise en concurrence est beaucoup plus complète, on ne peut pas renommer cette dernière ?

0 comments on commit dac576b

Please sign in to comment.