# ProfitCenterHierarchyNode

## Description

ProfitCenterHierarchyNode represents a single node within a profit center hierarchy tree, supporting parent-child relationships that enable hierarchical roll-up of profitability results from leaf-level profit centers through intermediate grouping nodes to the root. Each node carries a name, optional parent node reference, hierarchy reference, sort order, and level attribute. Nodes serve as the assignment target for profit centers, allowing flexible grouping by business dimension such as region, product line, or service line.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createProfitCenterHierarchyNode](../commands/CreateProfitCenterHierarchyNode.md) - Create a new hierarchy node as a child of an existing node or as the root node
- [deleteProfitCenterHierarchyNode](../commands/DeleteProfitCenterHierarchyNode.md) - Delete a hierarchy node that has no child nodes or assigned profit centers

### Query Definitions

- [GetProfitCenterHierarchy](../queries/GetProfitCenterHierarchy.md) - Retrieve hierarchy nodes as part of the full hierarchy tree

### Models

- ProfitCenterHierarchyNode

### Invariants

- Hierarchy node requires a name
- Hierarchy node must belong to a valid ProfitCenterHierarchy via hierarchyId
- A hierarchy node cannot be its own parent (no self-referencing)
- A hierarchy node cannot create a circular reference (child cannot be an ancestor of its parent)
- Removing a hierarchy node that has child nodes is rejected; children must be reassigned or removed first
- Removing a hierarchy node that has profit centers assigned is rejected; profit centers must be reassigned first

### Relationships

- **Belongs to ProfitCenterHierarchy**: Each node belongs to a ProfitCenterHierarchy via hierarchyId
- **Self-referencing Parent**: Each node optionally references a parent ProfitCenterHierarchyNode via parentNodeId
- **Has Many ProfitCenter**: A hierarchy node can have multiple profit centers assigned to it
