Auto-Approval Threshold Evaluator
Component Detail
Description
A pure service that applies the organisation-level threshold rule to a pending mileage claim. If the claimed distance is below the configurable threshold (default 50 km) and no additional expenses are attached, it returns 'approved'; otherwise it returns 'pending_review' for coordinator attestation. The evaluator is stateless and fully unit-testable.
auto-approval-evaluator
Summaries
The Auto-Approval Threshold Evaluator embodies the organisation's policy for low-value mileage claims, translating a business rule — claims under 50 km with no extras are trusted and approved immediately — into consistent, bias-free automated decisions. By removing the coordinator from routine approvals, the organisation dramatically reduces the time employees wait for reimbursement while freeing coordinators to focus on higher-value oversight tasks. The configurable threshold means the policy can be tuned to match changing compliance requirements or budget controls without any code changes, giving finance and operations leadership direct control over approval sensitivity.
This is one of the lower-risk deliverables in the mileage feature: it has zero external dependencies, is fully stateless, and its logic is entirely expressible in unit tests. Development effort is low. The primary planning concern is ensuring the threshold value is surfaced correctly through OrgRateConfig so that the evaluator always reads the live org-configured value rather than a hardcoded default. QA should include boundary tests at exactly 50 km, at 50 km + 1 m, and with/without expense line attachments.
Because this component is pure logic with no I/O, it can be developed and tested in complete isolation from the rest of the feature, making it a safe early deliverable.
AutoApprovalEvaluator is a stateless pure-function service with no constructor dependencies, making it trivially injectable and unit-testable. The primary interface evaluate(MileageClaim, OrgRateConfig) → ClaimStatus composes two private predicates: isBelowThreshold(distanceKm, thresholdKm) and hasAdditionalExpenses(claim). Both are exposed as named methods to allow isolated unit assertions. The evaluator returns the ClaimStatus enum directly — callers must not re-implement the threshold logic.
The audit log call inside evaluate() should write to a structured logger (not print) so that log aggregation pipelines can filter evaluation decisions by claim ID and outcome. Extend by adding new predicate methods and composing them in evaluate() without modifying existing predicates.
Responsibilities
- Compare claim distance against the org-configured threshold
- Check whether any additional expense lines are attached to the claim
- Return the correct ClaimStatus enum value ('approved' or 'pending_review')
- Log the evaluation decision for audit purposes
Interfaces
evaluate(MileageClaim claim, OrgRateConfig config) → ClaimStatus
isBelow Threshold(double distanceKm, double thresholdKm) → bool
hasAdditionalExpenses(MileageClaim claim) → bool
Relationships
Related Data Entities (2)
Data entities managed by this component