Data Layer medium complexity mobilebackend
0
Dependencies
0
Dependents
0
Entities
0
Integrations

Description

Data access layer responsible for persisting and retrieving expense type definitions, exclusion group mappings, and reimbursement rates per organization. It abstracts the underlying storage so that the service layer works against a consistent interface whether reading from the remote database or the local mobile cache. Coordinators' configuration changes are written through this repository and propagate to connected clients on their next sync.

Feature: Expense Types & Requirements

expense-type-repository

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

  • Store and retrieve expense type definitions scoped by organization ID
  • Persist exclusion group assignments linking types that cannot be co-selected
  • Record configured reimbursement rates per expense type and organization
  • Provide a local SQLite cache interface for the mobile client's offline reads
  • Support coordinator CRUD operations for expense type configuration in the admin portal

Interfaces

getExpenseTypes(orgId: string): Promise<ExpenseType[]>
getExclusionGroups(orgId: string): Promise<ExclusionGroup[]>
saveExpenseType(orgId: string, type: ExpenseType): Promise<void>
deleteExpenseType(orgId: string, typeId: string): Promise<void>
upsertCachedConfig(orgId: string, config: ExpenseTypeConfig): Promise<void>