fix: 0% completeness bug — SCORE finding was not generated at 100%
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user