Service Layer medium complexity backend
5
Dependencies
3
Dependents
5
Entities
0
Integrations

Description

Backend service handling all approval and rejection mutations for expense claims. Wraps each decision in a database transaction that atomically updates the expense_claims row (status, approved_by, approved_at, rejection_reason) and inserts an audit log entry, then enqueues a notification event to the claimant. Enforces role authorization (Coordinator and Org Admin only) and processes bulk-approve batches as a single transaction to avoid N+1 API calls.

Feature: Expense Approval Queue

expense-approval-service

Responsibilities

  • Validate that the authenticated approver has Coordinator or Org Admin role for the claim's organization
  • Atomically update claim status and record approver identity, timestamp, and optional rejection comment
  • Write audit log entry for every approval or rejection decision
  • Enqueue push and email/SMS notification event to the claimant upon decision
  • Process bulk-approve batch in a single database transaction with per-item validation

Interfaces

approveClaim(claimId, approverId)
rejectClaim(claimId, approverId, rejectionComment)
bulkApproveClaims(claimIds, approverId)
validateApproverRole(approverId, organizationId)
enqueueClaimDecisionNotification(claimId, decision, claimantId)