Period Configuration Repository
Component Detail
Description
Reads and writes organization-specific Bufdir period preset configurations from Supabase. Supports per-organization agreement dates so that presets reflect each org's actual grant cycle boundaries rather than generic calendar years.
period-configuration-repository
Summaries
The Period Configuration Repository enables each organization to maintain its own customized reporting calendar aligned with its specific grant cycle agreements, rather than being constrained to generic calendar-year presets. This flexibility directly supports compliance accuracy by ensuring that preset date ranges reflect actual contractual boundaries with Bufdir. By storing these configurations persistently and supporting offline access, organizations can continue report preparation even without connectivity — reducing last-minute reporting failures. The investment here pays dividends across every future reporting cycle, as coordinators gain time savings from reusable presets and reduced data-entry errors.
This is a low-complexity data repository component that reads from and writes to Supabase. Its scope is narrow — CRUD operations on period preset records scoped by organization ID. No dependencies on other components, making it independently deliverable and testable early in the sprint. Testing should cover optimistic UI patterns if the watchPresets streaming interface is used, offline caching behavior, and multi-org isolation to confirm one org cannot read or write another's presets.
The watchPresets real-time stream interface adds some complexity to integration testing — confirm Supabase Realtime subscription teardown is handled correctly to prevent memory leaks across session transitions.
Period Configuration Repository is a data-layer component backed by Supabase. It exposes getPresets(orgId) and watchPresets(orgId) for reads — the latter returning a real-time stream via Supabase Realtime subscriptions — plus savePresets() and deletePreset() for mutations. All queries must be scoped by orgId using row-level security policies on the Supabase side; do not rely solely on application-layer filtering. The local caching layer (for offline use) should use a consistent cache key derived from orgId and invalidate on successful savePresets or deletePreset calls.
Avoid holding open Realtime subscriptions longer than needed — ensure close/cancel is called when the consumer BLoC disposes.
Responsibilities
- Fetch period presets for a given organization
- Persist new or updated period presets
- Cache presets locally for offline use
Interfaces
getPresets(String orgId)
savePresets(String orgId, List<PeriodPreset> presets)
deletePreset(String orgId, String presetId)
watchPresets(String orgId)
Relationships
Dependents (2)
Components that depend on this component
Related Data Entities (1)
Data entities managed by this component