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

Description

Business-logic service that owns the rules engine for expense type validation on both client and server. It evaluates whether a given combination of expense types is valid according to the organization's exclusion groups and reimbursement constraints, and rejects invalid combinations before they reach the persistence layer. The service also orchestrates fetching and caching of expense type configuration so the mobile app can operate offline.

Feature: Expense Types & Requirements

expense-type-rules-service

Sources & reasoning

Lines 68 and 113 from two separate sections both explicitly require fixed expense type selection that makes invalid combinations technically impossible. The parent area is Fase 2 (line 148), mapping to v1.0. This feature is foundational to travel-expense-registration and must ship in the same release.

  • Faste valg for utleggstype - ikke fritekst - for å hindre feilkombinasjon (f.eks. både km og bussbillett).
  • Detaljert refusjonsstyring med faste valg som gjør feilkombinasjon teknisk umulig (f.eks. km + bussbillett kan ikke velges samtidig). Automatisk godkjenning under terskel.

Responsibilities

  • Validate expense type combinations against configured exclusion groups
  • Fetch organization-specific expense type configuration from the backend API
  • Cache configuration locally for offline mobile access and invalidate on TTL or push
  • Enforce server-side rejection of submissions that violate exclusion rules
  • Provide reimbursement rate lookups for eligible expense types

Interfaces

validateSelection(orgId: string, selectedTypeIds: string[]): ValidationResult
getExclusionGroups(orgId: string): ExclusionGroup[]
fetchAndCacheConfig(orgId: string): Promise<ExpenseTypeConfig>
getCachedConfig(orgId: string): ExpenseTypeConfig | null
getReimbursementRate(orgId: string, typeId: string): number

Related Data Entities (1)

Data entities managed by this component