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

♻️ Ne pas ajouter de tâche planifiée GF pour un projet achevé #2738

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/applications/bootstrap/src/setupTâche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TâcheGarantiesFinancièresSaga.Execute>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -66,27 +64,10 @@ export const registerAccorderAbandonUseCase = () => {
},
});

await mediator.send<AnnulerTâchePlanifiéeCommand>({
type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée',
data: {
identifiantProjet,
typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type,
},
});

await mediator.send<AnnulerTâchePlanifiéeCommand>({
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<AnnulerTâchePlanifiéeCommand>({
type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée',
await mediator.send<AnnulerTâchesPlanifiéesGarantiesFinancièresCommand>({
type: 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées',
data: {
identifiantProjet,
typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type,
},
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -85,27 +84,10 @@ export const registerTransmettreAttestationConformitéUseCase = () => {
},
});

await mediator.send<AnnulerTâchePlanifiéeCommand>({
type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée',
await mediator.send<AnnulerTâchesPlanifiéesGarantiesFinancièresCommand>({
type: 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées',
data: {
identifiantProjet,
typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type,
},
});

await mediator.send<AnnulerTâchePlanifiéeCommand>({
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<AnnulerTâchePlanifiéeCommand>({
type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée',
data: {
identifiantProjet,
typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type,
},
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -74,27 +73,10 @@ export const registerSoumettreDépôtGarantiesFinancièresUseCase = () => {
},
});

await mediator.send<AnnulerTâchePlanifiéeCommand>({
type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée',
await mediator.send<AnnulerTâchesPlanifiéesGarantiesFinancièresCommand>({
type: 'Lauréat.GarantiesFinancières.Command.AnnulerTâchesPlanifiées',
data: {
identifiantProjet,
typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.échoir.type,
},
});

await mediator.send<AnnulerTâchePlanifiéeCommand>({
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<AnnulerTâchePlanifiéeCommand>({
type: 'System.TâchePlanifiée.Command.AnnulerTâchePlanifiée',
data: {
identifiantProjet,
typeTâchePlanifiée: TypeTâchePlanifiéeGarantiesFinancières.rappelÉchéanceDeuxMois.type,
},
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -38,29 +37,15 @@ export const registerSupprimerGarantiesFinancièresÀTraiterUseCase = () => {
},
});

if (dateÉchéanceValue) {
await mediator.send<AjouterTâchePlanifiéeCommand>({
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<AjouterTâchesPlanifiéesGarantiesFinancièresCommand>({
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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -54,29 +53,15 @@ export const registerValiderDépôtGarantiesFinancièresEnCoursUseCase = () => {
},
});

if (dateÉchéanceValue) {
await mediator.send<AjouterTâchePlanifiéeCommand>({
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<AjouterTâchesPlanifiéesGarantiesFinancièresCommand>({
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -155,6 +157,8 @@ export type GarantiesFinancièresAggregate = Aggregate<GarantiesFinancièresEven
readonly démarrerInstructionDemandeMainlevée: typeof démarrerInstructionDemandeMainlevée;
readonly rejeterDemandeMainlevéeGarantiesFinancières: typeof rejeterDemandeMainlevéeGarantiesFinancières;
readonly accorderDemandeMainlevéeGarantiesFinancières: typeof accorderDemandeMainlevéeGarantiesFinancières;
readonly ajouterTâchesPlanifiées: typeof ajouterTâchesPlanifiées;
readonly annulerTâchesPlanifiées: typeof annulerTâchesPlanifiées;
};

export const getDefaultGarantiesFinancièresAggregate: GetDefaultAggregateState<
Expand All @@ -179,6 +183,8 @@ export const getDefaultGarantiesFinancièresAggregate: GetDefaultAggregateState<
rejeterDemandeMainlevéeGarantiesFinancières,
accorderDemandeMainlevéeGarantiesFinancières,
échoir,
ajouterTâchesPlanifiées,
annulerTâchesPlanifiées,
});

function apply(this: GarantiesFinancièresAggregate, event: GarantiesFinancièresEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { registerMainlevée } from './mainlevée/mainlevée.register';
import { registerDépôt } from './dépôtEnCours/dépôt.register';
import { registerGarantiesFinancières } from './garantiesFinancièresActuelles/garantiesFinancières.register';
import { registerConsulterArchivesGarantiesFinancièresQuery } from './garantiesFinancièresActuelles/consulterArchives/consulterArchivesGarantiesFinancières.query';
import { registerTâchesPlanifiées } from './tâches-planifiées/tâches-planifiées.register';

export type GarantiesFinancièresQueryDependencies = ConsulterGarantiesFinancièresDependencies &
ListerDépôtsEnCoursGarantiesFinancièresDependencies &
Expand All @@ -34,6 +35,7 @@ export const registerGarantiesFinancièresUseCases = ({
registerDépôt(loadAggregate);
registerGarantiesFinancières(loadAggregate);
registerMainlevée(loadAggregate);
registerTâchesPlanifiées(loadAggregate);
};

export const registerGarantiesFinancièresQueries = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { EnregistrerGarantiesFinancièresCommand } from './enregistrerGarantiesFinancières.command';

Expand Down Expand Up @@ -73,29 +72,15 @@ export const registerEnregistrerGarantiesFinancièresUseCase = () => {
},
});

if (dateÉchéanceValue) {
await mediator.send<AjouterTâchePlanifiéeCommand>({
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<AjouterTâchesPlanifiéesGarantiesFinancièresCommand>({
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);
};
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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);
}

Expand Down
Loading
Loading