Skip to content

feat: Identification of logistics operators / forklift drivers on phy…#197

Merged
jakub-przepiora merged 3 commits into
developfrom
feature/103-identification-of-logistics-operators
Jul 22, 2026
Merged

feat: Identification of logistics operators / forklift drivers on phy…#197
jakub-przepiora merged 3 commits into
developfrom
feature/103-identification-of-logistics-operators

Conversation

@JanKolo04

@JanKolo04 JanKolo04 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds attribution of physical pallet movements to the logistics operator / forklift
driver who performed them (#103).

Introduces a lightweight shop-floor Move Pallet terminal where an operator
identifies themselves (badge-style tap picker), selects a pallet, enters its new
location and confirms — recording an immutable, attributable movement. An admin
Pallet Movements history surfaces who moved which pallet, from where, to where
and when.

Key changes:

  • New is_logistics flag on Worker (+ logistics() scope) marking operators
    eligible to move pallets; toggle added to the worker form.
  • New append-only pallet_movements ledger (worker_id = who performed the move,
    performed_by = terminal account that recorded it, from_locationto_location,
    moved_at, notes).
  • PalletMovementService atomically snapshots the pallet's current location as the
    move origin, updates the pallet, and appends the movement row under a
    lockForUpdate() transaction (safe under concurrent moves of the same pallet).
  • Validation via StorePalletMovementRequest — only active logistics workers and
    live, non-shipped, non-deleted pallets are accepted (stale ids → 422, not 404).
  • Live history via the pallet_movements Electric shape (registered in
    ShapeRegistry + CollectionBroadcaster); is_logistics added to the workers
    shape.
  • Routes gated by role:Operator|Supervisor|Admin; nav + TabRegistry updated;
    full en/pl i18n parity.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • Other:

Related issue

Closes #103

Testing

Feature test suite tests/Feature/Web/Logistics/PalletMovementTest.php (9 tests,
48 assertions) — covers movement attribution + from→to capture, pallet location
follow-through, to_location required (422), operator must be active & logistics,
shipped pallets rejected, soft-deleted operator/pallet rejected with 422 (not 404),
guest blocked, role-gating on the terminal, terminal lists only eligible operators,
and admin history renders.

  • Tested manually in browser
  • php artisan test passes
  • Tested as Operator / Supervisor / Admin role (if UI change)

Checklist

  • No .env secrets committed
  • Migration added if schema changed
  • $fillable updated if new model columns added
  • No raw SQL with user input (use Eloquent / Query Builder)
  • CSRF protection in place for any new forms
  • composer audit clean

Summary by CodeRabbit

  • New Features
    • Added a Move Pallet terminal for recording pallet relocations, destinations, and notes.
    • Added an admin pallet movement history view.
    • Added logistics operator designation when creating or editing workers.
    • Restricted pallet moves to active logistics operators and movable pallets.
    • Pallet locations and movement history are updated and synchronized automatically.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 551ae8e9-b423-44a9-b00d-ae5e683415b4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds logistics-operator identification to workers and introduces a pallet movement workflow. Operators can move eligible pallets through a terminal, movements are transactionally recorded with attribution and history, and admins can view movement records.

Changes

Pallet movement workflow

Layer / File(s) Summary
Logistics operator capability
backend/app/Http/Controllers/Web/Admin/WorkerController.php, backend/app/Http/Requests/*WorkerRequest.php, backend/app/Models/Worker.php, backend/database/migrations/*, backend/resources/js/Pages/admin/workers/*, backend/app/Sync/ShapeRegistry.php
Adds the is_logistics worker field, validation, casting, query scope, admin form support, migration, factory state, and sync exposure.
Movement domain and validation
backend/database/migrations/2026_07_19_100001_create_pallet_movements_table.php, backend/app/Models/PalletMovement.php, backend/app/Services/Logistics/PalletMovementService.php, backend/app/Http/Requests/StorePalletMovementRequest.php, backend/database/factories/PalletMovementFactory.php
Adds movement persistence, relationships, validation for active logistics workers and non-shipped pallets, and transactional pallet location updates with movement history.
Terminal routes and operator workflow
backend/app/Http/Controllers/Web/Logistics/PalletMovementController.php, backend/routes/web.php, backend/resources/js/Pages/logistics/MovePallet.jsx, backend/resources/js/layouts/adminNav.js, backend/lang/*.json
Adds terminal and submission routes, operator and pallet selection, destination and notes entry, navigation links, and translations.
Movement history and coverage
backend/app/Sync/CollectionBroadcaster.php, backend/app/Sync/ShapeRegistry.php, backend/resources/js/Pages/admin/pallet-movements/Index.jsx, backend/tests/Feature/Web/Logistics/PalletMovementTest.php
Adds movement collection syncing, admin history rendering with lookup labels, and feature tests for recording, validation, access control, filtering, and history access.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant MovePallet
  participant PalletMovementController
  participant PalletMovementService
  participant PalletMovement
  Operator->>MovePallet: Select operator, pallet, and destination
  MovePallet->>PalletMovementController: Submit movement
  PalletMovementController->>PalletMovementService: Record movement
  PalletMovementService->>PalletMovement: Persist attribution and locations
  PalletMovementService-->>MovePallet: Redirect with success message
Loading

Possibly related PRs

  • Mes-Open/OpenMes#68: Overlaps the worker create/update request and controller methods modified here.
  • Mes-Open/OpenMes#70: Provides the pallet and pallet-status domain used by movement validation and updates.

Suggested reviewers: svannte, jakub-przepiora

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is specific and aligned with the main change: identifying logistics operators for physical pallet movements.
Linked Issues check ✅ Passed The PR satisfies #103 by recording the operator on movements, showing it in history, keeping terminal selection quick, and adding attribution tests.
Out of Scope Changes check ✅ Passed The changes stay focused on pallet-movement attribution, supporting history, validation, routing, and UI work without obvious unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/103-identification-of-logistics-operators

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JanKolo04

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
backend/app/Http/Requests/StorePalletMovementRequest.php (1)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Missing AGPL-3.0 license header.

As per coding guidelines, files in backend/app/**/*.php should keep license headers consistent with AGPL-3.0. Please add the standard license header to this new file.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/Http/Requests/StorePalletMovementRequest.php` at line 1, Add the
repository’s standard AGPL-3.0 license header at the top of
StorePalletMovementRequest.php, before the PHP opening tag, matching the
formatting used by other files under backend/app.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/app/Http/Controllers/Web/Logistics/PalletMovementController.php`:
- Around line 53-67: Replace the unbounded operatorNames and palletNumbers
preload in the Inertia render flow with server-side pagination for pallet
movement history, or dynamic paginated lookup loading for operator and pallet
labels. Ensure the initial props do not query every distinct ID referenced by
PalletMovement, while preserving label resolution for displayed rows.

In `@backend/resources/js/Pages/admin/pallet-movements/Index.jsx`:
- Line 12: The Index component currently depends on unbounded operatorNames and
palletNumbers Inertia lookup maps; replace this full-history payload approach
with bounded or local label resolution. Prefer resolving labels from locally
synced pallets and workers data, or constrain movement and lookup data to a
defined recent window, while preserving ID fallbacks for unavailable or
soft-deleted records.

In `@backend/resources/js/Pages/logistics/MovePallet.jsx`:
- Around line 103-110: Replace outline-none with outline-hidden in the className
strings for both the to_location input and the related textarea in
MovePallet.jsx, covering the anchor site at
backend/resources/js/Pages/logistics/MovePallet.jsx lines 103-110 and sibling
site at lines 117-123. Leave the existing custom focus:ring styling unchanged.

---

Nitpick comments:
In `@backend/app/Http/Requests/StorePalletMovementRequest.php`:
- Line 1: Add the repository’s standard AGPL-3.0 license header at the top of
StorePalletMovementRequest.php, before the PHP opening tag, matching the
formatting used by other files under backend/app.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f6b56197-e741-4f79-ab1f-d506f61775bc

📥 Commits

Reviewing files that changed from the base of the PR and between 8ec1ffa and 6545a25.

📒 Files selected for processing (25)
  • backend/app/Http/Controllers/Web/Admin/WorkerController.php
  • backend/app/Http/Controllers/Web/Logistics/PalletMovementController.php
  • backend/app/Http/Requests/StorePalletMovementRequest.php
  • backend/app/Http/Requests/StoreWorkerRequest.php
  • backend/app/Http/Requests/UpdateWorkerRequest.php
  • backend/app/Models/PalletMovement.php
  • backend/app/Models/Worker.php
  • backend/app/Services/Logistics/PalletMovementService.php
  • backend/app/Support/TabRegistry.php
  • backend/app/Sync/CollectionBroadcaster.php
  • backend/app/Sync/ShapeRegistry.php
  • backend/database/factories/PalletMovementFactory.php
  • backend/database/factories/WorkerFactory.php
  • backend/database/migrations/2026_07_19_100000_add_is_logistics_to_workers_table.php
  • backend/database/migrations/2026_07_19_100001_create_pallet_movements_table.php
  • backend/lang/en.json
  • backend/lang/pl.json
  • backend/resources/js/Pages/admin/pallet-movements/Index.jsx
  • backend/resources/js/Pages/admin/workers/Create.jsx
  • backend/resources/js/Pages/admin/workers/Edit.jsx
  • backend/resources/js/Pages/admin/workers/WorkerForm.jsx
  • backend/resources/js/Pages/logistics/MovePallet.jsx
  • backend/resources/js/layouts/adminNav.js
  • backend/routes/web.php
  • backend/tests/Feature/Web/Logistics/PalletMovementTest.php

Comment thread backend/resources/js/Pages/admin/pallet-movements/Index.jsx
Comment thread backend/resources/js/Pages/logistics/MovePallet.jsx
@JanKolo04

Copy link
Copy Markdown
Collaborator Author

@jakub.przepiora ready to review

@jakub-przepiora
jakub-przepiora merged commit 1498faa into develop Jul 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants