Driver Assignment
Data Entity
Description
Records a Blindeforbundet-specific arrangement where a peer mentor provides transportation to a service recipient. Captures the transported contact, the agreed driver fee, and the activity date. A driver assignment is active only after the associated confidentiality declaration has been electronically signed and acknowledged.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Globally unique identifier for the driver assignment record, generated server-side on creation. | PKrequiredunique |
peer_mentor_id |
uuid |
Foreign key referencing the peer mentor who provides transportation. Must be an active, non-paused peer mentor within the same organization. | required |
contact_id |
uuid |
Foreign key referencing the service recipient being transported. Must be a valid contact record belonging to the same organization. | required |
activity_id |
uuid |
Foreign key referencing the parent activity event this driver assignment is linked to. An activity may have one or more driver assignments. | required |
organization_id |
uuid |
Foreign key referencing the organization (must be Blindeforbundet or another org with the driver feature flag enabled). Used for RLS scoping of all queries. | required |
fee_amount |
decimal |
The agreed honorarium amount in Norwegian kroner (NOK) for the transportation service. Must be explicitly confirmed by the driver. Precision: 10 digits, 2 decimal places. Links to organization-specific rate guidance. | required |
date |
datetime |
The date on which the transportation took place. Stored as UTC timestamp; rendered in the user's local timezone. Must not be more than 365 days in the past or any time in the future. | required |
status |
enum |
Lifecycle state of the driver assignment. Controls whether the assignment is active and whether the fee can flow into the accounting export pipeline. | required |
confidentiality_declaration_id |
uuid |
Foreign key referencing the associated ConfidentialityDeclaration that must be acknowledged before the assignment becomes active. Nullable until the declaration is generated. | unique |
fee_confirmed_by_driver |
boolean |
Indicates whether the peer mentor driver has explicitly confirmed the agreed fee amount. Fee export to Xledger is blocked until this is true. | required |
fee_confirmed_at |
datetime |
UTC timestamp of when the peer mentor driver confirmed the fee amount. Null until confirmation. | - |
created_by_user_id |
uuid |
Foreign key referencing the coordinator user who created this driver assignment record. Required for audit trail. | required |
notes |
text |
Optional free-text notes added by the coordinator about the transportation arrangement. Maximum 1000 characters. Not included in Xledger export. | - |
assignment_sequence_number |
integer |
Sequential count of driver assignments for this peer mentor within the organization, used to determine honorarium rate tiers (office honorarium triggers at 3rd assignment, higher rate at 15th). Computed and stored on creation to avoid expensive COUNT queries at export time. | required |
exported_to_accounting |
boolean |
Indicates whether this assignment's fee has been included in an accounting system export run (Xledger). Prevents double-export. | required |
exported_at |
datetime |
UTC timestamp of when the fee was exported to the accounting system. Null until export. | - |
export_run_id |
uuid |
Foreign key referencing the export run that included this assignment. Used for audit and re-download purposes. | - |
created_at |
datetime |
UTC timestamp set automatically when the record is first inserted. | required |
updated_at |
datetime |
UTC timestamp updated automatically on every row modification. | required |
Database Indexes
idx_driver_assignment_peer_mentor
Columns: peer_mentor_id
idx_driver_assignment_contact
Columns: contact_id
idx_driver_assignment_activity
Columns: activity_id
idx_driver_assignment_org
Columns: organization_id
idx_driver_assignment_declaration
Columns: confidentiality_declaration_id
idx_driver_assignment_status
Columns: organization_id, status
idx_driver_assignment_date
Columns: organization_id, date
idx_driver_assignment_mentor_org_seq
Columns: peer_mentor_id, organization_id, assignment_sequence_number
idx_driver_assignment_export
Columns: organization_id, exported_to_accounting, status
Validation Rules
fee_amount_positive
error
Validation failed
date_not_future
error
Validation failed
date_not_too_old
error
Validation failed
peer_mentor_active
error
Validation failed
contact_belongs_to_org
error
Validation failed
activity_belongs_to_org
error
Validation failed
status_transition_valid
error
Validation failed
declaration_id_unique
error
Validation failed
fee_confirmation_timestamp_required
error
Validation failed
notes_max_length
error
Validation failed
Business Rules
assignment_requires_active_declaration
A driver assignment may only transition to 'active' status after its linked ConfidentialityDeclaration reaches 'acknowledged' status. Status transitions from 'pending_declaration' to 'active' are gated by the declaration acknowledgement event.
driver_feature_flag_required
Driver assignments may only be created for organizations that have the driver feature flag enabled in their organization configuration. Attempts to create a driver assignment for an org without the flag must be rejected.
fee_must_be_confirmed_before_export
The driver assignment's fee may not be included in an Xledger accounting export unless fee_confirmed_by_driver is true. The double-export guard also enforces exported_to_accounting = false before including a record.
honorarium_rate_tier_tracking
The assignment_sequence_number is computed as the total count of non-cancelled driver assignments for the peer mentor in the organization at the time of creation. Coordinators must be informed when the 3rd assignment (office honorarium trigger) and 15th assignment (higher rate trigger) thresholds are crossed.
declaration_must_be_linked_on_activation
A driver assignment may not remain in 'draft' status indefinitely. When the status transitions to 'pending_declaration', a confidentiality_declaration_id must be present. Attempting to activate without a linked declaration is rejected.
soft_delete_only
Driver assignments are never hard-deleted. Cancellation sets status = 'cancelled' and records updated_at. This preserves the audit trail for Bufdir reporting and accounting reconciliation.
org_scoped_access_via_rls
All database queries against the driver_assignments table are scoped by organization_id through Supabase Row Level Security policies. Users may only read and write assignments belonging to their own organization.
completed_assignments_immutable
Once a driver assignment reaches 'completed' status, all fields except exported_to_accounting, exported_at, and export_run_id become immutable. Update attempts to other fields must be rejected.
CRUD Operations
Storage Configuration
Entity Relationships
A Blindeforbundet activity involving transportation may have one or more driver assignments linked to it
Each Blindeforbundet driver assignment requires exactly one confidentiality declaration to be sent and acknowledged before the assignment becomes active
Each driver assignment has exactly one fee record storing the agreed honorarium amount and acknowledgement status