Service Layer medium complexity backend
0
Dependencies
3
Dependents
2
Entities
0
Integrations

Description

Maps the application's internal activity types to the category codes required by Bufdir. Uses configuration stored in activity_type_configuration to resolve mappings, and reports unmapped types as warnings in the preview.

Feature: Bufdir Report Export

bufdir-category-mapper

Summaries

The Bufdir Category Mapper ensures that every activity recorded in the system is correctly classified according to government-mandated reporting standards. Without accurate category mapping, submitted reports risk rejection or audit flags from Bufdir, which could delay funding disbursements and damage NHF's compliance standing. By centralising all mappings in configuration rather than hard-coded rules, the organisation can adapt to future category schema changes from Bufdir without costly redevelopment, protecting the long-term investment in the reporting system and reducing administrative overhead for member chapters.

This component has medium complexity and sits on the critical path for any Bufdir export feature. It must be completed and validated before PDF, CSV, or API submission can be tested end-to-end, since all three output formats depend on it. Key delivery risk is incomplete mapping coverage: any internal activity type not present in the mapping table will surface as a warning in export previews, which may block user acceptance testing. A mapping completeness audit against all active activity types in the database should be a formal acceptance criterion before release.

No external dependencies reduce scheduling risk.

The Bufdir Category Mapper is a backend service component that reads from the activity_type_configuration table to resolve internal activity type IDs to Bufdir-specified category codes. It exposes five interfaces: mapActivityType for single-record resolution, getUnmappedTypes for batch gap analysis, getAllMappings for admin inspection, validateMappingCompleteness for pre-export checks, and updateMapping for runtime configuration changes without deployment. The component has no runtime dependencies on other components but is consumed by PDF and CSV generation services. Implement as a pure service class with injected database access; cache the full mapping table on first load and invalidate on updateMapping calls to avoid per-record DB hits in batch export scenarios.

Responsibilities

  • Map internal activity type IDs to Bufdir category codes
  • Identify unmapped activity types and raise warnings
  • Support future Bufdir category schema updates via configuration

Interfaces

mapActivityType(internalTypeId)
getUnmappedTypes(activities)
getAllMappings()
validateMappingCompleteness(activityTypes)
updateMapping(internalTypeId, bufdirCode)

Relationships

Dependents (3)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/bufdir-category-mappings 8 endpoints
GET /api/v1/bufdir-category-mappings List all activity type mappings
GET /api/v1/bufdir-category-mappings/:mapping_id Get a single category mapping
POST /api/v1/bufdir-category-mappings Create a new category mapping
PUT /api/v1/bufdir-category-mappings/:mapping_id Update an existing category mapping
DELETE /api/v1/bufdir-category-mappings/:mapping_id Delete a category mapping
POST /api/v1/bufdir-category-mappings/map-activity-type Map a single internal activity type to a Bufdir category
+2 more