Files

61 lines
1.5 KiB
Python
Raw Permalink Normal View History

from decimal import Decimal
from pydantic import BaseModel
class CountByName(BaseModel):
name: str
count: int
class CountByMonth(BaseModel):
month: str # YYYY-MM
count: int
class CostByMonth(BaseModel):
month: str
labor: Decimal
material: Decimal
service: Decimal
other: Decimal
total: Decimal
class AgingBucket(BaseModel):
bucket: str
count: int
class StageCycleTime(BaseModel):
stage: str
stage_label: str
avg_days: float
samples: int
class TopJob(BaseModel):
job_number: str
count: int
class ReportsSummaryOut(BaseModel):
total_ncrs: int
open_ncrs: int
closed_ncrs: int
total_cost: Decimal
# ── CAPA metrics (API Q1 §6.4.2) ─────────────────────────────────────────
root_cause_pct: float | None # % of NCRs with a completed root cause
effectiveness_verified_pct: float | None # % of CA-required NCRs verified effective
avg_capa_close_days: float | None # CA opened → verified effective
overdue_capa_count: int # CA required, past due, not yet verified effective
by_root_cause_category: list[CountByName]
by_department: list[CountByName]
by_category: list[CountByName]
by_month: list[CountByMonth]
cost_over_time: list[CostByMonth]
aging: list[AgingBucket]
cycle_times: list[StageCycleTime]
end_to_end_avg_days: float | None
top_jobs: list[TopJob]