From e3ae35891fb7633a444b2246af11a7e6a44dba48 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 5 May 2026 15:34:04 +0200 Subject: [PATCH] =?UTF-8?q?fix:=200%=20completeness=20bug=20=E2=80=94=20SC?= =?UTF-8?q?ORE=20finding=20was=20not=20generated=20at=20100%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: When all 9 Art. 13 checks passed (100%), no SCORE finding was created (line: 'if pct < 100'). The backend then defaulted to completeness=0 because it looked for the SCORE finding to extract the %. Fix: Always generate SCORE finding, even at 100%. Added 'OK' severity for fully compliant documents. This was the cause of 8 documents showing '0% MANGELHAFT' despite containing all required information. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../services/dsi_document_checker.py | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/backend-compliance/compliance/services/dsi_document_checker.py b/backend-compliance/compliance/services/dsi_document_checker.py index fc792b8..4a90806 100644 --- a/backend-compliance/compliance/services/dsi_document_checker.py +++ b/backend-compliance/compliance/services/dsi_document_checker.py @@ -208,21 +208,20 @@ def check_document_completeness( else: present += 1 - # Add summary finding + # Always add summary finding (even at 100% — needed for completeness tracking) if total > 0: pct = round(present / total * 100) - if pct < 100: - findings.insert(0, { - "code": f"DSI-SCORE-{doc_type.upper()}", - "severity": "LOW" if pct >= 80 else "MEDIUM" if pct >= 50 else "HIGH", - "text": ( - f"'{doc_title}': {present}/{total} Pflichtangaben vorhanden ({pct}%). " - f"Fehlend: {total - present} Angaben nach {label}." - ), - "doc_title": doc_title, - "doc_url": doc_url, - "doc_type": doc_type, - }) + findings.insert(0, { + "code": f"DSI-SCORE-{doc_type.upper()}", + "severity": "OK" if pct == 100 else "LOW" if pct >= 80 else "MEDIUM" if pct >= 50 else "HIGH", + "text": ( + f"'{doc_title}': {present}/{total} Pflichtangaben vorhanden ({pct}%)." + + (f" Fehlend: {total - present} Angaben nach {label}." if pct < 100 else "") + ), + "doc_title": doc_title, + "doc_url": doc_url, + "doc_type": doc_type, + }) return findings