Service Layer low complexity backend
1
Dependencies
1
Dependents
1
Entities
0
Integrations

Description

Validates the selected report period before allowing the user to proceed to export. Checks that the period is complete, that the date range is non-zero, and that it does not overlap with a previously submitted report for the same organization.

Feature: Bufdir Report Period Selection

report-period-validator

Summaries

The Report Period Validator protects the organization from costly reporting errors by automatically enforcing data integrity rules before any Bufdir export is initiated. By blocking invalid date ranges, incomplete periods, and duplicate submissions, this component eliminates the risk of submitting incorrect reports to Bufdir — which could jeopardize grant compliance, trigger audit scrutiny, or require time-consuming corrections through official channels. It provides coordinators with immediate, clear feedback so errors are caught at the point of entry rather than after submission, reducing administrative rework and protecting the organization's reputation with its funding authority.

The Report Period Validator is a low-complexity backend service component with well-defined inputs and outputs, making it straightforward to implement and unit-test in isolation. Its primary dependency is the Period Configuration Repository, so scheduling should account for that component being available first. Testing requires representative sets of valid and invalid period scenarios including boundary cases such as same-day ranges, future end dates, and overlapping previously-submitted periods. Because it gates access to the export flow, any regression here blocks a critical user path — regression coverage should be thorough.

Deployment risk is low as it contains no UI and no external service calls beyond its repository dependency.

Report Period Validator is a pure backend service component exposing three interfaces: validate(ReportPeriod, String orgId) as the primary entry point, isRangeValid(DateTimeRange) for date arithmetic checks, and hasOverlapWithSubmitted(DateTimeRange, String orgId) which queries the Period Configuration Repository to compare against previously submitted report periods. The component has no direct database access — all persistence is delegated to period-configuration-repository. Validation logic should be stateless and synchronous where possible, with the overlap check being the only async operation. Keep business rules explicit and testable as separate predicates; avoid embedding them inline in the validate() orchestration method to ease future rule additions.

Responsibilities

  • Validate non-zero date range
  • Check period completeness (end date not in the future)
  • Detect overlap with previously submitted Bufdir reports

Interfaces

validate(ReportPeriod period, String orgId)
isRangeValid(DateTimeRange range)
hasOverlapWithSubmitted(DateTimeRange range, String orgId)

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/report-period-validations 7 endpoints
GET /api/v1/report-period-validations List historical validation results for an organization
GET /api/v1/report-period-validations/:id Get a specific validation result by ID
POST /api/v1/report-period-validations Validate a ReportPeriod for an organization (validate)
PUT /api/v1/report-period-validations/:id Re-run validation for a previously saved validation result
DELETE /api/v1/report-period-validations/:id Delete a saved validation result
POST /api/v1/report-period-validations/range-check Check whether a DateTimeRange has valid start/end boundaries
+1 more