# RAMA AG — Phase 12 — Historical PDF Import

Status: **DONE** (branch `develop/v1`; not yet activated on `:3400`).

## Implemented features
- `/smgv/import`: PDF upload (max. 15 MB, `%PDF-` check, encrypted files refused). Files are stored privately under their SHA-256; uploading the same file twice is refused.
- `App\Support\Pdf\PdfTextExtractor` reads text with positions (TrueType/ToUnicode and WinAnsi), page classification B / M / J, and per-employee blocks.
- Extracted fields: year, name, Vorjahr Stundensaldo, Vorjahr Ferien, and the annual carry-over values (shown for control only). Each row gets a confidence (high / medium / low) and an exact name match against employees; unknown or ambiguous names are never guessed.
- Preview with an editable mapping; **explicit confirmation**; existing opening balances are only overwritten when explicitly ticked; import and audit history are kept.
- Checked read-only against the client reference: 140 pages, B M×12 J × 10 classified correctly, all 10 years, names and balance lines found. **No real data was imported.**
- Round trip tested: our export, then import, gives the same values.

## Modified / added files
`app/Support/Pdf/PdfTextExtractor.php`, `app/Services/Smgv/SmgvImportService.php`, `app/Livewire/Smgv/Import.php` + view

## Database changes
`smgv_import_batches` (private path, unique SHA-256, extracted JSON, confirmed mapping).

## Test results
Unit `tests/Unit/SmgvTimeEngineTest.php` (8), feature `tests/Feature/SmgvAccountingTest.php` (8), `tests/Feature/SmgvCenterTest.php` (6). Full regression: main 562 (464 passed, 98 skipped by design), memory 97 (96 + 1 skipped), upgrade 2: **0 failures**.

## Security considerations
All user-facing actions are Administrator-only: `admin` route middleware plus a fresh database check on every Livewire request (`SmgvContext::bootSmgvContext`) and a service-level `Actor::admin()`. Audit entries never contain personal values (no AHV, address or birth date). Isolation is unchanged: RAMA database and account only, no outbound mail or HTTP, and Quality was never touched.

## Technical decisions, assumptions and limitations
Scope is deliberately limited to the opening values; monthly figures from historical PDFs are not imported as accounting data.

## Outstanding blockers
The GAV/SMGV rule confirmations listed in `RAMA_AG_MASTER_DEVELOPMENT_TRACKER.md` remain open. Until they are answered, values are drafts (watermarked, with banners).
