Skip to content

feat(pallets): finish changing location of pallet - #209

Merged
jakub-przepiora merged 5 commits into
developfrom
feature/101-pallet-status
Jul 28, 2026
Merged

feat(pallets): finish changing location of pallet#209
jakub-przepiora merged 5 commits into
developfrom
feature/101-pallet-status

Conversation

@JanKolo04

@JanKolo04 JanKolo04 commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a destination to pallets alongside the existing status and location, so logistics can see where each pallet
is and where it should go. Destination is cleared on arrival (arrived_at stamped), so transit state is a property
of the row rather than a string comparison in the UI. Destination changes ride the existing append-only
pallet_movements ledger (new from_destination / to_destination), giving one timeline for both "who moved it" and
"who redirected it".

New Pallet Logistics view (/logistics/pallets, Operator/Supervisor/Admin) lists pallets live with status,
location, destination, transit state and arrival — filterable by status and location/destination — plus a card to
re-route a pallet without moving it. The Move Pallet terminal gains an optional destination field.

Existing pallets are unaffected: both new columns are nullable and default to unset.

Type of change

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

Related issue

Closes #101

Testing

New tests/Feature/Web/Logistics/PalletDestinationTest.php — 18 cases: destination assign/keep/clear, arrival
stamping, stale-arrival clearing, re-route without an operator, validation 422 (length, shipped pallet, soft-deleted),
guest + wrong-role authorization, view render, shape allowlists, and a full pallet journey asserted across the whole
ledger.

  • Tested manually in browser
  • php artisan test passes — 1988 tests, 0 failures (run as php -d memory_limit=2G vendor/bin/phpunit; the
    artisan test wrapper OOMs locally at the default 128M memory_limit, unrelated to this change — the suite peaks at
    ~329MB)
  • Tested as Operator / Supervisor / Admin role — covered by feature tests (guest redirect, role-less 403, Operator
    write paths, Admin CRUD), not manually in a browser

Checklist

  • No .env secrets committed
  • Migration added if schema changed — pallets.destination + arrived_at, pallet_movements.from_destination +
    to_destination
  • $fillable updated if new model columns added — Pallet and PalletMovement
  • No raw SQL with user input (use Eloquent / Query Builder)
  • CSRF protection in place for any new forms — Inertia useForm over the standard web middleware
  • composer audit clean — 37 pre-existing advisories across 11 packages; no dependencies added or changed by this
    PR

