Service Layer low complexity mobile
0
Dependencies
0
Dependents
1
Entities
0
Integrations

Description

Provides reimbursement amount computation logic used both by the real-time widget and the claim submission path. Multiplies the provided distance by the current national per-km rate loaded from org configuration, ensuring a single authoritative calculation source across the feature.

Feature: Mileage Reimbursement Entry

mileage-calculation-service

Summaries

The Mileage Reimbursement Calculation Service guarantees that every employee and every coordinator sees exactly the same reimbursement figure — whether previewing in the form widget or reviewing a submitted claim. Eliminating calculation discrepancies prevents disputes, reduces support queries, and builds trust in the expense platform. By encoding Norwegian reimbursement rounding standards directly into the service, the organisation ensures ongoing compliance with national rate conventions without relying on individual employees or coordinators to apply rules correctly. This consistency also simplifies future audits, as all amounts are traceable to a single authoritative calculation path.

Low complexity and zero external dependencies make this one of the first components that can be delivered and locked down. Development involves implementing the multiplication formula, the Norwegian-standard rounding rules, and the locale-aware formatAmount formatter. The main scheduling risk is ensuring the rounding specification is signed off by finance or compliance stakeholders before implementation begins — rounding direction (half-up vs. bankers' rounding) affects payroll accuracy and must match the organisation's payroll system.

Once agreed, this component requires minimal ongoing maintenance. It should be delivered early so that the real-time widget and the claim submission path can both depend on it from the start of integration testing.

MileageCalculationService is a stateless synchronous utility with three public methods. calculate(distanceKm, ratePerKm) → double performs the core multiplication; roundAmount(raw) → double applies Norwegian reimbursement rounding (verify whether half-up or round-half-to-even is required with the finance team); formatAmount(amount, locale) → String wraps Dart's NumberFormat for locale-aware currency display. The service has no constructor dependencies and should be provided as a singleton or used as a static utility. Both the real-time preview widget and MileageClaimService call calculate() directly — ensure no duplication of the formula elsewhere.

The tiered-rate extension point should be designed as an optional List parameter on calculate() so existing callers are unaffected when tiers are introduced.

Responsibilities

  • Compute gross reimbursement = distanceKm × ratePerKm
  • Apply rounding rules consistent with Norwegian reimbursement standards
  • Expose a synchronous calculation method suitable for widget-layer calls
  • Support future extension for tiered distance rates

Interfaces

calculate(double distanceKm, double ratePerKm) → double
formatAmount(double amount, String locale) → String
roundAmount(double raw) → double

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/mileage-calculation 5 endpoints
GET /api/v1/mileage-calculation
GET /api/v1/mileage-calculation/:id
POST /api/v1/mileage-calculation
PUT /api/v1/mileage-calculation/:id
DELETE /api/v1/mileage-calculation/:id