fix: synchronize document links with reconciliation items
This commit is contained in:
@@ -575,6 +575,9 @@ def list_reconciliation_items(*, status: str = "open", external_type: Optional[s
|
||||
if status != "all":
|
||||
where.append("ri.status = :status")
|
||||
params["status"] = status
|
||||
from app.document_reconciliation_service import active_document_link_exclusion_sql
|
||||
where.append("(ri.status NOT IN ('open','needs_review','conflict') OR "
|
||||
+ active_document_link_exclusion_sql("ri") + ")")
|
||||
if external_type:
|
||||
where.append("ri.external_type = :external_type")
|
||||
params["external_type"] = external_type
|
||||
@@ -2718,6 +2721,7 @@ def _get_reconciliation_items_by_ids(item_ids: List[str]) -> List[Dict[str, Any]
|
||||
cleaned = [str(x).strip() for x in item_ids if str(x).strip()]
|
||||
if not cleaned:
|
||||
return []
|
||||
from app.document_reconciliation_service import active_document_link_exclusion_sql
|
||||
with engine.begin() as conn:
|
||||
rows = conn.execute(text("""
|
||||
SELECT id::text, source_system, external_type, external_id, title, description,
|
||||
@@ -2728,6 +2732,7 @@ def _get_reconciliation_items_by_ids(item_ids: List[str]) -> List[Dict[str, Any]
|
||||
FROM reconciliation_items
|
||||
WHERE id = ANY(CAST(:ids AS UUID[]))
|
||||
AND status IN ('open','needs_review','conflict')
|
||||
AND """ + active_document_link_exclusion_sql("reconciliation_items") + """
|
||||
ORDER BY document_date NULLS FIRST, created_at
|
||||
"""), {"ids": cleaned}).mappings().all()
|
||||
return [dict(row) for row in rows]
|
||||
|
||||
Reference in New Issue
Block a user