Notes for reviewers

  • New columns were added to the pallets and pallet_movements Electric shapes — without that the UI never sees them
    (there's a test guarding it).
  • Admin pallet CRUD writes destination without a ledger entry, matching how it already treats location. Logged
    paths are the move terminal and the logistics view.
  • Clearing an already-empty destination still appends a ledger row; happy to suppress that if reviewers prefer a
    ?PalletMovement return.

Summary by CodeRabbit

  • New Features

    • Added a tablet-friendly Pallet Logistics view with status, location, destination, transit, and arrival details.
    • Added pallet re-routing, destination assignment or clearing, and destination-aware move workflows.
    • Added destination fields to pallet creation, editing, lists, and movement history.
    • Movement history now displays destination changes and arrivals.
  • Bug Fixes

    • Authentication, registration, PIN, password, and two-factor security messages are now translated in English and Polish.

@coderabbitai

coderabbitai Bot commented Jul 25, 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: 3f2844b8-f0ad-4845-973f-6f67a8979fac

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 pallet destination, transit, arrival, rerouting, and append-only movement history support across the backend, sync shapes, logistics UI, admin pallet forms, and feature tests. Authentication, registration, password, and 2FA messages now use English and Polish translations.

Changes

Pallet logistics tracking

Layer / File(s) Summary
Pallet state and sync contracts
backend/database/migrations/*, backend/app/Models/*, backend/app/Enums/PalletStatus.php, backend/app/Sync/*, backend/database/factories/*
Adds nullable destination and arrival fields, movement destination fields, model relationships/helpers, enum option helpers, factory states, and sync columns.
Destination validation and movement service
backend/app/Http/Requests/*, backend/app/Services/Logistics/PalletMovementService.php
Adds shared logistics validation, destination request accessors, atomic destination-aware movement handling, arrival transitions, rerouting, and ledger append logic.
Logistics endpoints and interfaces
backend/app/Http/Controllers/Web/Logistics/*, backend/routes/web.php, backend/resources/js/Pages/logistics/*, backend/resources/js/Pages/admin/*, backend/resources/js/layouts/adminNav.js
Adds logistics overview and reroute endpoints, destination controls to move and admin screens, movement-history display, and navigation.
Destination behavior coverage
backend/tests/Feature/Web/Logistics/PalletDestinationTest.php, CHANGELOG.md
Tests destination transitions, reroutes, authorization, validation, sync exposure, admin updates, and full movement history; documents the feature.

Localized authentication messages

Layer / File(s) Summary
Authentication and validation localization
backend/app/Http/Controllers/Web/*Auth*, backend/app/Http/Controllers/Web/RegisterController.php, backend/app/Http/Requests/RegisterRequest.php, backend/app/Services/Auth/AuthService.php
Replaces hardcoded authentication, registration, password, PIN, and 2FA messages with translation calls while preserving control flow.
English and Polish translation dictionaries
backend/lang/en.json, backend/lang/pl.json
Adds translated logistics and authentication message keys in both locales.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant LogisticsPallets
  participant PalletMovementController
  participant PalletMovementService
  participant PalletMovementLedger
  Operator->>LogisticsPallets: select pallet and destination
  LogisticsPallets->>PalletMovementController: submit reroute
  PalletMovementController->>PalletMovementService: assign destination
  PalletMovementService->>PalletMovementLedger: append movement history
  PalletMovementService-->>LogisticsPallets: return updated logistics view
Loading

Possibly related PRs

  • Mes-Open/OpenMes#70: Introduced the pallet status enum helpers and controller status props extended here.
  • Mes-Open/OpenMes#197: Shares the pallet movement controller, request, service, and ledger paths.
  • Mes-Open/OpenMes#208: Established related pallet movement handling extended here with destination and arrival semantics.

Suggested reviewers: jakub-przepiora

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Auth/registration localization changes are unrelated to pallet management and appear outside the linked issue scope. Split the auth/registration i18n updates into a separate PR or clearly justify them as part of this change.
Docstring Coverage ⚠️ Warning Docstring coverage is 45.21% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and still describes the pallet movement/location work, though it’s broader than the full feature set.
Linked Issues check ✅ Passed The PR adds pallet status, location, destination, movement history, a logistics view, and tests matching issue #101.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/101-pallet-status

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.

Auth error and status messages were hardcoded English literals rather than
translation calls, so they stayed English on a Polish UI no matter what
lang/pl.json contained — there was no key for them to match.

Wraps all 29 user-facing strings in AuthController, AuthService,
TwoFactorController, TwoFactorChallengeController, RegisterController and
RegisterRequest in __(), and adds the 24 resulting keys to lang/en.json and
lang/pl.json (parity kept). The login screen resolves the locale because
SetLocale runs in the web middleware group, so guest requests are covered.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YbLa6GeJZACX3tFCE7iNJq
@JanKolo04

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 25, 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/tests/Feature/Web/Logistics/PalletDestinationTest.php (1)

347-360: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert no ledger entry is created by the admin edit path.

The PR objective explicitly states admin pallet CRUD updates destinations "without creating ledger entries," but this test only checks the destination value — add an assertDatabaseCount('pallet_movements', 0) to actually verify the documented behavior and guard against a future regression that silently starts logging admin edits.

As per path instructions, "Tests are mandatory for new endpoints/business logic: happy path, validation 422, authorization (guest + wrong role), domain edge cases."

✅ Proposed test addition
         ])->assertRedirect(route('admin.pallets.index'));

         $this->assertSame('DOCK-04', $pallet->fresh()->destination);
+        $this->assertDatabaseCount('pallet_movements', 0);
     }
🤖 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/tests/Feature/Web/Logistics/PalletDestinationTest.php` around lines
347 - 360, Update test_admin_can_edit_a_pallet_destination_directly to assert
the pallet_movements table contains zero records after the admin update, while
preserving the existing destination assertion and redirect checks.

Source: Path instructions

🤖 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/AuthController.php`:
- Around line 80-84: Make the 2FA attempt-limit message translatable by updating
the rate-limit branch in
backend/app/Http/Controllers/Web/TwoFactorChallengeController.php:51-54 to use
the translation key with a :seconds placeholder and pass the remaining seconds
for interpolation; add the corresponding entries to
backend/lang/en.json:4910-4933 and backend/lang/pl.json:4910-4933. The
AuthController locations at
backend/app/Http/Controllers/Web/AuthController.php:80-84 and :129-132, and the
secondary TwoFactorChallengeController location at :114-117, require no direct
changes.

In `@backend/app/Http/Requests/Concerns/ValidatesPalletLogistics.php`:
- Around line 40-47: Add the missing “Select an active logistics operator.” key
to the Polish translation catalog, matching the corresponding entry in en.json
and the message referenced by palletLogisticsMessages(). Preserve the existing
Polish translation format and do not alter the validation message definition.

In
`@backend/database/migrations/2026_07_25_100001_add_destination_to_pallet_movements_table.php`:
- Around line 14-16: The destination-transition documentation incorrectly treats
to_destination = null as sufficient evidence of arrival. Update the ledger
interpretation comment in
backend/database/migrations/2026_07_25_100001_add_destination_to_pallet_movements_table.php:14-16
to require to_location matching from_destination or an explicit event marker;
clarify in backend/resources/js/Pages/admin/pallet-movements/Index.jsx:40-42
that target clearing and arrival share this transition; and qualify the arrivals
statement in CHANGELOG.md:11 accordingly.

---

Nitpick comments:
In `@backend/tests/Feature/Web/Logistics/PalletDestinationTest.php`:
- Around line 347-360: Update test_admin_can_edit_a_pallet_destination_directly
to assert the pallet_movements table contains zero records after the admin
update, while preserving the existing destination assertion and redirect checks.
🪄 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: aee8791a-e093-4f66-8bad-ff934b42982f

📥 Commits

Reviewing files that changed from the base of the PR and between c8e30ee and 72be37d.

📒 Files selected for processing (35)
  • CHANGELOG.md
  • backend/app/Enums/PalletStatus.php
  • backend/app/Http/Controllers/Web/Admin/PalletController.php
  • backend/app/Http/Controllers/Web/AuthController.php
  • backend/app/Http/Controllers/Web/Logistics/PalletMovementController.php
  • backend/app/Http/Controllers/Web/RegisterController.php
  • backend/app/Http/Controllers/Web/TwoFactorChallengeController.php
  • backend/app/Http/Controllers/Web/TwoFactorController.php
  • backend/app/Http/Requests/AssignPalletDestinationRequest.php
  • backend/app/Http/Requests/Concerns/ValidatesPalletLogistics.php
  • backend/app/Http/Requests/PalletRequest.php
  • backend/app/Http/Requests/RegisterRequest.php
  • backend/app/Http/Requests/StorePalletMovementRequest.php
  • backend/app/Models/Pallet.php
  • backend/app/Models/PalletMovement.php
  • backend/app/Services/Auth/AuthService.php
  • backend/app/Services/Logistics/PalletMovementService.php
  • backend/app/Sync/ShapeRegistry.php
  • backend/app/Sync/Shapes/PalletMovementsRecentShape.php
  • backend/database/factories/PalletFactory.php
  • backend/database/factories/PalletMovementFactory.php
  • backend/database/migrations/2026_07_25_100000_add_destination_to_pallets_table.php
  • backend/database/migrations/2026_07_25_100001_add_destination_to_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/pallets/Create.jsx
  • backend/resources/js/Pages/admin/pallets/Edit.jsx
  • backend/resources/js/Pages/admin/pallets/Index.jsx
  • backend/resources/js/Pages/admin/pallets/PalletForm.jsx
  • backend/resources/js/Pages/logistics/MovePallet.jsx
  • backend/resources/js/Pages/logistics/Pallets.jsx
  • backend/resources/js/layouts/adminNav.js
  • backend/routes/web.php
  • backend/tests/Feature/Web/Logistics/PalletDestinationTest.php

Comment thread backend/app/Http/Controllers/Web/AuthController.php
Comment thread backend/app/Http/Requests/Concerns/ValidatesPalletLogistics.php
JanKolo04 and others added 2 commits July 25, 2026 22:30
The "Set destination" card sat outside ResourceTable's own max-w-7xl wrapper,
so it ran edge-to-edge while the table stayed inset. Adds an opt-in `fullWidth`
prop to ResourceTable and uses it here, so both share one left/right edge;
every other list keeps the 7xl cap.

The card's text inputs also used the global .form-input (min-h-[48px]) next to
Dropdown triggers (~39px), leaving the four-field row ragged. They now match
the Dropdown metrics.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YbLa6GeJZACX3tFCE7iNJq
- 2FA challenge rate-limit message was a hardcoded interpolated string, so it
  stayed English on a Polish UI. Now goes through __() with a :seconds
  placeholder; key added to lang/en.json and lang/pl.json.
- Corrected the claim, repeated in the migration docblock, the movements list
  and CHANGELOG, that an emptied to_destination marks an arrival. Clearing a
  destination produces the identical ledger shape; only a move landing on the
  pending destination is an arrival, and pallets.arrived_at is authoritative.
- The admin-CRUD test now asserts no ledger row is written, so the deliberate
  "admin edits are unlogged" behaviour can't regress silently.

Not applied: CodeRabbit flagged "Select an active logistics operator." as
missing from lang/pl.json. It is present ("Wybierz aktywnego operatora
logistyki.") and en/pl parity verified clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YbLa6GeJZACX3tFCE7iNJq
@JanKolo04

Copy link
Copy Markdown
Collaborator Author

@jakub-przepiora ready to review

@jakub-przepiora

Copy link
Copy Markdown
Contributor

@JanKolo04 conficts

# Conflicts:
#	CHANGELOG.md
#	backend/lang/en.json
#	backend/lang/pl.json
@jakub-przepiora
jakub-przepiora merged commit 9412683 into develop Jul 28, 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