core PK: id 9 required 1 unique

Description

Stores structured compliance reports generated for Bufdir (Norwegian Directorate for Children, Youth and Family Affairs). Each record represents a single reporting submission covering a specific period for an organization, aggregating activity data into the format required for government grant compliance.

25
Attributes
5
Indexes
8
Validation Rules
18
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Unique identifier for the report
PKrequiredunique
organization_id uuid Foreign key to the organization submitting the report
required
title string Human-readable report title, e.g. 'Bufdir Report Q1 2026 - NHF'
required
reporting_period_start datetime Start date of the reporting period covered by this report
required
reporting_period_end datetime End date of the reporting period covered by this report
required
status enum Current lifecycle status of the report
required
report_data json Full structured report payload mapped to Bufdir-required fields, including activity counts by type, peer mentor counts, contact counts, hours logged, and expense summaries
-
total_activities integer Total number of approved activities included in this report period
-
total_peer_mentors integer Count of active peer mentors during the reporting period
-
total_contacts integer Count of unique contacts served during the reporting period
-
total_hours decimal Sum of activity hours across all included activities
-
total_expenses decimal Sum of approved reimbursements included in this report
-
completeness_score decimal Percentage (0-100) indicating how complete the report data is against required Bufdir fields
-
validation_warnings json Array of data quality warnings detected during report generation (missing fields, inconsistencies)
-
generated_by uuid User ID of the admin or coordinator who triggered report generation
required
approved_by uuid User ID of the admin who approved the report for export
-
approved_at datetime Timestamp when the report was approved
-
export_format enum Format used for the most recent export of this report
-
export_file_url string Signed URL or file path referencing the exported report file
-
exported_at datetime Timestamp of the most recent export
-
submitted_at datetime Timestamp when the report was officially submitted to Bufdir
-
notes text Internal notes or comments about the report from the generating admin
-
field_mapping_version string Version identifier of the Bufdir field mapping configuration used to generate this report
-
created_at datetime Timestamp when the report record was created
required
updated_at datetime Timestamp of the last modification to the report record
required

Database Indexes

idx_bufdir_reports_organization_id
btree

Columns: organization_id

idx_bufdir_reports_org_period
btree unique

Columns: organization_id, reporting_period_start, reporting_period_end

idx_bufdir_reports_status
btree

Columns: status

idx_bufdir_reports_generated_by
btree

Columns: generated_by

idx_bufdir_reports_created_at
btree

Columns: created_at

Validation Rules

valid_organization_reference error

Validation failed

valid_user_references error

Validation failed

report_data_schema_validation error

Validation failed

non_negative_totals error

Validation failed

completeness_score_range error

Validation failed

export_format_required_for_export error

Validation failed

approved_fields_required error

Validation failed

reporting_period_reasonable_range warning

Validation failed

Business Rules

unique_period_per_organization
on_create

Each organization can have only one report per reporting period (start + end date combination). Prevents duplicate submissions for the same timeframe.

period_end_after_start
on_create

The reporting_period_end must be strictly after reporting_period_start. Zero-length or negative periods are not allowed.

Enforced by: Bufdir Report Service
status_transition_enforcement
on_update

Reports follow a strict lifecycle: draft → generating → ready_for_review → approved → exported → submitted → archived. Backward transitions are only allowed from ready_for_review back to draft (for corrections).

approval_required_before_export
on_update

A report must be in 'approved' status before it can be exported. Export without approval is blocked to ensure data quality review.

only_approved_activities_included
on_create

Report generation must only aggregate activities with 'approved' status. Pending, rejected, or flagged activities are excluded from Bufdir totals.

Enforced by: Bufdir Report Service
organization_scope_isolation
always

Reports are strictly scoped to a single organization. Cross-organization data must never leak into a report. Multi-tenant isolation enforced at query level.

completeness_warning_threshold
on_update

If completeness_score is below 80%, the report cannot be moved to 'approved' status. Admins must resolve data gaps first.

approved_by_requires_org_admin_role
on_update

Only users with Organization Administrator or Global Administrator role can approve reports. Coordinators can generate but not approve.

audit_trail_on_status_change
on_update

Every status transition must be logged in the audit_logs table with the acting user, timestamp, and previous/new status.

immutable_after_submission
on_update

Once a report reaches 'submitted' status, its report_data, totals, and period fields become immutable. Only status can change (to 'archived').

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage