Expense Calculation Service
Component Detail
Description
Maps each expense type to its reimbursement formula and computes the expected payout for a given selection. Handles per-km rate lookup for mileage, flat-amount logic for tolls and parking receipts, and zone-based public transit amounts. Produces a structured result for display and for downstream accounting export.
expense-calculation-service
Summaries
The Expense Calculation Service is the financial computation core of the reimbursement feature, translating an employee's expense selection into an accurate, policy-compliant payout figure before submission. By computing reimbursements in real time on the device, employees see exactly what they will receive before submitting, reducing disputes and resubmissions. Accurate pre-submission totals also streamline finance team approval workflows, as submissions arrive pre-validated with correct amounts. This directly lowers processing cost per claim and reduces time-to-reimbursement, improving employee satisfaction and retention — a measurable competitive advantage in expense management tooling.
Medium complexity component with a single dependency on expense-type-config, which must be delivered first. The primary scheduling risk is formula definition: per-km rates, transit zone amounts, and receipt thresholds must be confirmed with finance stakeholders before development begins — any late changes to rates require code or config updates. Plan a stakeholder sign-off milestone for formula parameters. Testing should cover all four expense types independently and in valid combined selections, including boundary values for km counts and zone thresholds.
The structured ExpenseCalculationResult output must be reviewed with the accounting export team early to prevent interface mismatches that could delay downstream integration.
This pure Dart service depends on expense-type-config for formula parameters and rate constants. The core interface, calculate(Set
Keep formula logic pure and side-effect-free to simplify testing. Rate parameters must be sourced exclusively from expense-type-config, never hardcoded inline.
Responsibilities
- Apply per-km rate formula for mileage expense type
- Apply flat receipt logic for toll and parking types
- Apply transit amount formula for public transit type
- Produce structured ExpenseCalculationResult with line items and total
Interfaces
calculate(Set<ExpenseType> selectedTypes, ExpenseInputParams params) → ExpenseCalculationResult
getFormulaDescription(ExpenseType type) → String
getRequiredInputs(ExpenseType type) → List<ExpenseInputField>
Relationships
Dependents (2)
Components that depend on this component
Related Data Entities (1)
Data entities managed by this component