# ECB Exchange Rates - User Guide

## What this does
The application can import official ECB exchange rates into the internal rates table.

This lets teams use up-to-date and historical FX rates directly in the app database.

## Standard usage
Run the import command:

```bash
php artisan lnc:sync-ecb-exchange-rates
```

By default, this imports rates for the last 7 days.

## Import a longer history
You can force historical backfill in years from **today**:

```bash
php artisan lnc:sync-ecb-exchange-rates --years=10
```

This example imports up to 10 years of ECB history ending today.

## Import X years starting from a fixed date
For very long ranges (for example 20–30 years), use a **start date** and a **span in years** (the import is split into smaller ECB requests automatically):

```bash
php artisan lnc:sync-ecb-exchange-rates --start=2000-01-01 --years=30
```

Optional: set an explicit end date:

```bash
php artisan lnc:sync-ecb-exchange-rates --start=2010-01-01 --end=2020-12-31
```

## Notes

- Data source is ECB.
- Base currency is EUR.
- Rates are available on ECB business/publication days.
- Running the command again updates existing rows (safe to re-run).
- The import may **fail** if the selected period yields no rows (example: wrong date range).

## Typical operations flow

1. Initial backfill once (example: 5 or 10 years)
2. Daily cron import for refresh
3. Re-run manually anytime if needed

## Common issues

- **No new data on some days**
  - Normal on non-publication days (weekends/holidays).
- **Import fails**
  - Check server internet access and logs (`storage/logs`).
