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

# vehicle_configurations

> Mount and dismount events. Must be loaded before the other files.

Mount and dismount events — which component is fitted in which position on which vehicle.
Delivered daily.

**Update key:** `external_system_id` — one identifier per **mount period**, reused to close it

<Warning>
  **This file must be loaded before the others.** Defects and measurements cross-check against
  configuration data, and vehicle readings recompute component mileage from the active mounts.
  Loading readings first corrupts recorded component mileage whenever a component is swapped
  in the same batch.
</Warning>

## Columns

| Column                    | Type        | Required | Notes                                                                  |
| ------------------------- | ----------- | :------: | ---------------------------------------------------------------------- |
| `external_system_id`      | text(100)   |     ●    | One identifier per mount period, reused to close it                    |
| `vehicle_number`          | text(100)   |     ●    | Must exist in project                                                  |
| `product_group_code`      | text(20)    |     ●    | With `slot_position`, identifies the slot. Note the 20-character limit |
| `slot_position`           | text(20)    |     ●    | Must match a slot defined on the vehicle's type                        |
| `component_serial_number` | text(100)   |     ●    | Must exist in project                                                  |
| `mounted_at`              | timestamptz |     ●    |                                                                        |
| `mounted_mileage_km`      | integer     |     ○    | Vehicle odometer at mount — needed for mileage tracking                |
| `dismounted_at`           | timestamptz |     ○    | Empty means still mounted                                              |
| `dismounted_mileage_km`   | integer     |     ○    | Vehicle odometer at dismount                                           |
| `dismount_reason`         | text(255)   |     ○    |                                                                        |
| `depot`                   | text(100)   |     ○    | **Required when `dismounted_at` is set** — see below                   |
| `notes`                   | text        |     ○    |                                                                        |
| `last_updated`            | timestamptz |     ●    | Staleness key                                                          |

## A dismount is not a new row

This is the most common mistake with this file. To record a dismount, **re-send the original
mount row** with the same `external_system_id`, now carrying `dismounted_at`,
`dismounted_mileage_km`, `dismount_reason` and `depot`, and a newer `last_updated`.

Sending a separate row with a new identifier creates a second mount period rather than
closing the first.

<Warning>
  The reverse also applies: re-sending a row whose `dismounted_at` is empty, with a newer
  `last_updated`, **re-opens a closed mount period**. Your exporter must carry the dismount
  fields forward once they are set.
</Warning>

## Rules

* The slot must resolve from the combination of vehicle type, `product_group_code` and
  `slot_position` — and here the product group must match the slot's node **exactly**, and a
  miss rejects the file. This is stricter than the same column pair on
  [defects](/data/files/defects), where the code may sit below the slot's node (the ancestor
  walk) and a miss only warns: a configuration row *defines* where a component sits and must
  be precise, while a defect merely quotes the code its reporter had.
* The component's type must be among the slot's allowed component types.
* The component must **not** be in a repair-workflow status — `IN_TRANSIT`,
  `IN_TRANSIT_BACK`, `UNDER_REPAIR` or `SCRAPPED`. A part in any of those states cannot
  physically be on a vehicle. `MOUNTED`, `DISMOUNTED` and `IN_STORE` are accepted.
* A component can be actively mounted in only one place, and a slot can hold only one active
  component. Dismounts in a file are applied before mounts, so a slot handover can be
  delivered in a single file.

<Note>
  **`depot` on a dismount is enforced by a database constraint, not by validation.** It is not
  in the required-field list, so a dismount missing its depot passes validation and then fails
  at load time as a raw constraint violation — without a row number. If a file fails with an
  error that names no row, this is the first thing to check.
</Note>

## Side effects

Importing this file sets the component's status (`MOUNTED` or `DISMOUNTED`) and its
`current_location` — the vehicle number while mounted, the depot once dismounted — and
finalises the component's lifetime mileage on dismount.

## Example

A mount:

```csv theme={null}
external_system_id,vehicle_number,product_group_code,slot_position,component_serial_number,mounted_at,mounted_mileage_km,dismounted_at,dismounted_mileage_km,dismount_reason,depot,notes,last_updated
CFG-045,X61001,EA,1,0123-1,2026-03-16T11:00:00Z,16000,,,,,,2026-03-16T12:00:00Z
CFG-046,X61001,EC,1,0789-D-5,2026-03-16T11:00:00Z,16000,,,,,,2026-03-16T12:00:00Z
```

The same mount period later closed — note the identical `external_system_id`, the retained
mount fields, and the bumped `last_updated`:

```csv theme={null}
CFG-045,X61001,EA,1,0123-1,2026-01-15T08:00:00Z,12000,2026-04-29T07:00:00Z,108225,Preventive swap,Raus,Bearing temperature alarm — preventive swap pending NDT inspection,2026-05-05T10:00:00Z
```

## Why a file gets rejected

Required fields are checked first and abort before anything else runs:

```
Row 4: missing or empty external_system_id
Row 6: missing or empty slot_position
```

Then references, types and status together:

```
Row 8: vehicle_number 'X61099' not found in project
Row 9: component_serial_number '0123-9' not found in project
Row 11: slot (product_group='EA', position='1') not found for vehicle type
Row 13: component type 'Bogie' not in slot allowed types
Row 15: component '0123-1' is in repair status UNDER_REPAIR and cannot be mounted or dismounted
```
