Skip to content

Commit

Permalink
fix(decision): premiere dom
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Jan 2, 2024
1 parent abe0ed5 commit dba99ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
usagerHistoryRepository,
usagerRepository,
} from "../database";
import { UsagerDecision, UsagerEntretien } from "@domifa/common";
import { UsagerDecision, UsagerEntretien, UsagerTypeDom } from "@domifa/common";
import {
TOULOUSE_STRUCTURE_ID,
TOULOUSE_USER_ID,
Expand Down Expand Up @@ -165,6 +165,13 @@ export class ImportDecisionsMigration1692216772744
states: [],
});

const typeDom: UsagerTypeDom =
{ ...uniqueDecision }.filter(
(decision) => decision.statut === "VALIDE"
).length > 1 || usager.typeDom === "RENOUVELLEMENT"
? "RENOUVELLEMENT"
: "PREMIERE_DOM";

for (const decision of uniqueDecision) {
usager.decision = decision;
usager.historique.push(decision);
Expand All @@ -179,6 +186,7 @@ export class ImportDecisionsMigration1692216772744
decision.statut === "INSTRUCTION") &&
(previousState?.isActive ?? false));

decision.typeDom = typeDom;
const state: UsagerHistoryState = {
uuid: uuidv4(),
createdAt: startOfDay(new Date(decision.dateDebut)),
Expand All @@ -187,7 +195,7 @@ export class ImportDecisionsMigration1692216772744
historyBeginDate: startOfDay(new Date(decision.dateDebut)),
historyEndDate: undefined,
decision,
typeDom: usager.typeDom,
typeDom,
etapeDemande: usager.etapeDemande,
entretien: {
domiciliation: null,
Expand Down Expand Up @@ -229,6 +237,7 @@ export class ImportDecisionsMigration1692216772744
decision: usager.decision,
historique: usager.historique,
migrated: true,
typeDom,
}
);
}
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,7 @@ __metadata:
"@types/uuid": ^9.0.7
"@typescript-eslint/eslint-plugin": ^6.16.0
"@typescript-eslint/parser": ^6.16.0
"@wmfs/xml2csv": ^1.32.0
axios: ^1.6.2
bcryptjs: ^2.4.3
cache-manager: ^5.3.2
Expand Down

0 comments on commit dba99ce

Please sign in to comment.