Service Layer high complexity mobile
1
Dependencies
1
Dependents
3
Entities
0
Integrations

Description

Client-side validation service that enforces business rules for expense submissions. Validates mutual exclusion constraints using the expense type catalogue's exclusive_groups field, enforces receipt attachment for claims above the configurable threshold, and validates distance and amount ranges.

Feature: Travel & Expense Registration

expense-validation-service

Summaries

The Expense Validation Service is a critical compliance enforcement layer that applies the organization's expense policy rules directly within the mobile app before any submission reaches back-end systems. By validating mutual exclusion constraints, receipt requirements above configurable thresholds, and distance limits entirely on the client side, it prevents non-compliant claims from entering the approval workflow at all. This reduces finance team review burden, minimizes erroneous or fraudulent submissions, and shortens reimbursement cycle times. Crucially, configurable thresholds allow policy rules to be adjusted without a new app release, giving the business meaningful agility in responding to policy changes without incurring engineering overhead.

The Expense Validation Service is a high-complexity, well-bounded service suitable for early parallel development, reducing critical path risk. Its single dependency — the expense type catalogue repository — must be available before mutual exclusion integration testing can begin. Configurable thresholds for receipt requirements and distance limits must be agreed with business stakeholders before validation logic can be fully implemented and signed off, making requirements alignment a prerequisite milestone. QA scope is substantial: exclusive group combination testing, boundary value analysis for amount and distance thresholds, and structured error message formatting must all be verified.

Stable validation outcomes are a hard prerequisite for Expense Form BLoC integration testing to proceed.

Implements client-side business rule validation for the expense submission flow on mobile, exposing five focused methods: validateExpenseTypes, validateReceiptRequirement, validateDistance, validateAll, and getExclusionConflicts. Mutual exclusion enforcement parses the expense-type-catalogue-repository's exclusive_groups field to identify conflicting type combinations across the active selection — requiring careful set-intersection logic and clear conflict reporting. Receipt threshold validation compares claim amount against a configurable scalar value and checks attachment state. All validators return structured error objects suitable for direct binding to form field error state within the Expense Form BLoC.

The validateAll aggregate method provides a single pre-submission entry point. A pure-function design with injected catalogue dependency is strongly recommended to maximize unit test coverage and isolate side effects.

Responsibilities

  • Validate mutual exclusion rules across selected expense types using exclusive_groups
  • Enforce receipt attachment requirement for amounts above configurable threshold
  • Validate kilometre distance against organisation-specific thresholds
  • Return structured validation errors for UI display

Interfaces

validateExpenseTypes(selectedTypes, catalogue)
validateReceiptRequirement(amount, threshold, hasReceipt)
validateDistance(kilometres)
validateAll(expenseFormData)
getExclusionConflicts(selectedTypes, exclusiveGroups)

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

API Contract

View full contract →
REST /api/v1/expense-validations 8 endpoints
GET /api/v1/expense-validations List recent validation results for an organization
GET /api/v1/expense-validations/:id Get a specific validation result
POST /api/v1/expense-validations Validate an expense form before submission
PUT /api/v1/expense-validations/:id Re-run validation after expense corrections
DELETE /api/v1/expense-validations/:id Clear validation result (on expense deletion)
POST /api/v1/expense-validations/check-expense-types Validate selected expense types against catalogue
+2 more