Period Preset Service
Component Detail
Description
Loads and resolves the list of period presets configured for a specific organization. Handles organizations that have custom agreement dates with Bufdir, ensuring presets are always org-scoped rather than globally hardcoded.
period-preset-service
Summaries
The Period Preset Service is the backend engine that ensures every organization sees reporting periods that reflect their specific contractual agreement with Bufdir — not a generic global calendar. This is commercially significant because Bufdir organizations operate on individualized fiscal cycles, and presenting incorrect periods would lead to data submitted against the wrong grant year. By centralizing and owning the logic for resolving organization-specific presets, this service eliminates a class of configuration error that could otherwise result in funding disputes or compliance failures. It directly supports the application's value proposition of organization-aware, accurate reporting.
Period Preset Service is a low-complexity backend service with a single repository dependency on period-configuration-repository. Development effort is approximately two to three days including unit tests. The key scheduling dependency is the availability of the period-configuration-repository interface and the underlying organization configuration data model — both must be finalized before this service can be fully implemented and tested. The service exposes three methods that are consumed by the frontend period picker flow, so it sits on the critical path for the reporting period selection feature.
Ensure that the contract for getPresetsForOrganization return types is agreed with the frontend team early to avoid integration delays.
Period Preset Service is a backend service component responsible for loading and resolving organization-scoped period presets. It depends on period-configuration-repository for data access. It exposes three methods: getPresetsForOrganization(String orgId) returns an ordered list of PeriodPreset objects for the given organization; resolvePresetRange(PeriodPreset) maps a preset identifier to a concrete DateTimeRange by evaluating the organization's agreement dates; getCurrentCyclePreset(String orgId) returns the preset matching the current date according to the organization's configuration. The service must handle organizations with custom Bufdir agreement dates distinctly from those using default calendar years — this branching logic is the core business rule.
All methods should be async and return Futures. Error handling must cover cases where an organization has no configured presets (return empty list, do not throw). Data models referenced are period-preset and organization. Unit tests should cover default calendar year orgs, custom agreement date orgs, and the edge case where today falls on a preset boundary.
Responsibilities
- Fetch organization-specific period presets from configuration
- Map preset identifiers to concrete DateTimeRange values
- Return ordered list of selectable presets
Interfaces
getPresetsForOrganization(String orgId)
resolvePresetRange(PeriodPreset)
getCurrentCyclePreset(String orgId)
Relationships
Related Data Entities (2)
Data entities managed by this component