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

# Vehicle Depreciation

> Depreciation calculation methods for fleet vehicles

# Vehicle Depreciation

HostMetrics calculates vehicle depreciation for profitability analysis.

## Supported Methods

### 1. Straight-Line Depreciation

The simplest method — equal depreciation each year.

```
Annual Depreciation = (Purchase Price - Salvage Value) / Useful Life (years)
Monthly Depreciation = Annual / 12
```

**Example:**

* Purchase price: \$35,000
* Salvage value: \$10,000
* Useful life: 5 years

```
Annual = ($35,000 - $10,000) / 5 = $5,000/year
Monthly = $5,000 / 12 = $416.67/month
```

### 2. Declining Balance Depreciation

Accelerated method — higher depreciation in early years.

```
Annual Depreciation = Book Value x (2 / Useful Life)
```

**Year 1:** $35,000 x 0.40 = $14,000
**Year 2:** ($35,000 - $14,000) x 0.40 = $8,400 **Year 3:** ($21,000 - $8,400) x 0.40 = $5,040
...and so on until salvage value is reached.

### 3. Mileage-Based Depreciation

Depreciation based on actual miles driven (from trip odometer readings).

```
Per-Mile Rate = (Purchase Price - Salvage Value) / Expected Lifetime Miles
Monthly Depreciation = Miles This Month x Per-Mile Rate
```

**Example:**

* Purchase: $35,000, Salvage: $10,000
* Expected: 150,000 miles
* Per-mile rate: \$0.1667/mile
* This month: 2,500 miles → \$416.67

## Configuration

Each vehicle can have depreciation configured in the Vehicle Detail page:

| Field                   | Description                                        |
| ----------------------- | -------------------------------------------------- |
| Purchase price          | Original vehicle cost                              |
| Salvage value           | Expected value at end of useful life               |
| Useful life (years)     | For straight-line and declining balance            |
| Depreciation method     | `straight_line`, `declining_balance`, or `mileage` |
| Purchase date           | When the vehicle was acquired                      |
| Expected lifetime miles | For mileage-based method only                      |

## Impact on Profitability

Monthly depreciation is included in the profitability calculation:

```
Vehicle Profit = Trip Earnings - Expenses - Depreciation
Profit Margin = (Profit / Earnings) x 100
```

This gives a more accurate picture of true profitability by accounting for the vehicle's declining value.

## Key File

`src/lib/depreciation.ts` — Contains all three depreciation calculation methods.
