Service Layer medium complexity backend
0
Dependencies
0
Dependents
4
Entities
0
Integrations

Description

Business logic layer responsible for evaluating submitted expense claims against active auto-approval rules and determining whether automatic approval applies. Manages rule lifecycle including creation, validation, conflict detection, and deactivation. Triggers approval actions and submitter notifications when a claim matches a qualifying rule.

Feature: Auto-Approval Rules

auto-approval-rule-service

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

  • Evaluate expense claims against all active rules for the submitting organization
  • Detect conflicting or overlapping rules and surface them for admin review
  • Apply automatic approval and bypass the manual queue when a rule is matched
  • Validate rule configurations before persisting to ensure criteria are complete and non-contradictory
  • Emit approval events and trigger notifications to submitters upon auto-approval

Interfaces

evaluateClaim(claimId: string, orgId: string): AutoApprovalResult
createRule(orgId: string, ruleData: RuleInput): AutoApprovalRule
updateRule(ruleId: string, ruleData: RuleInput): AutoApprovalRule
deleteRule(ruleId: string): void
detectConflicts(orgId: string): RuleConflict[]
getRulesForOrganization(orgId: string): AutoApprovalRule[]