derived PK: id 11 required 1 unique

Description

Records of accounting data export jobs triggered by organization administrators, tracking export status, format, date range, and the generated file reference for download and audit purposes.

18
Attributes
4
Indexes
6
Validation Rules
8
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
organization_id uuid Organization that triggered the export
required
triggered_by_user_id uuid Admin user who initiated the export
required
status enum Current state of the export job
required
export_format enum File format of the export (e.g. CSV, XLSX, or accounting-system-specific format)
required
period_from datetime Start of the date range covered by this export
required
period_to datetime End of the date range covered by this export
required
record_count integer Number of expense/reimbursement records included in the export
-
file_path string Storage path or URL of the generated export file
-
file_size_bytes integer Size of the generated export file in bytes
-
error_message text Error details if the export job failed
-
accounting_system enum Target accounting system for the export (Xledger for Blindeforbundet, Dynamics for HLF)
-
includes_expenses boolean Whether this export includes expense/reimbursement data
required
includes_activities boolean Whether this export includes activity data relevant to accounting
required
download_count integer Number of times the export file has been downloaded
required
expires_at datetime Timestamp after which the export file is no longer available for download
-
created_at datetime Timestamp when the export job was created
required
completed_at datetime Timestamp when the export job finished (success or failure)
-

Database Indexes

idx_accounting_exports_organization_id
btree

Columns: organization_id

idx_accounting_exports_status
btree

Columns: status

idx_accounting_exports_created_at
btree

Columns: created_at

idx_accounting_exports_org_period
btree

Columns: organization_id, period_from, period_to

Validation Rules

period_from_required error

Validation failed

period_to_required error

Validation failed

export_format_valid error

Validation failed

status_transition_valid error

Validation failed

file_path_on_completion error

Validation failed

error_message_on_failure warning

Validation failed

Business Rules

org_scoped_export
on_create

An export can only include data belonging to the triggering organization. Cross-organization data access is strictly prohibited.

org_admin_only
always

Only Organization Admins or Global Admins with explicit support access may trigger or download accounting exports.

period_range_valid
on_create

period_from must be earlier than period_to. Exports cannot span more than 366 days.

no_duplicate_pending
on_create

An organization cannot have two pending or processing exports for the same period range and accounting system simultaneously.

file_expiry
always

Export files expire after 7 days and are deleted from storage. The export record is retained for audit purposes.

audit_on_download
on_update

Every file download is recorded in the audit log with the user, timestamp, and export ID.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
by_date
Retention
archive_after_1year