From fb102513cf9ec410a3eb0847a9d19b179ae8f565 Mon Sep 17 00:00:00 2001 From: Artur Rucinski <90777022+arturlg@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:16:43 +0100 Subject: [PATCH] fix: handle declarations with missing data or insufficient duration (#2165) --- .../src/api/core-domain/repo/impl/PostgresDeclarationRepo.ts | 4 +++- .../app/(default)/mon-espace/mes-declarations/IndexList.tsx | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/app/src/api/core-domain/repo/impl/PostgresDeclarationRepo.ts b/packages/app/src/api/core-domain/repo/impl/PostgresDeclarationRepo.ts index 2daca5cc8..c07d812e7 100644 --- a/packages/app/src/api/core-domain/repo/impl/PostgresDeclarationRepo.ts +++ b/packages/app/src/api/core-domain/repo/impl/PostgresDeclarationRepo.ts @@ -73,7 +73,9 @@ export class PostgresDeclarationRepo implements IDeclarationRepo { public async getAllBySiren(siren: Siren): Promise { try { - const raws = await this.sql`select * from ${this.table} where siren=${siren.getValue()} ${this.postgresLimit}`; + const raws = await this.sql`select * from ${this.table} where siren=${siren.getValue()} and data notnull ${ + this.postgresLimit + }`; return raws.map(declarationMap.toDomain); } catch (error: unknown) { diff --git a/packages/app/src/app/(default)/mon-espace/mes-declarations/IndexList.tsx b/packages/app/src/app/(default)/mon-espace/mes-declarations/IndexList.tsx index 9df04415c..e7e489978 100644 --- a/packages/app/src/app/(default)/mon-espace/mes-declarations/IndexList.tsx +++ b/packages/app/src/app/(default)/mon-espace/mes-declarations/IndexList.tsx @@ -32,6 +32,7 @@ enum declarationOpmcStatus { const getDeclarationOpmcStatus = (declaration?: DeclarationOpmcDTO) => { if (!declaration) return declarationOpmcStatus.NOT_APPLICABLE; + if (declaration?.["periode-reference"]?.périodeSuffisante === "non") return declarationOpmcStatus.NOT_APPLICABLE; const { after2021, index, initialValuesObjectifsMesures, objectifsMesuresSchema } = buildHelpersObjectifsMesures(declaration);