# Organization Management

Complete module for managing organizational structures and the Organization Chart in the ACoreX Platform.

Key capabilities:

- Entities for Business Units, Business Unit Types, Positions, Roles, Responsibilities, Teams, and the Chart store
- Dynamic Organization Chart generation from entity data (versioned)
- Connectivity mocks and seeders for demo data
- i18n resources for EN/FA

## Entities

### BusinessUnitType

Defines business unit kinds and whether they are location-based.

Fields:

- `id: uuid`
- `code: string` (e.g., `division`, `department`, `branch`)
- `title: string`
- `isLocationBased: boolean`

### BusinessUnit

Unified node that represents Division / Department / Branch.

Fields:

- `id: uuid`
- `title: string`
- `description?: string`
- `typeId: string` → exposes `type.{ id, code, title, isLocationBased }`
- `parentId?: string` → exposes `parent.{ id, title }`
- `countryId? / stateId? / cityId?` → exposes `country/state/city.{ id, title }`
- Computed (plugin): `manager` (placeholder for now)

### Position

Standard position catalog with category support. Includes `isManager: boolean` for manager identification.

### Chart

Persists generated org chart data versions. Each record contains the `version` and the root `data` node.

## Org Chart

The chart is generated from entity data and rendered with a simplified legend. Nodes include:

- Company (virtual root from tenant)
- Location: Country → State → City (virtual grouping)
- Business Units: Division / Department / Branch (derived from `BusinessUnitType.code`)
- Position (subtitle shows employee display name, description shows employee role when available)

Example of the generated node (simplified):

```typescript
{
  id: '...',
  title: 'QA Manager',
  subtitle: 'Alexandra Kim',
  description: 'QA Manager',
  type: 'Position',
  entity: { id: 'position-id', source: 'OrganizationManagement.Position' }
}
```

## Data Generation (Mocks)

- `BusinessUnitType` mocks: `division`, `department`, `branch`
- `BusinessUnit` mocks: hierarchical sample with `parent`, `type`, and location fields (hydrated from Location mocks)
- `Position` mocks: categorized with `isManager` inferred from title
- `PositionAssignment` mocks (HCM): one active primary per employee, scoped by `businessUnitId`

Seeders are registered in `connectivity/mock` under Organization Management.

## Generate Org Chart Version

Use the mock command `organization.chart.generate` to build a new version based on current entity data. The UI page exposes a "Generate" action that triggers the command.

## i18n

Demo app assets include `en-US` and `fa-IR` keys for:

- `business-unit-type` (title, code, is-location-based, basic-info)
- `business-unit` (basic-info, relation-info, geographic-info, type/parent)
- Chart labels and actions

## Importing

```typescript
import {
  AXMOrganizationManagementBusinessUnitEntityModule,
  AXMOrganizationManagementBusinessUnitTypeEntityModule,
} from '@acorex/modules/organization-management';
```

This package is a secondary entry-point of `@acorex/modules`.
