# RAMA AG - GPS-to-report integration test report

Prepared 30 November 2026. All write tests used rama_workforce_laravel_test / rama_test@127.0.0.1, isolated from the operational rama_workforce_laravel database. Fixture transactions rolled back. No real employee attendance was created.

## Execution path

1. Worker dashboard uses `App\Livewire\WorkerAttendance::record` (or `recordManual` for the separately documented manual workflow). Requests use the existing Livewire update route, authentication, CSRF, rate limiting and fresh worker authorization.
2. `WorksiteSelection` snapshots the authorized selected site; `WorksiteScanning` retains scan context. `TravelWorkflow::evidence` verifies current worksite boundaries for automatic StartWork/ReturnDeparture in the six-step workflow. The entire accuracy circle must fit within the site radius. The existing worksite maximum accuracy is 50 m and maximum fix age is 60 seconds; future timestamps have the existing 5-second tolerance. No office geofence is configured, so office departure/arrival fixes are not represented as verified office proximity.
3. `AttendanceService::persist` / `recordInTransaction` locks the worker, validates state and fix, enforces idempotency and writes immutable attendance_events plus attendance_locations and attendance_sessions. Production event time is server time; the device timestamp is GPS evidence only. A site is frozen in first-event metadata.
4. `DurationEngine::compute` / `intervals` reconstruct WORK, BREAK, outward/return TRAVEL and legacy intervals. `TimeService::summaryFor` feeds worker history and the administrator view. `computeMonth` converts factual intervals into the existing `TimeEngine::month` projection, merging absences, corrections and confirmed historical inputs with source provenance.
5. `TimeService::month` serves immutable snapshots for closed months; otherwise it computes live. `year` sums those same monthly results, including calendar-week boundary reconciliation and Europe/Zurich local dates. UTC event timestamps are partitioned at local calendar boundaries; no second duration or pay engine was added.
6. `SmgvExportService::sheet` obtains the canonical year. Both PDF layouts and Excel consume that sheet. The added ClientReportData supplies presence/pensum display metadata only, not credited hours. No manual synchronization, queue job or import is needed for newly completed attendance in open months.

## Verified defects and narrow fixes

The regression test first reproduced stale same-request monthly data: a projection read before attendance remained at zero after the shift. AttendanceService now invalidates the already-resolved scoped TimeService after a successful new write. Idempotent replays create no records or hours.

A current-day unfinished shift was labelled recorded despite its open interval. TimeService now marks every open factual session incomplete in accounting output. Running interval end times remain null and no finalized duration is invented. These fixes change no GAV formula, GPS threshold, role, schema or historical value.

## Actual isolated results

Final regression: 98 tests, 518 assertions, no failures/errors/skips. Coverage includes 8 new GPS-to-report integration tests, client template/leap-year checks and existing attendance, history, worksites, TimeService, historical-import, export authorization and accounting-domain tests. Pint and Blade rendering passed. Detailed JUnit: evidence/final-regression.xml.

| Scenario | Observed result |
|---|---|
| Standard day | Work 07:00-15:30 Zurich, explicit break 11:00-11:30: 510-minute work span, 30-minute unpaid break, 480 productive minutes, 480 scheduled minutes, daily variance 0. Six raw workflow events retained. Travel 06:45-07:00 and 15:30-15:45 remains separate, uncredited under existing unverified travel-pay policy. |
| Positive variance | 07:00-16:00 with 30-minute break gives 510 productive, +30 minutes versus schedule, no automatic payable supplement. |
| Negative variance | 07:00-15:00 with 30-minute break gives 450 productive, -30 minutes. |
| Incomplete | Start without finish is flagged incomplete; running work is not fabricated as finalized hours. |
| GPS | Valid in-site fix accepted; missing, malformed, 5000 m accuracy, out-of-site and stale fixes rejected without saving failed events. |
| Duplicate submissions | Same-key start and finish replays retain exactly six events; no duplicate hours. Different-key invalid transitions remain covered by existing attendance tests. |
| Historical/live overlap | Imported 7 h and completed live 8 h on the same date produce 8 h, not 15 h; historical_and_live_overlap warning retained. Imported cells remain unchanged. |
| Outside employment | Actual work outside a closed contract date range is retained with zero scheduled hours and work_outside_contract warning. Current Avni data differs because its active contract is open, with 0% effective pensum after August. |
| Month/year/week | Multiple days across December/January and February/March reconcile: 480 productive minutes in prior year, 1440 in current year, cross-year week 960. Existing timezone/domain tests cover local splits. |
| Closed month | New raw attendance does not change the immutable closed accounting snapshot. Canonical live computation sees 480 minutes while snapshot stays 0; checksum remains intact. Existing administrator reopening workflow, with its usual cache invalidation, makes the 480 minutes reportable. |

Standard before/after comparison: monthly productive 0 -> 480 minutes, annual productive 0 -> 480, delta +8.00 h. Worker history displayed 8h 00m; administrator attendance view uses the same summary. Monthly and annual PDFs contain the corresponding canonical values; Excel overview, monthly and daily cells contain 8.00 h. The approved SMGV layout does not add separate gross/break columns; gross and break are verified in raw durations/history, with their net result exported. Synthetic before/after PDFs and evidence/standard-day-delta.json are retained.

## Approval and provenance

Open accounting periods reflect completed factual attendance immediately. No additional attendance-approval step was found in this execution path. The export's closed-source option still requires the relevant monthly closing records; closed months retain their frozen snapshots until the existing authorized reopen/correction/reclose workflow is used. Historical hours apply only when live evidence does not supersede them; sources and overlap warnings are retained. This audit does not reinterpret imported annual values as GPS events.

## Physical-device acceptance

DEFERRED BY OWNER UNTIL HOSTING. Simulated coordinate tests are not physical GPS acceptance. No HTTPS deployment address was supplied, and localhost on the computer is not the phone's application address. No tunnel, hosting or network exposure was created.

After hosting, use the authorized HTTPS RAMA address and an owner-authorized test employee with a valid contract/site. On the actual smartphone: allow location, check reported accuracy, select the assigned site, perform the approved six-step day including break, verify persisted events and immediate open-period report values, then download/inspect PDF and Excel. Record device/browser, timestamp, accuracy and report identifiers without exposing coordinates or credentials in public logs. Do not create records for a real employee without specific authorization.

Unverified GAV travel payment, deductions, night/Sunday/maximum-work supplements, vacation proration, previous-year compensation deadlines, RPBK obligations and Karenz settlement remain unverified. Draft warnings are preserved.
