Data Layer low complexity backendmobile
0
Dependencies
1
Dependents
2
Entities
0
Integrations

Description

Stores coordinator approval and rejection decisions, including actor identity, timestamp, and comment, linked to the parent expense claim. Provides read access for the detail screen and audit export pipeline.

Feature: Threshold-Based Expense Approval Workflow

claim-approval-repository

Summaries

The Claim Approval Decision Repository serves as the definitive record of every coordinator decision in the expense management process, capturing not just the outcome but the identity of the decision-maker, the precise timestamp, and any accompanying rationale. This structured decision record is essential for organisational accountability, enabling programme managers and administrators to review all approvals and rejections with full context. The `getApprovedClaimsForExport` interface directly supports accounting workflows and Bufdir reporting obligations, reducing the manual effort required to compile reimbursement data for financial reporting and ensuring the organisation can meet external compliance deadlines with data exported directly from the platform rather than assembled manually.

Low complexity with three clearly defined interfaces, this component can be delivered quickly and in parallel with other data-layer work. The primary integration dependency is the expense_claims table and claim_events table schema being finalised, as this repository links decisions to both. The `getApprovedClaimsForExport` query requires agreement with the accounting and reporting stakeholders on the exact fields, date range filter format, and whether the export scope is per organisation or per programme — this requirements clarification should happen before development begins to avoid rework. Testing should include verifying that `saveDecision` is idempotent or appropriately rejects duplicate decisions for the same claimId, and that export queries correctly scope results to the requesting organisation.

This component persists records to a `claim_decisions` (or equivalent) table that holds a foreign key to `expense_claims.id` and captures `coordinator_id`, `decision` (enum: approved | rejected), `comment` (nullable), and `decided_at` timestamp. The `saveDecision` method should enforce a unique constraint on `claim_id` to prevent duplicate decision records, returning a conflict error if a decision already exists rather than silently overwriting. `getDecision` is a simple primary key lookup and should return null rather than throwing when no decision exists, to allow callers to distinguish between an undecided claim and an error. `getApprovedClaimsForExport` must join to the parent `expense_claims` table to assemble the full export record including claim metadata; parameterise the date range against `decided_at` rather than `submitted_at` to correctly capture the approval event timing for financial period alignment.

Responsibilities

  • Persist coordinator approval or rejection with metadata
  • Fetch decision record for a given claim
  • Support export queries for accounting and Bufdir reporting

Interfaces

saveDecision(claimId, coordinatorId, decision, comment, timestamp)
getDecision(claimId)
getApprovedClaimsForExport(organisationId, dateRange)

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/claim-approvals 6 endpoints
GET /api/v1/claim-approvals List approval decisions with export filtering (getApprovedClaimsForExport)
GET /api/v1/claim-approvals/:claim_id Get approval decision for a specific claim (getDecision)
POST /api/v1/claim-approvals Save a coordinator approval decision (saveDecision)
PUT /api/v1/claim-approvals/:claim_id Override or correct an approval decision
DELETE /api/v1/claim-approvals/:claim_id Delete an approval record (admin only)
GET /api/v1/claim-approvals/export Export approved claims for payroll/accounting (getApprovedClaimsForExport)