Service Layer medium complexity backend
1
Dependencies
1
Dependents
12
Entities
0
Integrations

Description

Backend service that manages auto-approval rule CRUD operations and evaluates submitted expenses against configured rules. When an expense is submitted, the engine queries all enabled rules for the organization, checks whether the claim falls within every configured threshold (amount, distance, receipt presence, expense type), and sets the approval status to 'approved' or 'pending' accordingly. All decisions are logged to audit_logs with source 'auto'.

Feature: Auto-Approval Rules

auto-approval-rule-engine

Responsibilities

  • CRUD operations for auto-approval rules scoped to organization
  • Evaluate expense claims against applicable rules synchronously at submission time
  • Determine approval status based on threshold matching (amount, distance, receipt, expense type)
  • Write auto-approval decisions to audit_logs with source: 'auto' for compliance
  • Respect feature flag 'auto_approval_rules' gating per organization

Interfaces

createRule(orgId: string, ruleData: CreateRuleDTO): AutoApprovalRule
updateRule(ruleId: string, ruleData: UpdateRuleDTO): AutoApprovalRule
deleteRule(ruleId: string): void
toggleRule(ruleId: string, enabled: boolean): AutoApprovalRule
getRulesForOrganization(orgId: string): AutoApprovalRule[]
evaluateExpense(expense: Expense, orgId: string): ApprovalDecision
isAutoApprovalEnabled(orgId: string): boolean
getApplicableRules(orgId: string, expenseTypeId?: string): AutoApprovalRule[]
logApprovalDecision(expenseId: string, decision: ApprovalDecision): void

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component