Skip to content

Commit

Permalink
feat(api): autonomous candidacy are now forced into an "hors_platefor…
Browse files Browse the repository at this point in the history
…me" finance module when feasibility file is submitted
  • Loading branch information
agarbe committed Nov 15, 2024
1 parent edbbb57 commit 31556e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { FinanceModule } from "@prisma/client";
import { prismaClient } from "../../../prisma/client";

export const updateCandidacyFinanceModule = ({
candidacyId,
financeModule,
}: {
candidacyId: string;
financeModule: FinanceModule;
}) =>
prismaClient.candidacy.update({
where: { id: candidacyId },
data: { financeModule },
});
10 changes: 10 additions & 0 deletions packages/reva-api/modules/feasibility/feasibility.features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
} from "./utils/feasibility.helper";
import { deleteFeasibilityIDFile } from "./features/deleteFeasibilityIDFile";
import { allowFileTypeByDocumentType } from "../../modules/shared/file/allowFileTypes";
import { updateCandidacyFinanceModule } from "../candidacy/features/updateCandidacyFinanceModule";

const baseUrl = process.env.BASE_URL || "https://vae.gouv.fr";

Expand Down Expand Up @@ -278,6 +279,15 @@ export const createFeasibility = async ({
status: "DOSSIER_FAISABILITE_ENVOYE",
});

// If the candidacy is autonomous, we update the finance module to "hors_plateforme"
// It handles the case where the candidacy was created as 'accompagne' with a unifvae finance module and it switched to autonomous
if (candidacy.typeAccompagnement === "AUTONOME") {
await updateCandidacyFinanceModule({
candidacyId,
financeModule: "hors_plateforme",
});
}

const candidacyCertificationId = candidacy?.certificationId;
const candidacyDepartmentId = candidacy?.departmentId;

Expand Down

0 comments on commit 31556e0

Please sign in to comment.