OrgHierarchyService
Component Detail
Description
Business logic layer that enforces hierarchy integrity and attribution rules across organizational levels. It resolves parent-child relationships, validates cycle-free trees, and computes how activity data rolls up through federation, region, and branch levels. The service also detects and prevents double-reporting when a member belongs to multiple local units.
org-hierarchy-service
Sources & reasoning
NHF's unique need (lines 107-109) makes hierarchy management a launch requirement because NHF is one of the initial four organizations and their data integrity depends on it. Blueprint assigns MVP target_release to multi-organization-hierarchy, consistent with admin MVP scope including org management. Without it NHF cannot correctly attribute or report activities.
-
docs/source/likeperson.md · line 109Bredest organisasjonsstruktur: 12 landsforeninger, 9 regioner, 1 400 lokallag - aktivitetsfordeling mellom ledd må støttes.
-
docs/source/likeperson.md · line 107Håndtering av medlemmer i flere lokallag (opptil 5): Avklare tilhørighet og hindre dobbeltrapportering.
Responsibilities
- Validate and enforce acyclic parent-child relationships when nodes are created or moved
- Apply configurable activity attribution rules (exclusive, proportional, top-level-only) per org level
- Compute roll-up aggregations for reporting data through the full hierarchy
- Detect double-reporting scenarios for members with multiple local unit memberships
- Enforce feature-toggle checks before exposing multi-org capabilities to a tenant
Interfaces
buildOrgTree(tenantId: string): OrgTreeNode
addOrgUnit(tenantId: string, payload: CreateOrgUnitInput): OrgUnit
moveOrgUnit(unitId: string, newParentId: string): void
computeRollup(rootUnitId: string, metric: string): RollupResult
detectDoubleReporting(memberId: string): DoubleReportingConflict[]
setAttributionRule(unitId: string, rule: AttributionRule): void
Related Data Entities (2)
Data entities managed by this component