configuration PK: id 10 required 1 unique

Description

Organization-level configuration rules that define conditions under which expense claims are automatically approved without manual coordinator review, based on thresholds such as distance, amount, or expense type.

16
Attributes
3
Indexes
5
Validation Rules
14
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
organization_id uuid Foreign key to the organization this rule belongs to
required
rule_name string Human-readable name for this rule, e.g. 'Under 50 km auto-approve'
required
expense_type_scope enum Which expense types this rule applies to. 'all' applies to every type; 'specific' restricts to listed types.
required
applicable_expense_type_ids json Array of expense_type IDs this rule applies to when expense_type_scope is 'specific'. Empty array when scope is 'all'.
-
condition_type enum The primary dimension the rule evaluates: kilometer distance, monetary amount, or absence of receipt.
required
max_km_threshold decimal Maximum kilometers below which auto-approval applies. NULL when condition_type is not km-based.
-
max_amount_threshold decimal Maximum monetary amount (NOK) below which auto-approval applies. NULL when condition_type is not amount-based.
-
requires_no_receipt boolean When true, rule only auto-approves expenses with no attached receipt (i.e. under the receipt-required threshold).
-
priority integer Evaluation order when multiple rules exist for the same organization. Lower number = higher priority.
required
is_active boolean Whether this rule is currently enforced. Inactive rules are retained for audit purposes.
required
description text Optional human-readable description of why this rule exists or what it covers.
-
created_by_user_id uuid User (Org Admin) who created this rule.
required
updated_by_user_id uuid User who last modified this rule.
-
created_at datetime Timestamp of rule creation.
required
updated_at datetime Timestamp of last modification.
required

Database Indexes

idx_expense_auto_approval_rules_org_id
btree

Columns: organization_id

idx_expense_auto_approval_rules_org_active
btree

Columns: organization_id, is_active

idx_expense_auto_approval_rules_org_priority
btree

Columns: organization_id, priority

Validation Rules

threshold_required_for_condition error

Validation failed

applicable_types_populated_when_specific error

Validation failed

rule_name_not_blank error

Validation failed

priority_positive_integer error

Validation failed

expense_type_ids_exist error

Validation failed

Business Rules

org_scoped_rules
always

Rules are strictly scoped to a single organization. An org admin may only create, read, update, or delete rules for their own organization.

auto_approve_on_submission
on_create

When an expense is submitted, the service evaluates active rules for the submitting user's organization in priority order. The first matching rule triggers automatic approval, bypassing the manual approval queue.

km_without_receipt_auto_approve
on_create

Expenses of type kilometer allowance below the configured max_km_threshold with no attached receipt are automatically approved. This matches HLF's stated rule: under 50 km / no receipt → auto-approve.

amount_threshold_auto_approve
on_create

Expenses with a total amount below max_amount_threshold are automatically approved when the matching rule is active.

priority_ordering
always

When multiple active rules match a single expense submission, the rule with the lowest priority integer wins. Rules are evaluated in ascending priority order; evaluation stops at the first match.

audit_on_rule_change
on_create

Any create, update, or delete of an auto-approval rule must produce an audit log entry including the acting user, org, and the before/after state.

no_delete_if_in_use
on_delete

A rule may be soft-deleted (is_active = false) rather than hard-deleted if it was used to auto-approve any expenses. Hard delete is only allowed when the rule has never been applied.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage