Summary
Add a non-blocking vendor credit alert workflow for invoice create and approve actions.
Scope
- Pre-create a
CreditCheckRecord with a deterministic credit_check_id
- Run the credit evaluation after the response using FastAPI
BackgroundTasks
- Compute outstanding AP from invoices in
PENDING, MATCHED, and APPROVED
- Persist a single active vendor-level
CreditAlert when the credit limit is exceeded
- Expose
GET /credit-checks/{id} from the invoices routing surface
- Extend
GET /vendors/{id}/exposure to include the active alert when present
- Preserve idempotent replay so the same logical request returns the same
credit_check_id without duplicate background work
Constraints
- The triggering create and approve responses remain otherwise unchanged except for top-level
credit_check_id
- Credit-risk signaling is advisory only and must never block the triggering action
- Background task exceptions are caught and logged silently
References
- specs/018-vendor-credit-alert/spec.md
- specs/018-vendor-credit-alert/plan.md
- specs/018-vendor-credit-alert/tasks.md
Summary
Add a non-blocking vendor credit alert workflow for invoice create and approve actions.
Scope
CreditCheckRecordwith a deterministiccredit_check_idBackgroundTasksPENDING,MATCHED, andAPPROVEDCreditAlertwhen the credit limit is exceededGET /credit-checks/{id}from the invoices routing surfaceGET /vendors/{id}/exposureto include the active alert when presentcredit_check_idwithout duplicate background workConstraints
credit_check_idReferences