# RAMA AG — SMGV Historical Import Report

Status: **IMPORTED into the live database on 27.11.2026 (batch #1, `rama-v1.0.0-rc3`).**

## 1. Source document

| Item | Value |
| --- | --- |
| Files found | `Downloads\smgv-zeitkontrolle-alle-2026.pdf` and the protected reference copy `RAMA AG\reference\smgv-zeitkontrolle-alle-2026.pdf`: **identical** (same SHA-256). No `…(1).pdf` exists on this computer |
| SHA-256 | `60b475752329f317556852eec6865be9bad45cdc82dbfef32aa9cff7dc678e15` (1,961,288 bytes) |
| Structure | 140 pages = **10 employees × 14 pages**, strictly `B M×12 J` per employee (verified page by page) |
| Accounting year | 2026 · company "Rama Gipser AG" |
| Storage | Private disk only: `storage/app/private/smgv-imports/<sha256>.pdf` (not public, not in Git). Only Administrators can reach the import screen |

## 2. Extraction method

- **Positioned text.** `App\Support\Pdf\PdfTextExtractor` reads every text run with its x/y position, without OCR and without any external service. `App\Domain\Smgv\WorkbookParser` places each value in its **cell by position**:
  - day columns from the sheet's own "Tag" row;
  - the week totals' merged cells from the "Kalenderwoche" row;
  - months from the Jahresübersicht header;
  - the Basisblatt blocks by their labels.

  A blank cell can therefore never shift a value onto another day.
- **Exactness.** Every number is kept twice: the **original text as printed** and an exact fixed-point integer in **1/10,000 h**. The workbook prints the year saldo with 4 decimals (e.g. `56.3750`), so hundredths would not be exact.
- **Result.** 0 unplaced cells and 0 unclassified pages. Two layout quirks were recognised and documented:
  - a stray hidden month label at the right edge of some rows;
  - the "Unproduktive Std. Total" row is not printed in some months.

## 3. What was imported (per employee)

| Employee | First / last populated month | Daily records | Notes |
| --- | --- | ---: | --- |
| Avni Hoti | Jan – Aug | 178 | |
| Johan Manuel Batista de Mota | — (no hours recorded) | 0 | The PDF contains only the Basisblatt and empty months (annual −1,176.00 h = −Soll). Imported: profile, contract, Pensum, reported annual values |
| Durim Buduri | Jan – Sep | 203 | Exit 30.09.2026 |
| Besart Dibra | Jan – Aug | 183 | |
| Blerim Dullovi | Apr – Aug | 117 | |
| Zekri Elmazi | Mar – Aug | 136 | Pensum 70 % |
| Shipran Kryezi | Jan – Aug | 186 | |
| Flurim Kurtaj | Mar – Aug | 142 | |
| Egzon Tahiri | Jan – Aug | 179 | |
| Memet Tairi | Feb – Aug | 163 | |

- **Batch totals.**
  - Daily day-records: 1,461.
  - Week totals: 247.
  - Monthly values: 604, from the Jahresübersicht month columns.
  - Annual values: 142.
  - All values with provenance: **6,427**.
- **Derived platform records.**
  - 10 worker accounts.
  - 10 Basisblatt profiles (birth date only; everything else is blank in the PDF).
  - 10 contracts.
  - 10 Pensum periods.
  - 6 opening balances. The other 4 employees have no Vorjahr values in the PDF, so no row was created.
  - 194 unproductive-hour entries: vacation, illness and the other codes per day.
  - 9 public holidays in the default calendar: 1/2 Jan, 3/6 Apr, 14/25 May, 1 Aug, 25/26 Dec. They are identical on all 10 Basisblätter.
  - 0 manual corrections and 0 remarks: the PDF contains none.
- **Populated months.** A month counts as populated only when it has productive or unproductive hours, corrections or remarks. Sollstunden and holiday credits alone are template values. Blank future/after-exit months were **not** imported as accounting records.
- **The distinctions are preserved:**
  - *missing* (no cell, not imported);
  - *zero* (printed 0.00);
  - *public holiday* ("ft" marker + Gutschrift);
  - *vacation / absence* (by code);
  - *non-employment* (Pensum 0 %, outside the contract).

## 4. Architecture and provenance

- **New table `smgv_historical_values`** (forward-only migration `2026_11_27_130000`). Each row holds: batch → source SHA-256, employee, scope (basis/day/week/month/year), period, accounting date, metric, exact value (1/10,000 h), original text, **source page**, validation status and import time. A unique key on (batch, employee, scope, period, metric) makes the import **idempotent**.
- **Historical hours are accounting values, not attendance.**
  - No attendance sessions, events, timestamps, GPS points, worksites, orders or report texts were created. Live counts after the import: 0 / 0 / 0 / 0 / 0.
  - The SMGV engine uses the historical productive hours **only for dates without live attendance**. If both exist, live wins and a warning is shown, so nothing is double-counted.
  - Historical hours can never make anyone appear "currently at work".
  - Reported time supplements are used as reported, never recomputed by the unverified GAV rules.
- **Integration.**
  - SMGV Overview, Basisblatt, Monthly Control, Annual Overview, Absences, Balances, Closing and the Export Center all read the imported data through the engine.
  - The employee directory lists the 10 accounts.
  - The admin dashboard's live attendance figures still use live attendance only, by design.
- **Safety.**
  - One transaction for the batch, with a savepoint per employee: a conflict skips only that record or employee.
  - Existing data is never overwritten: differing records are reported as conflicts.
  - Re-importing the same PDF is refused: "already committed".

## 5. Import interface (SMGV Center → Importi historik)

- **Shows:**
  - the source checksum and page count;
  - the employee count and accounting year;
  - first and last populated month;
  - daily, weekly, monthly and annual record counts;
  - a progress indicator, the validation and reconciliation result, and the import history.
- **Per employee:** name order (editable), planned username, first/last month, access state, checks passed, calculated-vs-reported differences, fields missing in the PDF, and a details panel listing every discrepancy.
- **Workflow:** select employees → import → result (written counts, conflicts). The screen never shows a password.
- **Reusable** for future client PDFs.
- **CLI:** `php artisan rama:smgv-history <pdf> --actor=<admin> [--order=…] [--commit --credentials=<file outside the project>]`.

## 6. Safety steps performed

1. **DB identity** verified: `rama_workforce_laravel`. The command also refuses any other database name.
2. **Rehearsal 1, development.** On the empty test DB, the import ran cleanly and the engine totals matched the PDF.
3. **Rehearsal 2, live copy.** A live dump was restored into `rama_workforce_laravel_test`:
   - 49/49 tables with matching checksums and 32/32 triggers;
   - the migration and the import ran;
   - the engine check passed;
   - re-running the import was refused;
   - browser checks on `:3401` passed.

   The test DB was **wiped** afterwards.
4. **Pre-import backup.** `backups\onboarding-predeploy-20261127-084151` (owner + SYSTEM only) contains:
   - the live dump (sha256 `e1364b53…e129a`) and `verification.json`;
   - the changed files, the previous `public/build`, a git bundle and `GIT_HEAD`;
   - `SHA256SUMS` (58/58 OK).

   **Verified by a full restore** into the test DB: 49/49 tables, 0 mismatches, 32/32 triggers.
5. **Live import.** Migration (batch 5, ≈0.5 s), then the import (0 conflicts). Quality Workforce was not touched.

## 7. Known limitations

- Minute resolution: in 3 employee-months a printed supplement of 0.125 h (7.5 min) appears as 0.13 h on the platform screens (the platform stores whole minutes). The exact original values remain in `smgv_historical_values`.
- The GAV rules are still unverified, so platform screens remain labelled *draft*. Imported reported totals are stored separately and do not depend on those rules.
- The SMGV association logo is still not reproduced in exports (earlier owner decision pending).
