# CostCenterHierarchy

## Description

CostCenterHierarchy is the organizational structure entity that defines a tree-based grouping of cost centers for hierarchical roll-up reporting and cost aggregation. Each hierarchy carries a name, version identifier, and company scope. A hierarchy must be established before any cost centers can be created within a company, following the SAP CO pattern where a hierarchy root is a prerequisite for cost center master data. Multiple hierarchy versions can exist within the same company to support current and planned organizational structures.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createCostCenterHierarchy](../commands/CreateCostCenterHierarchy.md) - Create a new cost center hierarchy with a name and version for a company

### Query Definitions

- [GetCostCenterHierarchy](../queries/GetCostCenterHierarchy.md) - Retrieve a cost center hierarchy by id with its full node tree

### Models

- CostCenterHierarchy
- CostCenterHierarchyNode

### Invariants

- Cost center hierarchy requires a name and version identifier
- Cost center hierarchy must reference a valid companyId; the company must be in ACTIVE status
- Cost center hierarchy is scoped to a company; hierarchies from different companies are fully isolated
- A cost center hierarchy can have multiple versions within the same company
- A hierarchy root node must be established before child nodes can be added
- Hierarchy roll-up reporting aggregates costs from child nodes up through parent nodes to the root

### Relationships

- **References Company**: Each cost center hierarchy is scoped to a Company via companyId (organization module)
- **Has Many CostCenterHierarchyNode**: A cost center hierarchy contains one or more hierarchy nodes forming a tree structure
