diff --git "a/packages/applications/bootstrap/src/setupT\303\242che.ts" "b/packages/applications/bootstrap/src/setupT\303\242che.ts" index 1d78023fdc..5e2fe51acc 100644 --- "a/packages/applications/bootstrap/src/setupT\303\242che.ts" +++ "b/packages/applications/bootstrap/src/setupT\303\242che.ts" @@ -70,7 +70,6 @@ const registerTâcheGarantiesFinancières = async () => { 'GarantiesFinancièresDemandées-V1', 'DépôtGarantiesFinancièresSoumis-V1', 'GarantiesFinancièresEnregistrées-V1', - 'TypeGarantiesFinancièresImporté-V1', ], eventHandler: async (event) => { await mediator.publish({ diff --git "a/packages/domain/laur\303\251at/src/abandon/accorder/accorderAbandon.usecase.ts" "b/packages/domain/laur\303\251at/src/abandon/accorder/accorderAbandon.usecase.ts" index 0846029319..6f9a8df676 100644 --- "a/packages/domain/laur\303\251at/src/abandon/accorder/accorderAbandon.usecase.ts" +++ "b/packages/domain/laur\303\251at/src/abandon/accorder/accorderAbandon.usecase.ts" @@ -8,10 +8,8 @@ import { IdentifiantUtilisateur } from '@potentiel-domain/utilisateur'; import { DocumentProjet, EnregistrerDocumentProjetCommand } from '@potentiel-domain/document'; // Package -import { AnnulerTâchePlanifiéeCommand } from '@potentiel-domain/tache-planifiee'; - import * as TypeDocumentAbandon from '../typeDocumentAbandon.valueType'; -import { TypeTâchePlanifiéeGarantiesFinancières } from '../../garantiesFinancières'; +import { AnnulerTâchesPlanifiéesGarantiesFinancièresCommand } from '../../garantiesFinancières/tâches-planifiées/annuler/annuler.command'; import { AccorderAbandonCommand } from './accorderAbandon.command'; @@ -66,27 +64,10 @@ export const registerAccorderAbandonUseCase = () => { }, }); - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', - data: { - identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - }, - }); - - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', - data: { - identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, - }, - }); - - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', + await mediator.send({ + type: 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées', data: { identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, }, }); }; diff --git "a/packages/domain/laur\303\251at/src/ach\303\250vement/transmettre/transmettreAttestationConformit\303\251.usecase.ts" "b/packages/domain/laur\303\251at/src/ach\303\250vement/transmettre/transmettreAttestationConformit\303\251.usecase.ts" index fad16de4e4..0c1f6c65bf 100644 --- "a/packages/domain/laur\303\251at/src/ach\303\250vement/transmettre/transmettreAttestationConformit\303\251.usecase.ts" +++ "b/packages/domain/laur\303\251at/src/ach\303\250vement/transmettre/transmettreAttestationConformit\303\251.usecase.ts" @@ -3,10 +3,9 @@ import { Message, MessageHandler, mediator } from 'mediateur'; import { DocumentProjet, EnregistrerDocumentProjetCommand } from '@potentiel-domain/document'; import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; import { IdentifiantUtilisateur } from '@potentiel-domain/utilisateur'; -import { AnnulerTâchePlanifiéeCommand } from '@potentiel-domain/tache-planifiee'; import { TypeDocumentAchèvement } from '..'; -import * as TypeTâchePlanifiéeGarantiesFinancières from '../../garantiesFinancières/typeTâchePlanifiéeGarantiesFinancières.valueType'; +import { AnnulerTâchesPlanifiéesGarantiesFinancièresCommand } from '../../garantiesFinancières/tâches-planifiées/annuler/annuler.command'; import { TransmettreAttestationConformitéCommand } from './transmettreAttestationConformité.command'; @@ -85,27 +84,10 @@ export const registerTransmettreAttestationConformitéUseCase = () => { }, }); - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', + await mediator.send({ + type: 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées', data: { identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - }, - }); - - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', - data: { - identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, - }, - }); - - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', - data: { - identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, }, }); }; diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/soumettreD\303\251p\303\264t/soumettreD\303\251p\303\264tGarantiesFinanci\303\250res.usecase.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/soumettreD\303\251p\303\264t/soumettreD\303\251p\303\264tGarantiesFinanci\303\250res.usecase.ts" index 5919360f2f..8509177399 100644 --- "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/soumettreD\303\251p\303\264t/soumettreD\303\251p\303\264tGarantiesFinanci\303\250res.usecase.ts" +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/soumettreD\303\251p\303\264t/soumettreD\303\251p\303\264tGarantiesFinanci\303\250res.usecase.ts" @@ -3,11 +3,10 @@ import { Message, MessageHandler, mediator } from 'mediateur'; import { DocumentProjet, EnregistrerDocumentProjetCommand } from '@potentiel-domain/document'; import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; import { IdentifiantUtilisateur } from '@potentiel-domain/utilisateur'; -import { AnnulerTâchePlanifiéeCommand } from '@potentiel-domain/tache-planifiee'; import { Candidature } from '@potentiel-domain/candidature'; import { TypeDocumentGarantiesFinancières } from '../..'; -import * as TypeTâchePlanifiéeGarantiesFinancières from '../../typeTâchePlanifiéeGarantiesFinancières.valueType'; +import { AnnulerTâchesPlanifiéesGarantiesFinancièresCommand } from '../../tâches-planifiées/annuler/annuler.command'; import { SoumettreDépôtGarantiesFinancièresCommand } from './soumettreDépôtGarantiesFinancières.command'; @@ -74,27 +73,10 @@ export const registerSoumettreDépôtGarantiesFinancièresUseCase = () => { }, }); - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', + await mediator.send({ + type: 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées', data: { identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - }, - }); - - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', - data: { - identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, - }, - }); - - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', - data: { - identifiantProjet, - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, }, }); }; diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" index 9edc6d0515..8ffac2e2f5 100644 --- "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tEnCours/supprimerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" @@ -2,9 +2,8 @@ import { Message, MessageHandler, mediator } from 'mediateur'; import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; import { IdentifiantUtilisateur } from '@potentiel-domain/utilisateur'; -import { AjouterTâchePlanifiéeCommand } from '@potentiel-domain/tache-planifiee'; -import * as TypeTâchePlanifiéeGarantiesFinancières from '../../typeTâchePlanifiéeGarantiesFinancières.valueType'; +import { AjouterTâchesPlanifiéesGarantiesFinancièresCommand } from '../../tâches-planifiées/ajouter/ajouter.command'; import { SupprimerDépôtGarantiesFinancièresEnCoursCommand } from './supprimerDépôtGarantiesFinancièresEnCours.command'; @@ -38,29 +37,15 @@ export const registerSupprimerGarantiesFinancièresÀTraiterUseCase = () => { }, }); - if (dateÉchéanceValue) { - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AjouterTâchePlanifiée', - data: { - identifiantProjet, - tâches: [ - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).ajouterNombreDeJours(1), - }, - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(1), - }, - { - typeTâchePlanifiée: - TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(2), - }, - ], - }, - }); - } + await mediator.send({ + type: 'Lauréat.GarantiesFinancières.Command.AjouterTâchesPlanifiées', + data: { + identifiantProjet, + dateÉchéance: dateÉchéanceValue + ? DateTime.convertirEnValueType(dateÉchéanceValue) + : undefined, + }, + }); }; mediator.register( 'Lauréat.GarantiesFinancières.UseCase.SupprimerGarantiesFinancièresÀTraiter', diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/validerD\303\251p\303\264tEnCours/validerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/validerD\303\251p\303\264tEnCours/validerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" index f4956d2020..2cc2ce7c90 100644 --- "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/validerD\303\251p\303\264tEnCours/validerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/d\303\251p\303\264tEnCours/validerD\303\251p\303\264tEnCours/validerD\303\251p\303\264tGarantiesFinanci\303\250resEnCours.usecase.ts" @@ -3,10 +3,9 @@ import { Message, MessageHandler, mediator } from 'mediateur'; import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; import { IdentifiantUtilisateur } from '@potentiel-domain/utilisateur'; import { DocumentProjetCommand, DossierProjet } from '@potentiel-domain/document'; -import { AjouterTâchePlanifiéeCommand } from '@potentiel-domain/tache-planifiee'; import { TypeDocumentGarantiesFinancières } from '../..'; -import * as TypeTâchePlanifiéeGarantiesFinancières from '../../typeTâchePlanifiéeGarantiesFinancières.valueType'; +import { AjouterTâchesPlanifiéesGarantiesFinancièresCommand } from '../../tâches-planifiées/ajouter/ajouter.command'; import { ValiderDépôtGarantiesFinancièresEnCoursCommand } from './validerDépôtGarantiesFinancièresEnCours.command'; @@ -54,29 +53,15 @@ export const registerValiderDépôtGarantiesFinancièresEnCoursUseCase = () => { }, }); - if (dateÉchéanceValue) { - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AjouterTâchePlanifiée', - data: { - identifiantProjet, - tâches: [ - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).ajouterNombreDeJours(1), - }, - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(1), - }, - { - typeTâchePlanifiée: - TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(2), - }, - ], - }, - }); - } + await mediator.send({ + type: 'Lauréat.GarantiesFinancières.Command.AjouterTâchesPlanifiées', + data: { + identifiantProjet, + dateÉchéance: dateÉchéanceValue + ? DateTime.convertirEnValueType(dateÉchéanceValue) + : undefined, + }, + }); }; mediator.register( diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250res.aggregate.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250res.aggregate.ts" index 1743594f59..10b81dacff 100644 --- "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250res.aggregate.ts" +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250res.aggregate.ts" @@ -96,6 +96,8 @@ import { GarantiesFinancièresÉchuesEvent, échoir, } from './garantiesFinancièresActuelles/échoir/échoirGarantiesFinancières.behavior'; +import { ajouterTâchesPlanifiées } from './tâches-planifiées/ajouter/ajouter.behavior'; +import { annulerTâchesPlanifiées } from './tâches-planifiées/annuler/annuler.behavior'; export type GarantiesFinancièresEvent = | DépôtGarantiesFinancièresSoumisEvent @@ -155,6 +157,8 @@ export type GarantiesFinancièresAggregate = Aggregate { }, }); - if (dateÉchéanceValue) { - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AjouterTâchePlanifiée', - data: { - identifiantProjet, - tâches: [ - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).ajouterNombreDeJours(1), - }, - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(1), - }, - { - typeTâchePlanifiée: - TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(2), - }, - ], - }, - }); - } + await mediator.send({ + type: 'Lauréat.GarantiesFinancières.Command.AjouterTâchesPlanifiées', + data: { + identifiantProjet, + dateÉchéance: dateÉchéanceValue + ? DateTime.convertirEnValueType(dateÉchéanceValue) + : undefined, + }, + }); }; mediator.register('Lauréat.GarantiesFinancières.UseCase.EnregistrerGarantiesFinancières', runner); }; diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.behavior.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.behavior.ts" index aeffce45ff..1b7d75c3f7 100644 --- "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.behavior.ts" +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.behavior.ts" @@ -1,6 +1,7 @@ import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; import { DomainEvent } from '@potentiel-domain/core'; import { Candidature } from '@potentiel-domain/candidature'; +import { TâchePlanifiéeAggregate } from '@potentiel-domain/tache-planifiee'; import { StatutGarantiesFinancières } from '../..'; import { GarantiesFinancièresAggregate } from '../../garantiesFinancières.aggregate'; @@ -20,11 +21,26 @@ export type Options = { type?: Candidature.TypeGarantiesFinancières.ValueType; dateÉchéance?: DateTime.ValueType; importéLe: DateTime.ValueType; + + // TODO remove the following options once aggregate root is available + estAchevé: boolean; + tâchePlanifiéeEchoir: TâchePlanifiéeAggregate; + tâchePlanifiéeRappel1mois: TâchePlanifiéeAggregate; + tâchePlanifiéeRappel2mois: TâchePlanifiéeAggregate; }; export async function importerType( this: GarantiesFinancièresAggregate, - { identifiantProjet, type, dateÉchéance, importéLe }: Options, + { + identifiantProjet, + type, + dateÉchéance, + importéLe, + estAchevé, + tâchePlanifiéeEchoir, + tâchePlanifiéeRappel1mois, + tâchePlanifiéeRappel2mois, + }: Options, ) { if (!type) { return; @@ -40,6 +56,14 @@ export async function importerType( }, }; + await this.ajouterTâchesPlanifiées({ + dateÉchéance, + tâchePlanifiéeEchoir, + tâchePlanifiéeRappel1mois, + tâchePlanifiéeRappel2mois, + estAchevé, + }); + await this.publish(event); } diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.command.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.command.ts" index 4a8c25b255..ffca815801 100644 --- "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.command.ts" +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/importer/importerTypeGarantiesFinanci\303\250res.command.ts" @@ -3,9 +3,12 @@ import { Message, MessageHandler, mediator } from 'mediateur'; import { IdentifiantProjet } from '@potentiel-domain/common'; import { LoadAggregate } from '@potentiel-domain/core'; import { Candidature } from '@potentiel-domain/candidature'; +import { loadTâchePlanifiéeAggregateFactory } from '@potentiel-domain/tache-planifiee'; import { loadGarantiesFinancièresFactory } from '../../garantiesFinancières.aggregate'; import { loadLauréatFactory } from '../../../lauréat.aggregate'; +import { loadAchèvementFactory } from '../../../achèvement/achèvement.aggregate'; +import * as TypeTâchePlanifiéeGarantiesFinancières from '../../typeTâchePlanifiéeGarantiesFinancières.valueType'; export type ImporterTypeGarantiesFinancièresCommand = Message< 'Lauréat.GarantiesFinancières.Command.ImporterTypeGarantiesFinancières', @@ -18,6 +21,8 @@ export const registerImporterTypeGarantiesFinancièresCommand = (loadAggregate: const loadGarantiesFinancières = loadGarantiesFinancièresFactory(loadAggregate); const loadLauréat = loadLauréatFactory(loadAggregate); const loadCandidature = Candidature.Aggregate.loadCandidatureFactory(loadAggregate); + const loadAchèvement = loadAchèvementFactory(loadAggregate); + const loadTâchePlanifiée = loadTâchePlanifiéeAggregateFactory(loadAggregate); const handler: MessageHandler = async ({ identifiantProjet, @@ -25,12 +30,31 @@ export const registerImporterTypeGarantiesFinancièresCommand = (loadAggregate: const garantiesFinancières = await loadGarantiesFinancières(identifiantProjet, false); const candidature = await loadCandidature(identifiantProjet, false); const lauréat = await loadLauréat(identifiantProjet, false); - + const achèvement = await loadAchèvement(identifiantProjet, false); + const tâchePlanifiéeEchoir = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.échoir.type, + identifiantProjet, + false, + ); + const tâchePlanifiéeRappel1mois = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, + identifiantProjet, + false, + ); + const tâchePlanifiéeRappel2mois = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, + identifiantProjet, + false, + ); await garantiesFinancières.importerType({ identifiantProjet, importéLe: lauréat.notifiéLe, type: candidature.garantiesFinancières?.type, dateÉchéance: candidature.garantiesFinancières?.dateEchéance, + estAchevé: achèvement.estAchevé(), + tâchePlanifiéeEchoir, + tâchePlanifiéeRappel1mois, + tâchePlanifiéeRappel2mois, }); }; mediator.register( diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/modifier/modifierGarantiesFinanci\303\250res.usecase.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/modifier/modifierGarantiesFinanci\303\250res.usecase.ts" index e931d81f5f..4ab7084e9c 100644 --- "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/modifier/modifierGarantiesFinanci\303\250res.usecase.ts" +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/garantiesFinanci\303\250resActuelles/modifier/modifierGarantiesFinanci\303\250res.usecase.ts" @@ -3,11 +3,10 @@ import { Message, MessageHandler, mediator } from 'mediateur'; import { DocumentProjet, EnregistrerDocumentProjetCommand } from '@potentiel-domain/document'; import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; import { IdentifiantUtilisateur } from '@potentiel-domain/utilisateur'; -import { AjouterTâchePlanifiéeCommand } from '@potentiel-domain/tache-planifiee'; import { Candidature } from '@potentiel-domain/candidature'; import { TypeDocumentGarantiesFinancières } from '../..'; -import * as TypeTâchePlanifiéeGarantiesFinancières from '../../typeTâchePlanifiéeGarantiesFinancières.valueType'; +import { AjouterTâchesPlanifiéesGarantiesFinancièresCommand } from '../../tâches-planifiées/ajouter/ajouter.command'; import { ModifierGarantiesFinancièresCommand } from './modifierGarantiesFinancières.command'; @@ -73,29 +72,13 @@ export const registerModifierGarantiesFinancièresUseCase = () => { }, }); - if (dateÉchéanceValue) { - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AjouterTâchePlanifiée', - data: { - identifiantProjet, - tâches: [ - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).ajouterNombreDeJours(1), - }, - { - typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(1), - }, - { - typeTâchePlanifiée: - TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéanceValue).retirerNombreDeMois(2), - }, - ], - }, - }); - } + await mediator.send({ + type: 'Lauréat.GarantiesFinancières.Command.AjouterTâchesPlanifiées', + data: { + identifiantProjet, + dateÉchéance, + }, + }); }; mediator.register('Lauréat.GarantiesFinancières.UseCase.ModifierGarantiesFinancières', runner); }; diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/ajouter/ajouter.behavior.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/ajouter/ajouter.behavior.ts" new file mode 100644 index 0000000000..c57f7211ce --- /dev/null +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/ajouter/ajouter.behavior.ts" @@ -0,0 +1,39 @@ +import { DateTime } from '@potentiel-domain/common'; +import { TâchePlanifiéeAggregate } from '@potentiel-domain/tache-planifiee'; + +import { GarantiesFinancièresAggregate } from '../../garantiesFinancières.aggregate'; + +type AjouterTâchesOptions = { + dateÉchéance?: DateTime.ValueType; + + // TODO remove the following options once aggregate root is available + estAchevé?: boolean; + tâchePlanifiéeEchoir: TâchePlanifiéeAggregate; + tâchePlanifiéeRappel1mois: TâchePlanifiéeAggregate; + tâchePlanifiéeRappel2mois: TâchePlanifiéeAggregate; +}; + +export async function ajouterTâchesPlanifiées( + this: GarantiesFinancièresAggregate, + { + estAchevé, + dateÉchéance, + tâchePlanifiéeEchoir, + tâchePlanifiéeRappel1mois, + tâchePlanifiéeRappel2mois, + }: AjouterTâchesOptions, +) { + if (dateÉchéance && !estAchevé) { + await tâchePlanifiéeEchoir.ajouter({ + àExécuterLe: dateÉchéance.ajouterNombreDeJours(1), + }); + + await tâchePlanifiéeRappel1mois.ajouter({ + àExécuterLe: dateÉchéance.retirerNombreDeMois(1), + }); + + await tâchePlanifiéeRappel2mois.ajouter({ + àExécuterLe: dateÉchéance.retirerNombreDeMois(2), + }); + } +} diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/ajouter/ajouter.command.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/ajouter/ajouter.command.ts" new file mode 100644 index 0000000000..97925e68eb --- /dev/null +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/ajouter/ajouter.command.ts" @@ -0,0 +1,59 @@ +import { Message, MessageHandler, mediator } from 'mediateur'; + +import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; +import { LoadAggregate } from '@potentiel-domain/core'; +import { loadTâchePlanifiéeAggregateFactory } from '@potentiel-domain/tache-planifiee'; + +import { loadGarantiesFinancièresFactory } from '../../garantiesFinancières.aggregate'; +import { loadAchèvementFactory } from '../../../achèvement/achèvement.aggregate'; +import * as TypeTâchePlanifiéeGarantiesFinancières from '../../typeTâchePlanifiéeGarantiesFinancières.valueType'; + +/** + * @deprecated Cette commande est temporaire pour permettre l'appel au behavior, + * qui à terme sera fait directement depuis le behavior appelant, via l'aggregate root. + **/ +export type AjouterTâchesPlanifiéesGarantiesFinancièresCommand = Message< + 'Lauréat.GarantiesFinancières.Command.AjouterTâchesPlanifiées', + { + identifiantProjet: IdentifiantProjet.ValueType; + dateÉchéance?: DateTime.ValueType; + } +>; + +/** @deprecated */ +export const registerAjouterTâchesPlanfiéesCommand = (loadAggregate: LoadAggregate) => { + const loadGarantiesFinancières = loadGarantiesFinancièresFactory(loadAggregate); + const loadAchèvement = loadAchèvementFactory(loadAggregate); + const loadTâchePlanifiée = loadTâchePlanifiéeAggregateFactory(loadAggregate); + const handler: MessageHandler = async ({ + identifiantProjet, + dateÉchéance, + }) => { + const garantiesFinancières = await loadGarantiesFinancières(identifiantProjet); + const achèvement = await loadAchèvement(identifiantProjet, false); + const tâchePlanifiéeEchoir = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.échoir.type, + identifiantProjet, + false, + ); + const tâchePlanifiéeRappel1mois = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, + identifiantProjet, + false, + ); + const tâchePlanifiéeRappel2mois = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, + identifiantProjet, + false, + ); + await garantiesFinancières.ajouterTâchesPlanifiées({ + tâchePlanifiéeEchoir, + tâchePlanifiéeRappel1mois, + tâchePlanifiéeRappel2mois, + dateÉchéance, + estAchevé: achèvement.estAchevé(), + }); + }; + + mediator.register('Lauréat.GarantiesFinancières.Command.AjouterTâchesPlanifiées', handler); +}; diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/annuler/annuler.behavior.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/annuler/annuler.behavior.ts" new file mode 100644 index 0000000000..64607e725f --- /dev/null +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/annuler/annuler.behavior.ts" @@ -0,0 +1,23 @@ +import { TâchePlanifiéeAggregate } from '@potentiel-domain/tache-planifiee'; + +import { GarantiesFinancièresAggregate } from '../../garantiesFinancières.aggregate'; + +type annulerTâchesOptions = { + // TODO remove the following options once aggregate root is available + tâchePlanifiéeEchoir: TâchePlanifiéeAggregate; + tâchePlanifiéeRappel1mois: TâchePlanifiéeAggregate; + tâchePlanifiéeRappel2mois: TâchePlanifiéeAggregate; +}; + +export async function annulerTâchesPlanifiées( + this: GarantiesFinancièresAggregate, + { + tâchePlanifiéeEchoir, + tâchePlanifiéeRappel1mois, + tâchePlanifiéeRappel2mois, + }: annulerTâchesOptions, +) { + await tâchePlanifiéeEchoir.annuler(); + await tâchePlanifiéeRappel1mois.annuler(); + await tâchePlanifiéeRappel2mois.annuler(); +} diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/annuler/annuler.command.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/annuler/annuler.command.ts" new file mode 100644 index 0000000000..180c1b7ab2 --- /dev/null +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/annuler/annuler.command.ts" @@ -0,0 +1,52 @@ +import { Message, MessageHandler, mediator } from 'mediateur'; + +import { IdentifiantProjet } from '@potentiel-domain/common'; +import { LoadAggregate } from '@potentiel-domain/core'; +import { loadTâchePlanifiéeAggregateFactory } from '@potentiel-domain/tache-planifiee'; + +import { loadGarantiesFinancièresFactory } from '../../garantiesFinancières.aggregate'; +import * as TypeTâchePlanifiéeGarantiesFinancières from '../../typeTâchePlanifiéeGarantiesFinancières.valueType'; + +/** + * @deprecated Cette commande est temporaire pour permettre l'appel au behavior, + * qui à terme sera fait directement depuis le behavior appelant, via l'aggregate root. + **/ +export type AnnulerTâchesPlanifiéesGarantiesFinancièresCommand = Message< + 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées', + { + identifiantProjet: IdentifiantProjet.ValueType; + } +>; + +/** @deprecated */ +export const registerAnnulerTâchesPlanifiéesCommand = (loadAggregate: LoadAggregate) => { + const loadGarantiesFinancières = loadGarantiesFinancièresFactory(loadAggregate); + const loadTâchePlanifiée = loadTâchePlanifiéeAggregateFactory(loadAggregate); + const handler: MessageHandler = async ({ + identifiantProjet, + }) => { + const garantiesFinancières = await loadGarantiesFinancières(identifiantProjet, false); + const tâchePlanifiéeEchoir = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.échoir.type, + identifiantProjet, + false, + ); + const tâchePlanifiéeRappel1mois = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois.type, + identifiantProjet, + false, + ); + const tâchePlanifiéeRappel2mois = await loadTâchePlanifiée( + TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type, + identifiantProjet, + false, + ); + await garantiesFinancières.annulerTâchesPlanifiées({ + tâchePlanifiéeEchoir, + tâchePlanifiéeRappel1mois, + tâchePlanifiéeRappel2mois, + }); + }; + + mediator.register('Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées', handler); +}; diff --git "a/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/t\303\242ches-planifi\303\251es.register.ts" "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/t\303\242ches-planifi\303\251es.register.ts" new file mode 100644 index 0000000000..1750947d31 --- /dev/null +++ "b/packages/domain/laur\303\251at/src/garantiesFinanci\303\250res/t\303\242ches-planifi\303\251es/t\303\242ches-planifi\303\251es.register.ts" @@ -0,0 +1,10 @@ +import { LoadAggregate } from '@potentiel-domain/core'; + +import { registerAjouterTâchesPlanfiéesCommand } from './ajouter/ajouter.command'; +import { registerAnnulerTâchesPlanifiéesCommand } from './annuler/annuler.command'; + +export const registerTâchesPlanifiées = (loadAggregate: LoadAggregate) => { + // commands + registerAjouterTâchesPlanfiéesCommand(loadAggregate); + registerAnnulerTâchesPlanifiéesCommand(loadAggregate); +}; diff --git "a/packages/domain/laur\303\251at/src/repr\303\251sentantL\303\251gal/saga/t\303\242chePlanifi\303\251eGestionAutomatiqueDemandeChangementExecut\303\251e.saga.ts" "b/packages/domain/laur\303\251at/src/repr\303\251sentantL\303\251gal/saga/t\303\242chePlanifi\303\251eGestionAutomatiqueDemandeChangementExecut\303\251e.saga.ts" index 64d47abc92..d718a55894 100644 --- "a/packages/domain/laur\303\251at/src/repr\303\251sentantL\303\251gal/saga/t\303\242chePlanifi\303\251eGestionAutomatiqueDemandeChangementExecut\303\251e.saga.ts" +++ "b/packages/domain/laur\303\251at/src/repr\303\251sentantL\303\251gal/saga/t\303\242chePlanifi\303\251eGestionAutomatiqueDemandeChangementExecut\303\251e.saga.ts" @@ -83,7 +83,7 @@ class TâchePlanifiéeGestionAutomatiqueDemandeChangementError extends Error { public identifiantProjet: string, ) { super( - `Impossible de traiter automatiquement la tâche planifier pour le changement de représentant légal`, + `Impossible de traiter automatiquement la tâche planifiée pour le changement de représentant légal`, ); } } diff --git "a/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.behavior.ts" "b/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.behavior.ts" index 152ab305cc..0a9162822c 100644 --- "a/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.behavior.ts" +++ "b/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.behavior.ts" @@ -15,22 +15,17 @@ export type TâchePlanifiéeAjoutéeEvent = DomainEvent< >; export type AjouterOptions = { - identifiantProjet: IdentifiantProjet.ValueType; - typeTâchePlanifiée: string; àExécuterLe: DateTime.ValueType; }; -export async function ajouter( - this: TâchePlanifiéeAggregate, - { identifiantProjet, typeTâchePlanifiée, àExécuterLe }: AjouterOptions, -) { +export async function ajouter(this: TâchePlanifiéeAggregate, { àExécuterLe }: AjouterOptions) { if (!this.àExécuterLe.estÉgaleÀ(àExécuterLe) || this.statut.estAnnulé()) { const event: TâchePlanifiéeAjoutéeEvent = { type: 'TâchePlanifiéeAjoutée-V1', payload: { ajoutéeLe: DateTime.now().formatter(), - identifiantProjet: identifiantProjet.formatter(), - typeTâchePlanifiée, + identifiantProjet: this.identifiantProjet.formatter(), + typeTâchePlanifiée: this.typeTâchePlanifiée, àExécuterLe: àExécuterLe.formatter(), }, }; @@ -40,9 +35,8 @@ export async function ajouter( export function applyTâchePlanifiéeAjoutée( this: TâchePlanifiéeAggregate, - { payload: { typeTâchePlanifiée, àExécuterLe } }: TâchePlanifiéeAjoutéeEvent, + { payload: { àExécuterLe } }: TâchePlanifiéeAjoutéeEvent, ) { - this.typeTâchePlanifiée = typeTâchePlanifiée; this.àExécuterLe = DateTime.convertirEnValueType(àExécuterLe); this.statut = StatutTâchePlanifiée.enAttenteExécution; } diff --git "a/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.command.ts" "b/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.command.ts" index d6bec46a5e..2977ae884b 100644 --- "a/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.command.ts" +++ "b/packages/domain/t\303\242che-planifi\303\251e/src/ajouter/ajouterT\303\242chePlanifi\303\251e.command.ts" @@ -26,8 +26,6 @@ export const registerAjouterTâchePlanifiéeCommand = (loadAggregate: LoadAggreg tâches.map(async ({ typeTâchePlanifiée, àExécuterLe }) => { const tâche = await loadTâchePlanifiée(typeTâchePlanifiée, identifiantProjet, false); await tâche.ajouter({ - typeTâchePlanifiée, - identifiantProjet, àExécuterLe, }); }), diff --git "a/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.behavior.ts" "b/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.behavior.ts" index ef5746ee4d..093e04666d 100644 --- "a/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.behavior.ts" +++ "b/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.behavior.ts" @@ -18,17 +18,14 @@ export type AnnulerOptions = { typeTâchePlanifiée: string; }; -export async function annuler( - this: TâchePlanifiéeAggregate, - { identifiantProjet, typeTâchePlanifiée }: AnnulerOptions, -) { +export async function annuler(this: TâchePlanifiéeAggregate) { if (this.statut.estÉgaleÀ(StatutTâchePlanifiée.enAttenteExécution)) { const event: TâchePlanifiéeAnnuléeEvent = { type: 'TâchePlanifiéeAnnulée-V1', payload: { annuléeLe: DateTime.now().formatter(), - identifiantProjet: identifiantProjet.formatter(), - typeTâchePlanifiée, + identifiantProjet: this.identifiantProjet.formatter(), + typeTâchePlanifiée: this.typeTâchePlanifiée, }, }; await this.publish(event); @@ -37,9 +34,8 @@ export async function annuler( export function applyTâchePlanifiéeAnnulée( this: TâchePlanifiéeAggregate, - { payload: { typeTâchePlanifiée, annuléeLe } }: TâchePlanifiéeAnnuléeEvent, + { payload: { annuléeLe } }: TâchePlanifiéeAnnuléeEvent, ) { - this.typeTâchePlanifiée = typeTâchePlanifiée; this.annuléeLe = DateTime.convertirEnValueType(annuléeLe); this.statut = StatutTâchePlanifiée.annulée; } diff --git "a/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.command.ts" "b/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.command.ts" index f2458893ae..af68f1f26a 100644 --- "a/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.command.ts" +++ "b/packages/domain/t\303\242che-planifi\303\251e/src/annuler/annulerT\303\242chePlanifi\303\251e.command.ts" @@ -20,10 +20,7 @@ export const registerAnnulerTâchePlanifiéeCommand = (loadAggregate: LoadAggreg typeTâchePlanifiée, }) => { const tâche = await loadTâchePlanifiée(typeTâchePlanifiée, identifiantProjet, false); - await tâche.annuler({ - typeTâchePlanifiée, - identifiantProjet, - }); + await tâche.annuler(); }; mediator.register('System.TâchePlanifiée.Command.AnnulerTâchePlanifiée', handler); }; diff --git "a/packages/domain/t\303\242che-planifi\303\251e/src/index.ts" "b/packages/domain/t\303\242che-planifi\303\251e/src/index.ts" index acb6253753..770749af6c 100644 --- "a/packages/domain/t\303\242che-planifi\303\251e/src/index.ts" +++ "b/packages/domain/t\303\242che-planifi\303\251e/src/index.ts" @@ -37,3 +37,8 @@ export * as StatutTâchePlanifiée from './statutTâchePlanifiée.valueType'; // Entities export * from './tâchePlanifiée.entity'; + +export { + loadTâchePlanifiéeAggregateFactory, + TâchePlanifiéeAggregate, +} from './tâchePlanifiée.aggregate'; diff --git "a/packages/domain/t\303\242che-planifi\303\251e/src/t\303\242chePlanifi\303\251e.aggregate.ts" "b/packages/domain/t\303\242che-planifi\303\251e/src/t\303\242chePlanifi\303\251e.aggregate.ts" index 5b62eda566..515f931ce2 100644 --- "a/packages/domain/t\303\242che-planifi\303\251e/src/t\303\242chePlanifi\303\251e.aggregate.ts" +++ "b/packages/domain/t\303\242che-planifi\303\251e/src/t\303\242chePlanifi\303\251e.aggregate.ts" @@ -1,4 +1,4 @@ -import { Aggregate, GetDefaultAggregateState, LoadAggregate } from '@potentiel-domain/core'; +import { Aggregate, AggregateState, LoadAggregate } from '@potentiel-domain/core'; import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; import * as StatutTâchePlanifiée from './statutTâchePlanifiée.valueType'; @@ -25,8 +25,9 @@ export type TâchePlanifiéeEvent = | TâchePlanifiéeExecutéeEvent; export type TâchePlanifiéeAggregate = Aggregate & { + readonly identifiantProjet: IdentifiantProjet.ValueType; + readonly typeTâchePlanifiée: string; statut: StatutTâchePlanifiée.ValueType; - typeTâchePlanifiée: string; àExécuterLe: DateTime.ValueType; annuléeLe?: DateTime.ValueType; ajouter: typeof ajouter; @@ -34,13 +35,14 @@ export type TâchePlanifiéeAggregate = Aggregate & { exécuter: typeof exécuter; }; -export const getDefaultTâchePlanifiéeAggregate: GetDefaultAggregateState< - TâchePlanifiéeAggregate, - TâchePlanifiéeEvent -> = () => ({ - statut: StatutTâchePlanifiée.inconnu, +export const getDefaultTâchePlanifiéeAggregate = ( + typeTâchePlanifiée: string, + identifiantProjet: IdentifiantProjet.ValueType, +): AggregateState => ({ apply, - typeTâchePlanifiée: 'inconnue', + statut: StatutTâchePlanifiée.inconnu, + identifiantProjet, + typeTâchePlanifiée: typeTâchePlanifiée, àExécuterLe: DateTime.now(), ajouter, annuler, @@ -66,7 +68,7 @@ export const loadTâchePlanifiéeAggregateFactory = (type: string, identifiantProjet: IdentifiantProjet.ValueType, throwOnNone = true) => { return loadAggregate({ aggregateId: `tâche-planifiée|${type}#${identifiantProjet.formatter()}`, - getDefaultAggregate: getDefaultTâchePlanifiéeAggregate, + getDefaultAggregate: () => getDefaultTâchePlanifiéeAggregate(type, identifiantProjet), onNone: throwOnNone ? () => { throw new TâchePlanifiéeInconnueError(type, identifiantProjet.formatter()); diff --git "a/packages/domain/t\303\242che/src/saga/t\303\242cheGarantiesFinanci\303\250res.saga.ts" "b/packages/domain/t\303\242che/src/saga/t\303\242cheGarantiesFinanci\303\250res.saga.ts" index 4dc3ff6939..378efb7d33 100644 --- "a/packages/domain/t\303\242che/src/saga/t\303\242cheGarantiesFinanci\303\250res.saga.ts" +++ "b/packages/domain/t\303\242che/src/saga/t\303\242cheGarantiesFinanci\303\250res.saga.ts" @@ -1,8 +1,7 @@ import { Message, MessageHandler, mediator } from 'mediateur'; import { GarantiesFinancières } from '@potentiel-domain/laureat'; -import { DateTime, IdentifiantProjet } from '@potentiel-domain/common'; -import { AjouterTâchePlanifiéeCommand } from '@potentiel-domain/tache-planifiee'; +import { IdentifiantProjet } from '@potentiel-domain/common'; import { AjouterTâcheCommand } from '../ajouter/ajouterTâche.command'; import { AcheverTâcheCommand } from '../achever/acheverTâche.command'; @@ -11,8 +10,7 @@ import * as Tâche from '../typeTâche.valueType'; export type SubscriptionEvent = | GarantiesFinancières.GarantiesFinancièresDemandéesEvent | GarantiesFinancières.DépôtGarantiesFinancièresSoumisEvent - | GarantiesFinancières.GarantiesFinancièresEnregistréesEvent - | GarantiesFinancières.TypeGarantiesFinancièresImportéEvent; + | GarantiesFinancières.GarantiesFinancièresEnregistréesEvent; export type Execute = Message<'System.Saga.TâcheGarantiesFinancières', SubscriptionEvent>; @@ -41,39 +39,6 @@ export const register = () => { }, }); break; - case 'TypeGarantiesFinancièresImporté-V1': - const { - payload: { dateÉchéance }, - } = event; - - if (dateÉchéance) { - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AjouterTâchePlanifiée', - data: { - identifiantProjet: IdentifiantProjet.convertirEnValueType(identifiantProjet), - tâches: [ - { - typeTâchePlanifiée: - GarantiesFinancières.TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéance).ajouterNombreDeJours(1), - }, - { - typeTâchePlanifiée: - GarantiesFinancières.TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceUnMois - .type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéance).retirerNombreDeMois(1), - }, - { - typeTâchePlanifiée: - GarantiesFinancières.TypeTâchePlanifiéeGarantiesFinancières - .rappelÉchéanceDeuxMois.type, - àExécuterLe: DateTime.convertirEnValueType(dateÉchéance).retirerNombreDeMois(2), - }, - ], - }, - }); - } - break; } }; diff --git a/packages/domain/utilisateur/src/role.valueType.ts b/packages/domain/utilisateur/src/role.valueType.ts index 2d800fbea2..108b0985ba 100644 --- a/packages/domain/utilisateur/src/role.valueType.ts +++ b/packages/domain/utilisateur/src/role.valueType.ts @@ -221,6 +221,8 @@ const référencielPermissions = { 'Lauréat.GarantiesFinancières.Mainlevée.Command.AccorderDemandeMainlevée', rejeterDemandeMainlevée: 'Lauréat.GarantiesFinancières.Mainlevée.Command.RejeterDemandeMainlevée', + ajouterTâchesPlanifiées: 'Lauréat.GarantiesFinancières.Command.AjouterTâchesPlanifiées', + annulerTâchesPlanifiées: 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées', }, }, achèvement: { @@ -468,6 +470,7 @@ const policies = { référencielPermissions.lauréat.abandon.query.consulter, référencielPermissions.lauréat.abandon.usecase.accorder, référencielPermissions.lauréat.abandon.command.accorder, + référencielPermissions.lauréat.garantiesFinancières.command.annulerTâchesPlanifiées, ], rejeter: [ référencielPermissions.candidature.query.consulterProjet, @@ -586,17 +589,20 @@ const policies = { référencielPermissions.lauréat.garantiesFinancières.usecase.soumettre, référencielPermissions.lauréat.garantiesFinancières.command.soumettre, référencielPermissions.document.command.enregister, + référencielPermissions.lauréat.garantiesFinancières.command.annulerTâchesPlanifiées, ], valider: [ référencielPermissions.lauréat.garantiesFinancières.usecase.valider, référencielPermissions.lauréat.garantiesFinancières.command.valider, référencielPermissions.document.command.déplacer, + référencielPermissions.lauréat.garantiesFinancières.command.ajouterTâchesPlanifiées, ], supprimer: [ référencielPermissions.lauréat.garantiesFinancières.usecase .supprimerGarantiesFinancièresÀTraiter, référencielPermissions.lauréat.garantiesFinancières.command .supprimerGarantiesFinancièresÀTraiter, + référencielPermissions.lauréat.garantiesFinancières.command.ajouterTâchesPlanifiées, ], modifier: [ référencielPermissions.appelOffre.query.consulter, @@ -632,6 +638,7 @@ const policies = { référencielPermissions.document.command.enregister, référencielPermissions.lauréat.garantiesFinancières.usecase.modifier, référencielPermissions.lauréat.garantiesFinancières.command.modifier, + référencielPermissions.lauréat.garantiesFinancières.command.ajouterTâchesPlanifiées, ], enregistrerAttestation: [ référencielPermissions.appelOffre.query.consulter, @@ -643,6 +650,7 @@ const policies = { référencielPermissions.document.command.enregister, référencielPermissions.lauréat.garantiesFinancières.usecase.enregistrer, référencielPermissions.lauréat.garantiesFinancières.command.enregistrer, + référencielPermissions.lauréat.garantiesFinancières.command.ajouterTâchesPlanifiées, ], }, mainlevée: { @@ -699,6 +707,7 @@ const policies = { transmettre: [ référencielPermissions.lauréat.achèvement.useCase.transmettre, référencielPermissions.lauréat.achèvement.command.transmettre, + référencielPermissions.lauréat.garantiesFinancières.command.annulerTâchesPlanifiées, référencielPermissions.document.command.enregister, ], modifier: [ diff --git "a/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/modifierGarantiesFinanci\303\250resActuelles.feature" "b/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/modifierGarantiesFinanci\303\250resActuelles.feature" index 5e3991a812..d93b1e8272 100644 --- "a/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/modifierGarantiesFinanci\303\250resActuelles.feature" +++ "b/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/modifierGarantiesFinanci\303\250resActuelles.feature" @@ -98,3 +98,14 @@ Fonctionnalité: Modifier des garanties financières actuelles Quand un admin modifie les garanties financières actuelles pour le projet "Du boulodrome de Marseille" avec : | date de constitution | 2020-01-01 | Alors l'utilisateur devrait être informé que "Vous ne pouvez pas déposer ou modifier des garanties financières car elles ont déjà été levées pour ce projet" + + Scénario: Une tâche du type "échoir les garanties financières" n'est pas ajoutée si une attestation de conformité est déjà transmise + Etant donné des garanties financières actuelles pour le projet "Du boulodrome de Marseille" avec : + | type GF | avec-date-échéance | + | date d'échéance | 2024-12-01 | + | date de validation | 2024-11-24 | + Et une attestation de conformité transmise pour le projet lauréat + Quand un admin modifie les garanties financières actuelles pour le projet "Du boulodrome de Marseille" avec : + | type GF | avec-date-échéance | + | date d'échéance | 2024-12-02 | + Alors une tâche "échoir les garanties financières" n'est plus planifiée pour le projet "Du boulodrome de Marseille" diff --git "a/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/stepDefinitions/garantiesFinanci\303\250resActuelles.when.ts" "b/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/stepDefinitions/garantiesFinanci\303\250resActuelles.when.ts" index 933f601d17..fea4307bb9 100644 --- "a/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/stepDefinitions/garantiesFinanci\303\250resActuelles.when.ts" +++ "b/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/stepDefinitions/garantiesFinanci\303\250resActuelles.when.ts" @@ -2,11 +2,7 @@ import { DataTable, When as Quand } from '@cucumber/cucumber'; import { mediator } from 'mediateur'; import { GarantiesFinancières } from '@potentiel-domain/laureat'; -import { - AjouterTâchePlanifiéeCommand, - ExécuterTâchePlanifiéeUseCase, -} from '@potentiel-domain/tache-planifiee'; -import { DateTime } from '@potentiel-domain/common'; +import { ExécuterTâchePlanifiéeUseCase } from '@potentiel-domain/tache-planifiee'; import { PotentielWorld } from '../../../../../potentiel.world'; import { corrigerCandidature } from '../../../../../candidature/stepDefinitions/candidature.when'; @@ -103,28 +99,11 @@ Quand( ); Quand( - `un admin échoie les garanties financières actuelles pour le projet {string} avec :`, - async function (this: PotentielWorld, nomProjet: string, dataTable: DataTable) { - const exemple = dataTable.rowsHash(); + `un admin échoie les garanties financières actuelles pour le projet {string}`, + async function (this: PotentielWorld, nomProjet: string) { try { const { identifiantProjet } = this.lauréatWorld.rechercherLauréatFixture(nomProjet); - const échuLeValue = new Date(exemple['à échoir le']).toISOString(); - - await mediator.send({ - type: 'System.TâchePlanifiée.Command.AjouterTâchePlanifiée', - data: { - identifiantProjet, - tâches: [ - { - typeTâchePlanifiée: - GarantiesFinancières.TypeTâchePlanifiéeGarantiesFinancières.échoir.type, - àExécuterLe: DateTime.convertirEnValueType(échuLeValue), - }, - ], - }, - }); - await mediator.send({ type: 'System.TâchePlanifiée.UseCase.ExécuterTâchePlanifiée', data: { diff --git "a/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/\303\251choirGarantiesFinanci\303\250resActuelles.feature" "b/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/\303\251choirGarantiesFinanci\303\250resActuelles.feature" index bc09a70c0b..72ee0fdf43 100644 --- "a/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/\303\251choirGarantiesFinanci\303\250resActuelles.feature" +++ "b/packages/specifications/src/projet/laur\303\251at/garantiesFinanci\303\250res/actuelles/\303\251choirGarantiesFinanci\303\250resActuelles.feature" @@ -10,8 +10,7 @@ Fonctionnalité: Échoir les garanties financières actuelles d'un projet Etant donné des garanties financières actuelles pour le projet "Du boulodrome de Marseille" avec : | type GF | avec-date-échéance | | date d'échéance | 2024-07-17 | - Quand un admin échoie les garanties financières actuelles pour le projet "Du boulodrome de Marseille" avec : - | à échoir le | 2024-07-18 | + Quand un admin échoie les garanties financières actuelles pour le projet "Du boulodrome de Marseille" Alors les garanties financières actuelles du projet "Du boulodrome de Marseille" sont échues Et un email a été envoyé au porteur avec : | sujet | Potentiel - Date d'échéance dépassée pour les garanties financières du projet Du boulodrome de Marseille dans le département(.*) | @@ -29,7 +28,7 @@ Fonctionnalité: Échoir les garanties financières actuelles d'un projet Et une demande d'abandon en cours pour le projet lauréat Quand le DGEC validateur accorde l'abandon pour le projet lauréat Alors l'abandon du projet lauréat devrait être accordé - Et une tâche indiquant de "échoir les garanties financières" n'est plus consultable dans la liste des tâches du porteur pour le projet + Et une tâche "échoir les garanties financières" n'est plus planifiée pour le projet "Du boulodrome de Marseille" @NotImplemented Scénario: Impossible d'échoir les garanties financières actuelles d'un projet si il n'y a pas de garanties financières actuelles pour ce projet diff --git "a/packages/specifications/src/t\303\242che/t\303\242che.world.ts" "b/packages/specifications/src/t\303\242che/t\303\242che.world.ts" index 73ea165fdd..3cd2d2c03f 100644 --- "a/packages/specifications/src/t\303\242che/t\303\242che.world.ts" +++ "b/packages/specifications/src/t\303\242che/t\303\242che.world.ts" @@ -5,7 +5,6 @@ export type RechercherTypeTâche = | 'confirmer un abandon' | 'transmettre les garanties financières' | 'mettre à jour le gestionnaire de réseau' - | 'échoir les garanties financières' | 'transmettre une référence de raccordement'; export class TâcheWorld { @@ -15,8 +14,6 @@ export class TâcheWorld { return TypeTâche.abandonTransmettrePreuveRecandidature; case 'confirmer un abandon': return TypeTâche.abandonConfirmer; - case 'échoir les garanties financières': - return TypeTâche.garantiesFinancieresEchoir; case 'transmettre les garanties financières': return TypeTâche.garantiesFinancièresDemander; case 'mettre à jour le gestionnaire de réseau':