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

Description

Transforms raw aggregated numeric data into the ordered section-and-field hierarchy defined by the official Bufdir reporting form. Maintains the canonical field key mapping between internal activity category identifiers and the label strings required by Bufdir. Acts as the single source of truth for form layout and field ordering.

Feature: Bufdir Report Preview

bufdir-report-structure-mapper

Summaries

The Bufdir Report Structure Mapper ensures the organization consistently delivers government reports in the exact format required by official Bufdir guidelines, eliminating the risk of rejected submissions due to structural non-compliance. By acting as the single authoritative source for field ordering and labeling, this component dramatically reduces the manual review burden on coordinators and administrators, freeing them to focus on data quality rather than formatting correctness. Compliance failures can result in delayed funding, reputational damage with government bodies, and administrative overhead — this component directly mitigates those risks. Its centralized design means any future changes to the official Bufdir form structure require updates in exactly one place, reducing long-term maintenance cost and ensuring consistent compliance across all reporting periods.

The Bufdir Report Structure Mapper has medium complexity and is a foundational dependency for all downstream report generation and preview features. It carries no external dependencies itself, making it safe to develop and test in isolation early in the project timeline. Teams working on preview rendering, PDF export, and validation services will block on this component being stable, so it should be prioritized in early sprints. The primary delivery risk is requirements drift — the Bufdir form structure is dictated by external government guidelines that may change between development and release.

A versioning strategy or configurable schema approach should be considered to mitigate this. Testing should include contract tests verifying every official Bufdir field key and section order against a reference copy of the current form.

The Bufdir Report Structure Mapper is a shared-context, stateless transformation component responsible for converting flat aggregated numeric data into the hierarchical section-and-field model required by the official Bufdir reporting form. Its core interface, `mapAggregatedDataToSections(aggregatedData)`, accepts a flat key-value map of activity category IDs to numeric values and returns an ordered array of section objects, each containing an ordered array of field descriptors with resolved labels. `getSectionDefinitions()` exposes the raw schema for use by rendering and validation layers. `getFieldLabel(fieldKey)` provides the canonical human-readable Bufdir label for any internal ID, and `getRequiredFields()` drives completeness validation upstream.

Since it has zero external dependencies, it is fully unit-testable in isolation. Field key mappings should be maintained as a typed constant map to enable compile-time exhaustiveness checks as the Bufdir schema evolves.

Responsibilities

  • Define the canonical Bufdir form section and field ordering
  • Map internal activity category IDs to official Bufdir field labels
  • Produce a structured report model from flat aggregated data
  • Handle fields with no corresponding aggregated data as empty

Interfaces

mapAggregatedDataToSections(aggregatedData)
getSectionDefinitions()
getFieldLabel(fieldKey)
getRequiredFields()
getSectionForField(fieldKey)

Relationships

Dependents (1)

Components that depend on this component

API Contract

View full contract →
REST /api/v1/report-sections 7 endpoints
GET /api/v1/report-sections
GET /api/v1/report-sections/:id
POST /api/v1/report-sections
PUT /api/v1/report-sections/:id
DELETE /api/v1/report-sections/:id
GET /api/v1/report-sections/fields/:fieldKey/label
+1 more