Service Layer medium complexity mobilebackend
1
Dependencies
1
Dependents
3
Entities
0
Integrations

Description

Evaluates the JSON rules payload carried by each expense type record to determine mutual-exclusion constraints, receipt-required flags, and auto-approval eligibility. Provides both client-side rule resolution for immediate UI feedback and a server-side validation path that re-enforces all rules at submission time to reject any client-side bypass.

Feature: Expense Types & Requirements

expense-type-rule-service

Sources & reasoning

Rule evaluation for mutual exclusion, receipt thresholds, and auto-approval eligibility is non-trivial business logic that must run on both the client (for immediate UI feedback) and the backend (to reject bypasses). A dedicated service isolates this complexity and provides a single testable boundary for the organisation-configurable rule engine.

No source references — this artifact was included based on reasoning alone (see above).

Responsibilities

  • Load and cache the active expense type catalogue for the current organisation from Drift
  • Resolve mutual-exclusion sets from each type's JSON rules field
  • Determine receipt-required flag given type rules and submitted amount
  • Determine auto-approval eligibility given type rules and distance or amount
  • Re-validate the full type selection server-side before any expense record is persisted

Interfaces

getActiveTypes(String orgId) -> Future<List<ExpenseType>>
getMutualExclusions(String typeId) -> List<String>
isReceiptRequired(String typeId, double amount) -> bool
isAutoApprovalEligible(String typeId, double distanceKm) -> bool
validateSelection(List<String> selectedTypeIds) -> ValidationResult
POST /api/v1/expense-types/validate

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (3)

Data entities managed by this component