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

Commit

Permalink
wip isPremiereDemandePourMiseEnConcurrence
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaubert committed Sep 17, 2024
1 parent a5ea686 commit dd7562f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/api/src/business/rules-demarches/arm/oct.machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,17 @@ interface OctARMContext extends CaminoCommonContext {
paiementFraisDossierValide: boolean
}

const isConnu = (mecanisation: MecanisationInconnu): mecanisation is MecanisationConnu => {
const isConnu = (mecanisation: MecanisationInconnu) => {
return mecanisation !== 'inconnu'
}
const isInconnu = (mecanisation: MecanisationInconnu): mecanisation is MecanisationInconnu => {
const isInconnu = (mecanisation: MecanisationInconnu) => {
return !isConnu(mecanisation)
}

const isMecanise = (mecanisation: MecanisationInconnu): mecanisation is MecanisationConnuMecanise => {
const isMecanise = (mecanisation: MecanisationInconnu) => {
return isConnu(mecanisation) && mecanisation.mecanise
}
const isNonMecanise = (mecanisation: MecanisationInconnu): mecanisation is MecanisationConnuNonMecanise => {
const isNonMecanise = (mecanisation: MecanisationInconnu) => {
return isConnu(mecanisation) && !mecanisation.mecanise
}
const mustPayerFraisDossierComplementaire = (mecanisation: MecanisationInconnu): boolean => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/business/rules-demarches/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,5 @@ export const machineFind = (
return undefined
}

return definition?.machine(titreTypeId, demarcheTypeId)
return definition?.machine(titreInfos)

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/processes/titres-demarches-depot-create.test.ts > créer le dépot de la démarche > crée un dépot d’une ARM avec une demande faite

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ Module.titreDemarcheDepotCheck business/processes/titres-demarches-depot-create.ts:53:30 ❯ business/processes/titres-demarches-depot-create.test.ts:21:41

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/processes/titres-demarches-depot-create.test.ts > créer le dépot de la démarche > ne crée pas un dépot d’une ARM si sa demande est en construction

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ Module.titreDemarcheDepotCheck business/processes/titres-demarches-depot-create.ts:53:30 ❯ business/processes/titres-demarches-depot-create.test.ts:21:41

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/processes/titres-demarches-depot-create.test.ts > créer le dépot de la démarche > ne crée pas un dépot d’une ARM si déjà déposée

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ Module.titreDemarcheDepotCheck business/processes/titres-demarches-depot-create.ts:53:30 ❯ business/processes/titres-demarches-depot-create.test.ts:21:41

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/processes/titres-demarches-public-update.test.ts > public des démarches d'un titre > met à jour la publicité d'une démarche

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ Module.titreDemarchePublicFind business/rules/titre-demarche-public-find.ts:171:21 ❯ Module.titresDemarchesPublicUpdate business/processes/titres-demarches-public-update.ts:35:53 ❯ business/processes/titres-demarches-public-update.test.ts:21:42

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/processes/titres-etapes-ordre-update.test.ts > ordre des étapes > met à jour l'ordre de deux étapes

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ Module.titreEtapesSortAscByDate business/utils/titre-etapes-sort.ts:19:19 ❯ Module.titresEtapesOrdreUpdateVisibleForTesting business/processes/titres-etapes-ordre-update.ts:40:22 ❯ business/processes/titres-etapes-ordre-update.test.ts:77:39

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/rules/titre-demarche-public-find.test.ts > publicité d'une démarche > une démarche sans étape n'est pas publique

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ Module.titreDemarchePublicFind business/rules/titre-demarche-public-find.ts:171:21 ❯ business/rules/titre-demarche-public-find.test.ts:28:7

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/rules-demarches/definitions.test.ts > demarcheDefinitionFind retourne une machine

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ business/rules-demarches/definitions.test.ts:7:10

Check failure on line 157 in packages/api/src/business/rules-demarches/definitions.ts

View workflow job for this annotation

GitHub Actions / api / unit-test

business/rules-demarches/definitions.test.ts > demarcheDefinitionFind retourne une machine quand il n'y a pas d'étape

ReferenceError: titreInfos is not defined ❯ Module.machineFind business/rules-demarches/definitions.ts:157:30 ❯ business/rules-demarches/definitions.test.ts:11:10
}
5 changes: 5 additions & 0 deletions packages/api/src/business/rules-demarches/machine-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Etape {
contenu?: IContenu
paysId?: PaysId
surface?: number
isPremiereDemandePourMiseEnConcurrence?: boolean
}

export const globalGuards = {
Expand Down Expand Up @@ -92,6 +93,10 @@ const toMachineEtape = (dbEtape: Omit<TitreEtapeForMachine, 'id' | 'ordre'>): Et
machineEtape.surface = dbEtape.surface
}

if (dbEtape.isPremiereDemandePourMiseEnConcurrence !== null) {
machineEtape.isPremiereDemandePourMiseEnConcurrence = dbEtape.isPremiereDemandePourMiseEnConcurrence
}

return machineEtape
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ type FaireMiseEnConcurrence = {
type: 'FAIRE_MISE_EN_CONCURRENCE'
}

type FaireRecevabiliteFavorable = {
// FIXMACHINE brand this boolean
isPremiereDemandePourMiseEnConcurrence: boolean
type: 'FAIRE_RECEVABILITE_FAVORABLE'
}

type ProcedureSpecifiqueXStateEvent =
| { type: 'FAIRE_DEMANDE' }
| { type: 'DEPOSER_DEMANDE' }
| { type: 'FAIRE_RECEVABILITE_FAVORABLE' }
| FaireRecevabiliteFavorable
| { type: 'FAIRE_RECEVABILITE_DEFAVORABLE' }
| { type: 'FAIRE_DEMANDE_DE_COMPLEMENTS' }
| { type: 'RECEVOIR_COMPLEMENTS' }
Expand Down Expand Up @@ -104,26 +110,32 @@ export class ProcedureSpecifiqueMachine extends CaminoMachine<ProcedureSpecifiqu
{ type: event, status: ETAPES_STATUTS.EN_COURS },
{ type: event, status: ETAPES_STATUTS.TERMINE },
]
case 'FAIRE_RECEVABILITE_FAVORABLE':
return [
{ type: event, isPremiereDemandePourMiseEnConcurrence: true },
{ type: event, isPremiereDemandePourMiseEnConcurrence: false },
]
default:
return super.toPotentialCaminoXStateEvent(event, date)
}
}
}

