> ## 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.

# GL Migration

> Map legacy system accounts to the chart of accounts and import migration data via CSV for general ledger migration.

The GL Migration page provides tooling for one-time or recurring migrations from a legacy general ledger system. It is accessible at route `/fa/gl-migration`.

## Overview

The GL Migration page has two sections:

1. **Account Mappings** — Create and manage mappings from legacy account codes to current chart-of-account entries and optional fund assignments. Mappings can be exported as JSON.
2. **Import Migration Data** (permission-gated to `fa.gl-migration.manage`) — Upload a CSV file whose rows are resolved against the account mappings. On submit, the page invokes the `fa-gl-migration-import` edge function, which returns a count of journal entries created and any row-level errors.

**Primary hooks:** `useAccountMappings`, `useCreateAccountMapping`, `useDeleteAccountMapping`, `useAccounts`, `useFunds`

**Edge function:** `fa-gl-migration-import`

## Who it's for

Permission required: `fa.gl-migration.manage`

## Before you start

* Existing account mappings must be defined before a CSV import can be run.
* Obtain the CSV from your legacy system and ensure it matches the expected format (source account data resolved via mappings).
* Have your chart of accounts and fund list ready.

## Steps

**Define account mappings**

1. Navigate to `/fa/gl-migration`.
2. In the **Account Mappings** card, fill in the **Source Code**, optional **Source Name**, **Target Account**, and optional **Fund**.
3. Click **Add** to save the mapping. Repeat for each legacy account.
4. Optionally click **Export JSON** to download all current mappings.

**Delete a mapping**

1. Click the trash icon on any mapping row to delete it.

**Import migration data**

1. In the **Import Migration Data** card, drop a CSV file onto the drop zone or click to browse. Maximum size is 5 MB.
2. Click **Run Migration Import**. The page calls the `fa-gl-migration-import` edge function.
3. On success, a toast shows the number of journal entries created. Any row errors are listed in an alert.
4. Click **Clear** to reset the file selection.

## Key concepts

* **Source Account Code:** The account identifier in the legacy system (e.g., `4100`).
* **Account Mapping:** A record linking a legacy source code to a current `fa_accounts` entry and optional `fa_funds` entry. The `source_system` field is hardcoded to `"legacy"`.

## 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/GlMigrationPage.tsx
  * src/cores/fa/hooks/useAccountMappings.ts
  * src/cores/fa/hooks/useAccounts.ts
  * src/cores/fa/hooks/useFunds.ts
</Accordion>
