diff --git a/packages/reva-api/modules/feasibility/feasibility.search-count.test.ts b/packages/reva-api/modules/feasibility/feasibility.search-count.test.ts index b626b986e..8c9a9fdaf 100644 --- a/packages/reva-api/modules/feasibility/feasibility.search-count.test.ts +++ b/packages/reva-api/modules/feasibility/feasibility.search-count.test.ts @@ -43,6 +43,32 @@ beforeAll(async () => { createFeasibilityUploadedPdfHelper({ decision: "COMPLETE", }), + // The status of below candidacies is incompatible with the decision + // about the feasibility file. They should be ignored by the API (not counted, not returned) + createFeasibilityUploadedPdfHelper( + { + decision: "PENDING", + }, + "PROJET", + ), + createFeasibilityUploadedPdfHelper( + { + decision: "PENDING", + }, + "PARCOURS_ENVOYE", + ), + createFeasibilityUploadedPdfHelper( + { + decision: "PENDING", + }, + "PARCOURS_CONFIRME", + ), + createFeasibilityUploadedPdfHelper( + { + decision: "PENDING", + }, + "DOSSIER_DE_VALIDATION_ENVOYE", + ), ]); await createCandidacyHelper({ candidacyActiveStatus: "ARCHIVE", diff --git a/packages/reva-api/modules/feasibility/feasibility.test.ts b/packages/reva-api/modules/feasibility/feasibility.test.ts index 78865287d..0df0e2f1a 100644 --- a/packages/reva-api/modules/feasibility/feasibility.test.ts +++ b/packages/reva-api/modules/feasibility/feasibility.test.ts @@ -52,6 +52,7 @@ test("should count all (1) available feasibility for certificator user even if o const candidacy = await createCandidacyHelper({ candidacyArgs: { certificationId: certification.id, + status: "DOSSIER_FAISABILITE_ENVOYE", }, }); await createFeasibilityUploadedPdfHelper({ @@ -178,6 +179,7 @@ test("should return all (1) available feasibility for certificateur user", async candidacyArgs: { certificationId: certification.id, }, + candidacyActiveStatus: "DOSSIER_FAISABILITE_ENVOYE", }); const feasibility = await createFeasibilityUploadedPdfHelper({ decision: "PENDING", diff --git a/packages/reva-api/modules/feasibility/utils/feasibility.helper.ts b/packages/reva-api/modules/feasibility/utils/feasibility.helper.ts index 165225544..871fb7f09 100644 --- a/packages/reva-api/modules/feasibility/utils/feasibility.helper.ts +++ b/packages/reva-api/modules/feasibility/utils/feasibility.helper.ts @@ -9,8 +9,16 @@ export type FeasibilityStatusFilter = export const excludeArchivedAndDroppedOutCandidacy: Prisma.FeasibilityWhereInput = { candidacy: { - candidacyStatuses: { none: { isActive: true, status: "ARCHIVE" } }, candidacyDropOut: { is: null }, + status: { + in: [ + "DOSSIER_FAISABILITE_ENVOYE", + "DOSSIER_FAISABILITE_COMPLET", + "DOSSIER_FAISABILITE_INCOMPLET", + "DOSSIER_FAISABILITE_RECEVABLE", + "DOSSIER_FAISABILITE_NON_RECEVABLE", + ], + }, }, }; @@ -21,11 +29,13 @@ export const excludeRejectedArchivedDraftAndDroppedOutCandidacy: Prisma.Feasibil decision: { in: ["REJECTED", "DRAFT"] }, }, candidacy: { - candidacyStatuses: { - none: { - isActive: true, - status: "ARCHIVE", - }, + status: { + in: [ + "DOSSIER_FAISABILITE_ENVOYE", + "DOSSIER_FAISABILITE_COMPLET", + "DOSSIER_FAISABILITE_INCOMPLET", + "DOSSIER_FAISABILITE_RECEVABLE", + ], }, candidacyDropOut: { is: null }, }, diff --git a/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts b/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts index 8621c75bf..c12b6e9a7 100644 --- a/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts +++ b/packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts @@ -1,12 +1,16 @@ -import { Feasibility } from "@prisma/client"; +import { CandidacyStatusStep, Feasibility } from "@prisma/client"; import { prismaClient } from "../../../prisma/client"; import { createCandidacyHelper } from "./create-candidacy-helper"; import { createFileHelper } from "./create-file-helper"; export const createFeasibilityUploadedPdfHelper = async ( feasibilityArgs?: Partial, + candidacyActiveStatus?: CandidacyStatusStep, ) => { - const candidacy = await createCandidacyHelper(); + const candidacy = await createCandidacyHelper({ + candidacyActiveStatus: + candidacyActiveStatus ?? "DOSSIER_FAISABILITE_ENVOYE", + }); const file = await createFileHelper(); return prismaClient.feasibility.create({