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

# Toll Reconciliation

> Connecting toll accounts, importing transactions, matching tolls to trips, and cost analysis

# Toll Reconciliation

HostMetrics tracks toll charges across your fleet and matches them to specific trips for accurate cost accounting. This feature supports multiple toll providers and both manual CSV import and automatic sync.

## Supported Toll Providers

| Provider    | Region                    | Import Method              |
| ----------- | ------------------------- | -------------------------- |
| **NTTA**    | Texas (Dallas/Fort Worth) | CSV import, automatic sync |
| **EZPass**  | Northeast US              | CSV import                 |
| **SunPass** | Florida                   | CSV import                 |

See the data reference pages for CSV formats: [NTTA](/data-reference/ntta-toll-csv), [EZPass](/data-reference/ezpass-toll-csv), [SunPass](/data-reference/sunpass-toll-csv).

## Connecting Toll Accounts

On the Data Sources page, users can add toll account credentials. These are stored in the `toll_accounts` table and used for automatic sync.

## Import Methods

<Accordion title="CSV Import">
  Download a transaction report from your toll provider's website, then upload it in HostMetrics. The system parses provider-specific CSV formats, extracts transaction date, amount, plaza/location, and tag ID.
</Accordion>

<Accordion title="Automatic Sync (Lambda)">
  For supported providers (NTTA), an AWS Lambda function periodically scrapes toll transactions using saved credentials. The sync runs on a schedule and can also be triggered manually. See [Toll Sync Architecture](/architecture/toll-sync) for technical details.
</Accordion>

## Trip Matching

Toll transactions are matched to trips by comparing:

1. **Date** — The toll transaction date falls within the trip's start and end dates
2. **Vehicle** — The toll tag is associated with a specific vehicle

<Warning>
  Toll dates are stored as plain date strings (not UTC timestamps) because toll agencies report in their operating timezone. Matching uses date-only comparison. See the timezone architecture section in the project docs for details.
</Warning>

## Reconciliation Table

The `TollReconciliationTable` component shows all toll transactions with their match status:

| Status        | Meaning                                       |
| ------------- | --------------------------------------------- |
| **Matched**   | Toll is linked to a specific trip and vehicle |
| **Unmatched** | No trip found for the toll date and vehicle   |
| **Manual**    | User manually assigned the toll to a trip     |

## Cost Analysis

The Reports page includes toll-specific analytics:

* **Summary cards** (`TollSummaryCards`) — Total toll costs, average per trip, matched percentage
* **Trend chart** (`TollTrendChart`) — Monthly toll spending over time
* **By-vehicle breakdown** (`TollsByVehicleChart`) — Which vehicles incur the most tolls
* **Reconciliation report** — Full matched/unmatched transaction list with CSV export

## Key Files

| File                                                 | Purpose                            |
| ---------------------------------------------------- | ---------------------------------- |
| `src/lib/db/toll-transactions.ts`                    | Import, parse, and query toll data |
| `src/lib/db/toll-accounts.ts`                        | Manage toll provider credentials   |
| `src/app/api/tolls/sync/route.ts`                    | API route for manual sync trigger  |
| `src/components/reports/TollsTab.tsx`                | Toll analysis tab in Reports       |
| `src/components/reports/TollReconciliationTable.tsx` | Match status table                 |
