1.4 KiB
1.4 KiB
ADR 0017: CRM Report Foundation
Status
Accepted
Context
CRM now has stable foundations for:
- access control and scope resolution
- customer ownership and contact sharing
- lead and enquiry lifecycle
- won/lost governance
- revenue attribution
- dashboard KPI
Future report modules need one shared architecture so they do not re-implement:
- report discovery
- filter contracts
- export helpers
- access resolution
- audit logging
Decision
We introduce a dedicated report foundation under src/features/crm/reports/.
The foundation includes:
crm_report_definitionsas the report registrycrm_report_categorymaster options for grouping and future permissions- shared filter metadata endpoint
ResolvedReportContextfor organization, scope, and permission resolutionresolveCrmAccess()as the common context adapter for reports- dataset and builder layers for report queries
- shared CSV/XLS export helpers
crm_reportaudit entries forview,export_csv, andexport_excel
Reports must not query the database directly from UI routes. Route handlers call the report server layer instead.
Consequences
- K.2-K.7 can add business reports without redefining report plumbing
- scope and permission enforcement stays aligned with CRM authorization work from Task L
- export behavior becomes reusable instead of dashboard-specific
- report navigation can be driven from the seeded registry and category metadata