interface ProcedureSpecifiqueContext extends CaminoCommonContext {}
interface ProcedureSpecifiqueContext extends CaminoCommonContext {
isPremiereDemandePourMiseEnConcurrence: boolean | 'inconnu'
}
const defaultDemarcheStatut = DemarchesStatutsIds.EnConstruction
const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: DemarcheTypeId) =>
setup({
types: {} as { context: CaminoCommonContext; events: ProcedureSpecifiqueXStateEvent },
types: {} as { context: ProcedureSpecifiqueContext; events: ProcedureSpecifiqueXStateEvent },
guards: {
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é
canHaveMiseEnConcurrence: () =>
[DEMARCHES_TYPES_IDS.Octroi, DEMARCHES_TYPES_IDS.ExtensionDePerimetre].includes(demarcheTypeId) ||
(isDemarcheTypeProlongations(demarcheTypeId) && getTitreTypeType(titreTypeId) === TITRES_TYPES_TYPES_IDS.CONCESSION),
//FIXMACHINE
isPremiereDemandePourMiseEnConcurrence: () => true,
isPremiereDemandePourMiseEnConcurrence: ({ context }) => context.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 All @@ -147,6 +159,7 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
context: {
demarcheStatut: defaultDemarcheStatut,
visibilite: 'confidentielle',
isPremiereDemandePourMiseEnConcurrence: 'inconnu',
},
states: {
demandeAFaire: {
Expand Down Expand Up @@ -189,7 +202,10 @@ const procedureSpecifiqueMachine = (titreTypeId: TitreTypeId, demarcheTypeId: De
},
recevabiliteOuIrrecevabiliteAFaire: {
on: {
FAIRE_RECEVABILITE_FAVORABLE: 'recevabiliteFavorableFaite',
FAIRE_RECEVABILITE_FAVORABLE: {
target: 'recevabiliteFavorableFaite',
actions: assign({ isPremiereDemandePourMiseEnConcurrence: ({ event }) => event.isPremiereDemandePourMiseEnConcurrence }),
},
FAIRE_RECEVABILITE_DEFAVORABLE: 'demandeDeComplementsAFaire',
FAIRE_DECLARATION_IRRECEVABILITE: {
target: 'finDeMachine',
Expand Down

0 comments on commit dd7562f

Please sign in to comment.