Data Layer medium complexity backend
0
Dependencies
0
Dependents
2
Entities
0
Integrations

Description

Data access layer for persisting and querying auto-approval rule records in the database. Handles CRUD operations for rules scoped to specific organizations and supports efficient lookup of active rules for claim evaluation. Manages rule status transitions and query filtering by criteria fields.

Feature: Auto-Approval Rules

auto-approval-rule-repository

Sources & reasoning

Line 70 gives a concrete HLF rule (under 50 km or no receipts = auto-approve). Line 113 confirms a threshold-based auto-approval pattern for HLF. Both refs point to Phase 2 (v1.0). The feature must live in the admin portal so org admins can configure per-org thresholds without code changes, matching the module-toggle and config-flag architecture described in the source doc.

  • docs/source/likeperson.md · line 70
    Automatisk godkjenning under 50 km / uten utlegg, manuell attestering ellers (HLF).
  • docs/source/likeperson.md · line 113
    Detaljert refusjonsstyring med faste valg som gjør feilkombinasjon teknisk umulig (f.eks. km + bussbillett kan ikke velges samtidig). Automatisk godkjenning under terskel.

Responsibilities

  • Persist new auto-approval rules with all criteria fields to the database
  • Retrieve all active rules for a given organization for evaluation and admin display
  • Update rule fields and status (active/inactive) by rule ID
  • Delete rules by ID with organization-scoped authorization checks
  • Query rules by specific criteria fields to support conflict detection lookups

Interfaces

findByOrganization(orgId: string): AutoApprovalRule[]
findActiveByOrganization(orgId: string): AutoApprovalRule[]
findById(ruleId: string): AutoApprovalRule | null
create(rule: AutoApprovalRuleRecord): AutoApprovalRule
update(ruleId: string, updates: Partial<AutoApprovalRuleRecord>): AutoApprovalRule
delete(ruleId: string): void

Related Data Entities (2)

Data entities managed by this component