Skip to content

Commit 940034d

Browse files
authored
feat(api): map SUIT declarations export to GIP labels (#3206) (#3227)
1 parent 56df18c commit 940034d

6 files changed

Lines changed: 618 additions & 388 deletions

File tree

packages/app/src/app/api/v1/export/declarations/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ async function apiExportDeclarationsHandler(
9393
});
9494

9595
return Response.json({
96-
dateBegin: date_begin,
97-
dateEnd: dateEnd,
98-
count: data.length,
99-
declarations: data,
96+
Date_debut: date_begin,
97+
Date_fin: dateEnd,
98+
Nombre: data.length,
99+
Declarations: data,
100100
});
101101
} catch (error) {
102102
console.error("[api/v1/export/declarations]", error);

packages/app/src/modules/export/__tests__/exportApi.test.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ describe("GET /api/v1/export/declarations", () => {
144144

145145
expect(response.status).toBe(200);
146146
const body = await response.json();
147-
expect(body.count).toBe(0);
148-
expect(body.declarations).toEqual([]);
149-
expect(body.dateBegin).toBe("2027-03-15");
150-
expect(body.dateEnd).toBe("2027-03-16");
147+
expect(body.Nombre).toBe(0);
148+
expect(body.Declarations).toEqual([]);
149+
expect(body.Date_debut).toBe("2027-03-15");
150+
expect(body.Date_fin).toBe("2027-03-16");
151151
expect(mockFetchSubmitted).toHaveBeenCalledWith("2027-03-15", "2027-03-16");
152152
});
153153

@@ -160,7 +160,7 @@ describe("GET /api/v1/export/declarations", () => {
160160

161161
expect(response.status).toBe(200);
162162
const body = await response.json();
163-
expect(body.dateEnd).toBe("2027-03-20");
163+
expect(body.Date_fin).toBe("2027-03-20");
164164
expect(mockFetchSubmitted).toHaveBeenCalledWith("2027-03-15", "2027-03-20");
165165
});
166166

@@ -238,7 +238,7 @@ describe("GET /api/v1/export/declarations", () => {
238238

239239
expect(response.status).toBe(200);
240240
const body = await response.json();
241-
expect(body.count).toBe(2);
241+
expect(body.Nombre).toBe(2);
242242

243243
expect(mockFetchIndicatorG).toHaveBeenCalledWith(["decl-1", "decl-2"]);
244244
expect(mockFetchCse).toHaveBeenCalledWith(["decl-1", "decl-2"]);
@@ -288,20 +288,20 @@ describe("GET /api/v1/export/declarations", () => {
288288

289289
expect(response.status).toBe(200);
290290
const body = await response.json();
291-
expect(body.count).toBe(1);
292-
293-
const decl = body.declarations[0];
294-
expect(decl.siren).toBe("123456789");
295-
expect(decl.declarant.email).toBe("jean@acme.fr");
296-
expect(decl.indicators.A.annualWomen).toBe("35000");
297-
expect(decl.indicators.A.annualMen).toBe("38000");
298-
expect(decl.indicators.A.hourlyWomen).toBeNull();
299-
expect(decl.indicators.G).toBeNull();
300-
expect(decl.indicators.F.annual).toHaveLength(4);
301-
expect(decl.secondDeclaration.correction).toBeNull();
302-
expect(decl).not.toHaveProperty("cseOpinions");
303-
expect(decl).not.toHaveProperty("cseFiles");
304-
expect(decl).not.toHaveProperty("jointEvaluationFile");
291+
expect(body.Nombre).toBe(1);
292+
293+
const decl = body.Declarations[0];
294+
expect(decl.SIREN).toBe("123456789");
295+
expect(decl.Declarant.Email).toBe("jean@acme.fr");
296+
expect(decl.Indicateurs.A.Rem_globale_annuelle_moyenne_F).toBe("35000");
297+
expect(decl.Indicateurs.A.Rem_globale_annuelle_moyenne_H).toBe("38000");
298+
expect(decl.Indicateurs.A.Taux_horaire_global_moyen_F).toBeNull();
299+
expect(decl.Indicateurs.G).toBeNull();
300+
expect(decl.Indicateurs.F.annuel.Seuil_Q1_Rem_globale).toBeNull();
301+
expect(decl.Seconde_declaration.Correction).toBeNull();
302+
expect(decl).not.toHaveProperty("Avis_CSE");
303+
expect(decl).not.toHaveProperty("Fichiers_CSE");
304+
expect(decl).not.toHaveProperty("Fichier_evaluation_conjointe");
305305
});
306306

307307
it("should expose CSE opinion declarationNumber alongside type", async () => {
@@ -378,18 +378,18 @@ describe("GET /api/v1/export/declarations", () => {
378378

379379
expect(response.status).toBe(200);
380380
const body = await response.json();
381-
expect(body.declarations[0].cseOpinions).toEqual([
381+
expect(body.Declarations[0].Avis_CSE).toEqual([
382382
{
383-
declarationNumber: 1,
384-
type: "accuracy",
385-
opinion: "favorable",
386-
date: "2027-03-01",
383+
Numero_declaration: 1,
384+
Type: "accuracy",
385+
Avis: "favorable",
386+
Date: "2027-03-01",
387387
},
388388
{
389-
declarationNumber: 2,
390-
type: "gap",
391-
opinion: "unfavorable",
392-
date: "2027-06-01",
389+
Numero_declaration: 2,
390+
Type: "gap",
391+
Avis: "unfavorable",
392+
Date: "2027-06-01",
393393
},
394394
]);
395395
});
@@ -450,13 +450,13 @@ describe("GET /api/v1/export/declarations", () => {
450450
{ siren: "123456789", year: 2027 },
451451
]);
452452
const body = await response.json();
453-
expect(body.declarations[0].cseFiles).toEqual([
453+
expect(body.Declarations[0].Fichiers_CSE).toEqual([
454454
{
455-
id: "file-abc",
456-
type: "cse_opinion",
457-
fileName: "avis-cse-2027.pdf",
458-
uploadedAt: "2027-03-10T08:30:00.000Z",
459-
downloadUrl: "/api/v1/files/file-abc",
455+
Id: "file-abc",
456+
Type: "cse_opinion",
457+
Nom_fichier: "avis-cse-2027.pdf",
458+
Date_upload: "2027-03-10T08:30:00.000Z",
459+
URL_telechargement: "/api/v1/files/file-abc",
460460
},
461461
]);
462462
});
@@ -512,8 +512,8 @@ describe("GET /api/v1/export/declarations", () => {
512512

513513
expect(response.status).toBe(200);
514514
const body = await response.json();
515-
expect(body.declarations[0]).not.toHaveProperty("cseOpinions");
516-
expect(body.declarations[0]).not.toHaveProperty("cseFiles");
515+
expect(body.Declarations[0]).not.toHaveProperty("Avis_CSE");
516+
expect(body.Declarations[0]).not.toHaveProperty("Fichiers_CSE");
517517
});
518518

519519
it("should include jointEvaluationFile with explicit name when uploaded", async () => {
@@ -572,12 +572,12 @@ describe("GET /api/v1/export/declarations", () => {
572572
{ siren: "123456789", year: 2027 },
573573
]);
574574
const body = await response.json();
575-
expect(body.declarations[0].jointEvaluationFile).toEqual({
576-
id: "je-1",
577-
type: "joint_evaluation",
578-
fileName: "eval.pdf",
579-
uploadedAt: "2027-04-01T09:00:00.000Z",
580-
downloadUrl: "/api/v1/files/je-1",
575+
expect(body.Declarations[0].Fichier_evaluation_conjointe).toEqual({
576+
Id: "je-1",
577+
Type: "joint_evaluation",
578+
Nom_fichier: "eval.pdf",
579+
Date_upload: "2027-04-01T09:00:00.000Z",
580+
URL_telechargement: "/api/v1/files/je-1",
581581
});
582582
});
583583
});

0 commit comments

Comments
 (0)