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

Description

Data access layer for persisting and querying auto-approval rules and their version history. Provides queries needed for rule evaluation at claim-submission time and for the historical preview computation.

Feature: Auto-Approval Rules

auto-approval-rules-repository

Sources & reasoning

Line 70 states the exact auto-approval rule HLF needs: under 50 km / no additional expenses triggers automatic approval, otherwise manual. Line 113 repeats the requirement with the phrase "Automatisk godkjenning under terskel". Both are in Phase 2 context (line 342 maps to v1.0). This feature is the policy engine that drives the approval queue's routing logic.

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

Responsibilities

  • CRUD operations for auto-approval rule records scoped to an organisation
  • Store and retrieve immutable rule versions on every update
  • Query all active rules for a given organisation for claim evaluation
  • Count historical claims matching a draft rule's criteria for preview
  • Soft-delete rules while preserving version history for audit purposes

Interfaces

findActiveRules(orgId: string): AutoApprovalRule[]
findById(ruleId: string): AutoApprovalRule | null
insert(rule: NewRule): AutoApprovalRule
update(ruleId: string, changes: Partial<RuleFields>): AutoApprovalRule
softDelete(ruleId: string): void
countHistoricalMatches(orgId: string, criteria: RuleCriteria): number
listVersions(ruleId: string): RuleVersion[]