# CostCenter

## Description

CostCenter represents a responsibility area within a company that accumulates overhead costs, such as an IT department, a production floor, or a facilities group. Each cost center carries a code, name, optional description, category (e.g., overhead, production, administration, sales, research), optional responsible person, optional department reference, company scope, validity period (valid-from/to dates), and a position within a cost center hierarchy via its hierarchy node assignment. Cost centers are distinct from organizational departments and serve as the primary receiver for overhead costs, acting as the foundational cost object referenced by cost allocation, budget management, variance analysis, and internal order settlement. Cost centers use validity-based lifecycle management rather than explicit status transitions.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createCostCenter](../commands/CreateCostCenter.md) - Create a new cost center with code, name, category, validity period, and hierarchy node assignment
- [updateCostCenter](../commands/UpdateCostCenter.md) - Update mutable fields of a cost center (name, description, category, responsible person, department)
- [deleteCostCenter](../commands/DeleteCostCenter.md) - Delete a cost center that has no dependent records (postings, budgets, allocation rules)
- [assignCostCenterToHierarchyNode](../commands/AssignCostCenterToHierarchyNode.md) - Assign or reassign a cost center to a different hierarchy node within the same company

### Query Definitions

- [GetCostCenter](../queries/GetCostCenter.md) - Retrieve a cost center by id
- [ListCostCenters](../queries/ListCostCenters.md) - List cost centers with filters (category, company, validity period)

### Models

- CostCenter

### Invariants

- Cost center requires a unique code within the company scope
- Cost center code cannot be changed after creation to preserve referential integrity
- Cost center requires a name and a valid category (overhead, production, administration, sales, research)
- Cost center must reference a valid companyId; the company must be in ACTIVE status
- Cost center must reference a valid hierarchy node within the same company's hierarchy
- Cost center valid-from date must be earlier than or equal to valid-to date when both are provided
- A cost center with no valid-to date is treated as indefinitely active from its valid-from date
- A cost center whose valid-to date has passed cannot receive new cost postings
- A cost center whose valid-from date is in the future cannot receive cost postings until that date is reached
- A cost center cannot be deleted if it has associated cost postings, budget line items, or allocation rules referencing it
- A cost center can only be assigned to a hierarchy node within the same company's hierarchy
- Multiple cost centers can be assigned to the same hierarchy node
- Changing a cost center's category is permitted and emits an audit event
- Cost centers are scoped to a company; cost centers from different companies are fully isolated

### Relationships

- **References Company**: Each cost center is scoped to a Company via companyId (organization module)
- **References CostCenterHierarchyNode**: Each cost center is assigned to a CostCenterHierarchyNode via hierarchyNodeId
- **References User**: Each cost center optionally references a responsible person via responsiblePersonId (user-management module)
- **References Department**: Each cost center optionally references a Department via departmentId (organization module)
