Skip to content

Commit fb10251

Browse files
authored
fix: handle declarations with missing data or insufficient duration (#2165)
1 parent 813f9f8 commit fb10251

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/app/src/api/core-domain/repo/impl/PostgresDeclarationRepo.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export class PostgresDeclarationRepo implements IDeclarationRepo {
7373

7474
public async getAllBySiren(siren: Siren): Promise<Declaration[]> {
7575
try {
76-
const raws = await this.sql`select * from ${this.table} where siren=${siren.getValue()} ${this.postgresLimit}`;
76+
const raws = await this.sql`select * from ${this.table} where siren=${siren.getValue()} and data notnull ${
77+
this.postgresLimit
78+
}`;
7779

7880
return raws.map(declarationMap.toDomain);
7981
} catch (error: unknown) {

packages/app/src/app/(default)/mon-espace/mes-declarations/IndexList.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ enum declarationOpmcStatus {
3232

3333
const getDeclarationOpmcStatus = (declaration?: DeclarationOpmcDTO) => {
3434
if (!declaration) return declarationOpmcStatus.NOT_APPLICABLE;
35+
if (declaration?.["periode-reference"]?.périodeSuffisante === "non") return declarationOpmcStatus.NOT_APPLICABLE;
3536
const { after2021, index, initialValuesObjectifsMesures, objectifsMesuresSchema } =
3637
buildHelpersObjectifsMesures(declaration);
3738

0 commit comments

Comments
 (0)