derived PK: id 14 required 1 unique

Description

A derived compliance report aggregating activity data from an organization for submission to Bufdir (Norwegian government agency). Generated by admins in the Admin Web Portal from activity registration data collected via the mobile app.

18
Attributes
4
Indexes
5
Validation Rules
7
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
organization_id uuid Foreign key to organizations table
required
reporting_period_start datetime Start of the reporting period covered by this report
required
reporting_period_end datetime End of the reporting period covered by this report
required
generated_by_user_id uuid User (Org Admin or Global Admin) who triggered report generation
required
generated_at datetime Timestamp when the report was generated
required
status enum Current status of the report
required
report_data json Aggregated Bufdir-structured report payload: activity counts, peer mentor counts, contact counts, activity types, hours, geographic breakdown, etc.
required
activity_count integer Total number of activities included in this report
required
peer_mentor_count integer Number of active peer mentors in the reporting period
required
contact_count integer Number of unique contacts reached in the reporting period
required
total_hours decimal Total hours of peer mentor activity in the reporting period
required
export_file_url string URL to the exported file (CSV/Excel) stored in cloud storage, set after export
-
exported_at datetime Timestamp when the report was exported to file
-
exported_by_user_id uuid User who triggered the file export
-
notes text Optional admin notes about this report (e.g. manual corrections, context)
-
created_at datetime Row creation timestamp
required
updated_at datetime Row last-updated timestamp
required

Database Indexes

idx_bufdir_reports_organization_id
btree

Columns: organization_id

idx_bufdir_reports_org_period
btree

Columns: organization_id, reporting_period_start, reporting_period_end

idx_bufdir_reports_status
btree

Columns: status

idx_bufdir_reports_generated_at
btree

Columns: generated_at

Validation Rules

period_end_after_start error

Validation failed

period_not_future error

Validation failed

valid_organization error

Validation failed

report_data_not_empty error

Validation failed

export_url_format error

Validation failed

Business Rules

no_test_org_data
on_create

Bufdir reports must never include data from Norse Test Organization — test data is excluded from all external reporting

admin_only_generation
on_create

Only Org Admins and Global Admins may generate Bufdir reports. Coordinators and Peer Mentors have no access to this feature; it is exclusively an Admin Web Portal function.

org_scoped_data
on_create

Report data must only include activities, peer mentors, and contacts belonging to the requesting organization — strict tenant isolation

export_requires_generated_status
on_update

A report can only be exported once it has status 'generated'. Draft reports cannot be exported.

Enforced by: BufdirExportService
immutable_after_export
on_update

Once a report has been exported (status 'exported' or 'submitted'), its report_data must not be modified to preserve audit integrity

period_overlap_warning
on_create

Warn if a new report's period overlaps with an existing generated report for the same organization, to prevent duplicate Bufdir submissions

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
by_date
Retention
Permanent Storage