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

# Credit Lines

> List, view, and manage revolving credit facilities with utilization metrics, expiry warnings, and inline edit capability.

Credit Lines lists all revolving credit facilities for the organization, with status and utilization filters, summary stat cards, and high-utilization alerts. Route: `/fa/credit-lines`

## Overview

The page fetches all credit lines via `useCreditLineList(organizationId, filters)` and high-utilization credit lines via `useHighUtilizationCreditLines`. Summary stat cards show aggregate totals. A `UtilizationFilter` dropdown (`all`, `low`, `medium`, `high`) and a `CreditLineStatus` dropdown filter the table. An `Alert` component displays if high-utilization lines are present. The **New Credit Line** button opens `CreditLineDialog`. Clicking a row navigates to `/fa/credit-lines/:id`.

## Who it's for

Requires permission: `fa.credit_lines.view`

## Before you start

* You must hold the `fa.credit_lines.view` permission.

## Steps

<Steps>
  <Step title="Navigate to Credit Lines">
    Go to `/fa/credit-lines`.
  </Step>

  <Step title="Review summary stats">
    Stat cards show aggregate credit line information.
  </Step>

  <Step title="Check high-utilization alert">
    If any credit lines have high utilization, an alert banner is shown.
  </Step>

  <Step title="Filter the list">
    Use the utilization filter and status filter dropdowns to narrow the list.
  </Step>

  <Step title="Open a credit line">
    Click a row to navigate to its detail page at `/fa/credit-lines/:id`.
  </Step>

  <Step title="Create a new credit line">
    Click **New Credit Line** to open `CreditLineDialog`.
  </Step>
</Steps>

## Key concepts

* **`useCreditLineList`** — Primary list hook; accepts `organizationId` and filter parameters.
* **`useHighUtilizationCreditLines`** — Hook flagging lines with high utilization.
* **`UtilizationFilter`** — Local type: `'all' | 'low' | 'medium' | 'high'`.
* **`CreditLineStatus`** — Type for credit line lifecycle states.
* **`CreditLineWithRelations`** — Full type for credit line records including relations.

## Viewing a credit line

The detail view at `/fa/credit-lines/:id` displays all information for a single credit line record, including utilization percentage with color-coded indicators, expiry warnings, and an inline edit capability.

The page loads a credit line by `:id` via `useCreditLine(id, currentOrganization?.id)` and computes: days to expiry from `end_date`, expiry warning flag (≤30 days), utilization color (`bg-destructive` ≥80%, `bg-warning` ≥50%, `bg-success` otherwise). The `CreditLineStatusBadge` shows current status. The edit button opens `CreditLineDialog` in edit mode. Breadcrumb uses `credit_line_number`.

Key concepts:

* **`useCreditLine`** — Primary data hook; fetches a single credit line by `id` and `organizationId`.
* **`utilization_percentage`** — Field on the credit line record representing current utilization.
* **`CreditLineStatus`** — Type for credit line lifecycle status.
* **`CreditLineStatusBadge`** — Component rendering the status visually.
* **`daysToExpiry`** — Computed as `differenceInDays(new Date(end_date), new Date())`.

1. Go to `/fa/credit-lines` and click a record, or navigate directly to `/fa/credit-lines/:id`.
2. Review the credit line number, status badge, utilization bar, and expiry information.
3. Check the utilization bar: green below 50%, yellow 50–79%, red 80%+. An expiry warning appears when fewer than 30 days remain.
4. Click Edit to open `CreditLineDialog` and save changes to update the record.

## 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/CreditLinesPage.tsx
  * src/cores/fa/pages/CreditLineDetailPage.tsx
  * src/cores/fa/hooks/useCreditLines.ts
  * src/cores/fa/components/CreditLinesTable.tsx
  * src/cores/fa/components/CreditLineDialog.tsx
  * src/cores/fa/components/CreditLineStatusBadge.tsx
  * src/cores/fa/types/index.ts
</Accordion>
