diff --git a/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.test.ts b/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.test.ts index 1be17004e..f70333150 100644 --- a/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.test.ts +++ b/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.test.ts @@ -89,7 +89,7 @@ describe('vérifie l’arbre des procédures spécifique', () => { expect(service.getSnapshot().context.visibilite).toBe('publique') expect(service.getSnapshot().context.demarcheStatut).toBe(DemarchesStatutsIds.AccepteEtPublie) - expect(service).canOnlyTransitionTo({ machine, date: dateFin }, []) + expect(service).canOnlyTransitionTo({ machine, date: dateFin }, ['FAIRE_ABROGATION']) }) test("réalise une demande de prolongation d'ARM rejetée", () => { const { service, dateFin } = setDateAndOrderAndInterpretMachine(psArmProMachine, '1999-04-14', [ @@ -168,8 +168,8 @@ describe('vérifie l’arbre des procédures spécifique', () => { "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]", - "NOTIFIER_DEMANDEUR (publique , accepté et publié ) -> [FAIRE_ATTESTATION_DE_CONSTITUTION_DE_GARANTIES_FINANCIERES]", - "FAIRE_ATTESTATION_DE_CONSTITUTION_DE_GARANTIES_FINANCIERES (publique , accepté et publié ) -> []", + "NOTIFIER_DEMANDEUR (publique , accepté et publié ) -> [FAIRE_ABROGATION,FAIRE_ATTESTATION_DE_CONSTITUTION_DE_GARANTIES_FINANCIERES]", + "FAIRE_ATTESTATION_DE_CONSTITUTION_DE_GARANTIES_FINANCIERES (publique , accepté et publié ) -> [FAIRE_ABROGATION]", ] `) }) @@ -201,8 +201,8 @@ describe('vérifie l’arbre des procédures spécifique', () => { "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]", - "FAIRE_ABROGATION (publique , accepté et publié ) -> [PUBLIER_DECISION_ACCEPTEE_AU_JORF,PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS]", - "PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS (publique , rejeté après abrogation) -> []", + "FAIRE_ABROGATION (publique , accepté et publié ) -> [NOTIFIER_DEMANDEUR,PUBLIER_DECISION_ACCEPTEE_AU_JORF,PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS]", + "PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS (publique , rejeté après abrogation) -> [NOTIFIER_DEMANDEUR]", ] `) }) diff --git a/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.ts b/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.ts index b10c66d04..93d3228c1 100644 --- a/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.ts +++ b/packages/api/src/business/rules-demarches/procedure-specifique/procedure-specifique.machine.ts @@ -314,47 +314,70 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De }, publicationAuRecueilDesActesAdministratifsOupublicationAuJORFAFaire: { on: { - PUBLIER_DECISION_ACCEPTEE_AU_JORF: [ - { - guard: 'isDemarcheStatutAcceptee', - target: 'abrogationOuNotificationAuDemandeurAFaire', - actions: assign({ demarcheStatut: DemarchesStatutsIds.AccepteEtPublie }), - }, - { - guard: 'isDemarcheStatutAccepteeEtPublie', - target: 'finDeMachine', - actions: assign({ demarcheStatut: DemarchesStatutsIds.RejeteApresAbrogation }), - }, - ], - PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS: [ - { - guard: 'isDemarcheStatutAcceptee', - target: 'abrogationOuNotificationAuDemandeurAFaire', - actions: assign({ demarcheStatut: DemarchesStatutsIds.AccepteEtPublie }), - }, - { - guard: 'isDemarcheStatutAccepteeEtPublie', - target: 'finDeMachine', - actions: assign({ demarcheStatut: DemarchesStatutsIds.RejeteApresAbrogation }), - }, - ], - }, - }, - abrogationOuNotificationAuDemandeurAFaire: { - on: { - NOTIFIER_DEMANDEUR: 'attestationDeConstitutionDeGarantiesFinancieresAFaire', - FAIRE_ABROGATION: 'publicationAuRecueilDesActesAdministratifsOupublicationAuJORFAFaire', + PUBLIER_DECISION_ACCEPTEE_AU_JORF: { + target: 'abrogationOuNotificationAuDemandeurMachine', + actions: assign({ demarcheStatut: DemarchesStatutsIds.AccepteEtPublie }), + }, + PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS: { + target: 'abrogationOuNotificationAuDemandeurMachine', + actions: assign({ demarcheStatut: DemarchesStatutsIds.AccepteEtPublie }), + }, }, }, - attestationDeConstitutionDeGarantiesFinancieresAFaire: { - always: { - target: 'finDeMachine', - guard: not('isAxm'), - }, - on: { - FAIRE_ATTESTATION_DE_CONSTITUTION_DE_GARANTIES_FINANCIERES: 'finDeMachine', + abrogationOuNotificationAuDemandeurMachine: { + type: 'parallel', + states: { + notificationAuDemandeurMachine: { + initial: 'notificationAuDemandeurAFaire', + states: { + notificationAuDemandeurAFaire: { + on: { + NOTIFIER_DEMANDEUR: 'attestationDeConstitutionDeGarantiesFinancieresAFaire', + }, + }, + attestationDeConstitutionDeGarantiesFinancieresAFaire: { + always: { + target: 'attestationDeConstitutionDeGarantiesFinancieresFait', + guard: not('isAxm'), + }, + on: { + FAIRE_ATTESTATION_DE_CONSTITUTION_DE_GARANTIES_FINANCIERES: 'attestationDeConstitutionDeGarantiesFinancieresFait', + }, + }, + + attestationDeConstitutionDeGarantiesFinancieresFait: { type: 'final' }, + }, + }, + + abrogationMachine: { + initial: 'abrogationAFaire', + states: { + abrogationAFaire: { + on: { + FAIRE_ABROGATION: 'publicationsAFaire', + }, + }, + publicationsAFaire: { + on: { + PUBLIER_DECISION_ACCEPTEE_AU_JORF: { + target: 'publicationsFaites', + actions: assign({ demarcheStatut: DemarchesStatutsIds.RejeteApresAbrogation }), + }, + PUBLIER_DECISION_AU_RECUEIL_DES_ACTES_ADMINISTRATIFS: { + target: 'publicationsFaites', + actions: assign({ demarcheStatut: DemarchesStatutsIds.RejeteApresAbrogation }), + }, + }, + }, + publicationsFaites: { + type: 'final', + }, + }, + }, }, + onDone: 'finDeMachine', }, + notificationAuDemandeurApresDecisionRejetAFaire: { on: { NOTIFIER_DEMANDEUR: { @@ -379,5 +402,4 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De // - comment on peut avoir une mise en concurrence si la démarche n'est pas publique ? => Modif du logigramme, ça devient publique dés que la mise en concurrence est « en cours » // - 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 ? -// - Une fois qu'on a notifié le demandeur, on ne peut plus abroger ? +// - « Mesures de publicité» ça bloque tout ? -> NON