Service Layer high complexity backend
0
Dependencies
0
Dependents
6
Entities
0
Integrations

Description

Supabase Edge Function triggered on insert to travel_expense_reports that evaluates configurable organisation thresholds and automatically approves low-risk submissions. Writes the initial approval record with status auto_approved when total mileage is below the configured threshold and no additional expense items are attached; otherwise sets status to pending_attestation.

Feature: Reimbursement Approval Workflow

auto-approval-service

Responsibilities

  • Evaluate configured mileage and expense thresholds per organisation
  • Write initial reimbursement_approvals record with correct status
  • Trigger push notification on auto-approval status transition
  • Read threshold configuration from integration_configs table

Interfaces

evaluateAutoApproval(reportId: String, orgId: String): ApprovalDecision
loadThresholdConfig(orgId: String): ApprovalThreshold
createApprovalRecord(reportId: String, status: ApprovalStatus): ReimbursementApproval
dispatchStatusNotification(userId: String, status: ApprovalStatus)
calculateTotalMileage(items: List<ExpenseItem>): double
hasAdditionalExpenses(items: List<ExpenseItem>): bool