AutoApprovalRulesService
Component Detail
Service Layer
medium complexity
backend
0
Dependencies
0
Dependents
1
Entities
0
Integrations
Description
Business logic layer that evaluates submitted expense claims against all active auto-approval rules and executes instant approval when a match is found. Handles rule versioning, the preview computation against historical data, and routes non-matching claims to the manual approval queue.
auto-approval-rules-service
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.
-
docs/source/likeperson.md · line 70Automatisk godkjenning under 50 km / uten utlegg, manuell attestering ellers (HLF).
-
docs/source/likeperson.md · line 113Detaljert refusjonsstyring med faste valg som gjør feilkombinasjon teknisk umulig (f.eks. km + bussbillett kan ikke velges samtidig). Automatisk godkjenning under terskel.
Responsibilities
- Evaluate each submitted claim against active rules in priority order
- Instantly approve claims that match a rule and skip the manual queue
- Route non-matching claims to the expense approval queue
- Compute preview counts showing how many historical claims a draft rule would have matched
- Enforce rule versioning on every create or update operation
Interfaces
evaluateClaim(claim: ExpenseClaim): ApprovalDecision
getRules(orgId: string): AutoApprovalRule[]
createRule(orgId: string, draft: RuleDraft): AutoApprovalRule
updateRule(ruleId: string, draft: RuleDraft): AutoApprovalRule
previewRule(orgId: string, draft: RuleDraft): PreviewResult
setRuleActive(ruleId: string, active: boolean): AutoApprovalRule