> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Finance & Revenue Departments

> Manage the organization's department hierarchy and cost centers with a hierarchical tree view, flat list, and inline create/edit dialog.

Departments provides a tabbed interface for managing the organization's department hierarchy and cost centers, with both a tree view and a flat list. Route: `/fa/departments`

## Overview

The page fetches departments via `useDepartments(organizationId)`. Two tabs are available: **Hierarchy View** (rendered by `DepartmentTree`) and a flat list (second tab content not visible from page header — additional tab labels may exist). The **New Department** button opens `DepartmentDialog` with no pre-selected ID. Clicking edit on a row sets `selectedDeptId` and opens the dialog. The `DepartmentDialog` handles both create and edit based on whether `selectedDeptId` is defined.

Page header: "Departments — Manage department hierarchy and cost centers."

## Who it's for

Access follows your organization's role and module configuration.

## Before you start

* Departments are referenced in GL entries, cost allocations, and budget line items. Define them before posting entries.
* Identify the department name, code, and any parent department if applicable.

## Steps

<Steps>
  <Step title="Navigate to Departments">
    Go to `/fa/departments`.
  </Step>

  <Step title="View the hierarchy">
    The Hierarchy View tab displays the department tree via `DepartmentTree`.
  </Step>

  <Step title="Create a department">
    Click **New Department** to open `DepartmentDialog` with a blank form.
  </Step>

  <Step title="Edit a department">
    Click the edit action on a department row. The dialog opens with the department's current data.
  </Step>
</Steps>

## Key concepts

* **`useDepartments`** — Primary data hook; fetches all department records for `organizationId`.
* **`DepartmentTree`** — Component rendering the hierarchical tree view of departments.
* **`DepartmentDialog`** — Create/edit dialog; accepts `deptId` (undefined for create) and `organizationId`.

## Creating a department

New department creation is handled through an inline dialog on the Departments page. The `/fa/departments` page includes a **New Department** button that opens `DepartmentDialog` with `departmentId={undefined}` (create mode). `DepartmentTree` confirms that departments support a hierarchical structure.

1. Navigate to `/fa/departments`.
2. Click **New Department** (top right).
3. Complete the `DepartmentDialog` form fields.
4. Save to create the department. It appears in the hierarchy tree.

To edit an existing department:

1. Locate the department in the Hierarchy View.
2. Click the edit action on the department node.
3. Update and save.

<Warning>
  SME: The exact fields and validation rules in `DepartmentDialog` are not fully observable from the page component alone. Confirm required fields with the implementation team.
</Warning>

## Related

<Columns cols={2}>
  <Card title="Finance & Revenue" icon="building-columns" href="/fa/overview">
    Finance & Revenue core overview.
  </Card>

  <Card title="Governance & parity" icon="scale-balanced" href="/governance/index" />
</Columns>

<Note>
  This page documents shipped product behavior. It is not medical, legal, or
  billing advice. Verify against your organization's policies and applicable
  regulations before using it for clinical, compliance, or billing decisions.
  Protected health information (PHI) shown in the product is governed by your
  tenant's access controls and is never exposed in this documentation.
</Note>

<Accordion title="Documentation sources">
  * src/routes/fa.tsx
  * src/cores/fa/pages/DepartmentsPage.tsx
  * src/cores/fa/hooks/useDepartments.ts
  * src/cores/fa/components/DepartmentTree.tsx
  * src/cores/fa/components/DepartmentDialog.tsx
</Accordion>
