fix: bugs-04
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user