fix: bugs-04

This commit is contained in:
2026-03-17 22:39:05 +08:00
parent 143a1b4507
commit cdc2c4ead6
50 changed files with 1694 additions and 1916 deletions

View File

@@ -9,11 +9,17 @@ from app.models.assessment import FraudAssessment, ReviewStatus
async def recalculate_case_total(case_id: UUID, db: AsyncSession) -> float:
"""Recalculate and persist the total confirmed fraud amount for a case."""
"""Recalculate and persist the recognized fraud amount for a case.
The case-level amount shown in case list/workspace represents the current
recognized amount after analysis, so it should include pending/confirmed/
needs_info items and only exclude explicitly rejected records.
"""
result = await db.execute(
select(func.coalesce(func.sum(FraudAssessment.assessed_amount), 0))
.where(FraudAssessment.case_id == case_id)
.where(FraudAssessment.review_status == ReviewStatus.confirmed)
.where(FraudAssessment.assessed_amount > 0)
.where(FraudAssessment.review_status != ReviewStatus.rejected)
)
total = float(result.scalar() or 0)
case = await db.get(Case, case_id)