feat: endpoint istruttore (queue + review + soccorso istruttorio)

- 4 nuove colonne su remission_practice: assigned_instructor_id, reviewed_at,
  reviewed_by, rejection_reason, approved_remission
- Nuova tabella remission_amendment_request con cascade delete, scope JSONB,
  stati AWAITING -> RESPONSE_RECEIVED -> CLOSED / EXPIRED / REJECTED
- Router instructor.py (287 righe) con 8 endpoint:
  /queue, /{id}, /{id}/claim, /{id}/approve, /{id}/reject,
  /{id}/amendment, /{id}/amendment/{aid}/close,
  /{id}/amendment/{aid}/respond-beneficiary
- GET /{id} (router practices) ora include amendments nel payload
- Manager manager_view flag per ROLE_INSTRUCTOR_MANAGER + SUPER_ADMIN
  (vede tutto il pool vs solo le proprie assegnazioni)
- Logica status transitions verificata:
  SUBMITTED -> UNDER_REVIEW (claim)
  UNDER_REVIEW <-> AWAITING_AMENDMENT (amendment open/close)
  UNDER_REVIEW | AWAITING_AMENDMENT -> APPROVED | REJECTED
- _compute_gate_check riusato anche dal router istruttore per calcolo
  remission_due in coda e nel dettaglio

Test end-to-end verde: ciclo completo benef -> istruttore -> soccorso ->
risposta -> chiusura -> approvazione funzionante su NAPOLI SAS.
This commit is contained in:
BFLOWS
2026-04-18 10:15:32 +02:00
parent e217f15e5a
commit 26fbc03871
5 changed files with 375 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ from sqlalchemy import text
from .config import get_settings
from .db import engine, Base
from .routers import health, schemas, practices, debug
from .routers import health, schemas, practices, debug, instructor
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
log = logging.getLogger("rendicontazione-api")
@@ -57,6 +57,7 @@ app.include_router(health.router, tags=["health"])
app.include_router(schemas.router)
app.include_router(practices.router)
app.include_router(debug.router)
app.include_router(instructor.router)
@app.get("/", tags=["root"])