Skip to content

bug: outbound autopick skips expired lots - #9

Open
devin-ai-integration[bot] wants to merge 2 commits into
developfrom
devin/task-39-autopick-skip-expired-lots
Open

devin-ai-integration[bot] wants to merge 2 commits into
developfrom
devin/task-39-autopick-skip-expired-lots

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

✨ Description of Change

Link to GitHub issue or Jira ticket: Reported in the #matthew-bots browser walkthrough (Bug 1).

Description:

Outbound autopick suggested and shipped expired lots. Repro on demo data: Lamivudine 150mg, qty 5 from Main Warehouse picked lot 4041283 (expired 30/Nov/2025) even though lot WALK50117 (expires 2030) was in stock. StockMovementService.getAvailableItems had no expiry check, and FEFO sorting put the expired lot first.

  • AvailableItem.isExpired(): true when the lot's expiration date is today or earlier, matching InventoryItem.expirationStatus. Lots with no expiry date are not expired.
  • getAvailableItems: expired lots sort after unexpired ones. They stay in the list, so a user can still pick one by hand on the Pick page.
  • getSuggestedItems(availableItems, quantity, skipExpired): only the autopick callers (createPicklist and the Pick page suggestions in buildPickPageItem) pass skipExpired = true. Autopick never suggests an expired lot, and it never tops up short unexpired stock from an expired lot.
  • CSV pick import keeps the two-argument getSuggestedItems, which doesn't skip expired lots. A row that names an expired lot with a blank bin still gets picked from the lot's bin, as it did before this PR.

Tests: new StockMovementServiceAutopickSpec, 5 cases:

  • an expired lot is skipped when an unexpired lot is in stock
  • no top-up from an expired lot
  • nothing is suggested when only expired stock is left
  • a lot expiring today is skipped, while tomorrow and no-expiry lots are picked in FEFO order
  • a CSV pick import row naming an expired lot with a blank bin is still picked

Results:

  • inventory.*, fulfillment.* and picklist.* unit tests: 84 tests, 0 failures.
  • On the first commit, the 3 original expiry cases failed with the service change reverted.
  • Run locally on JDK 8 with -x npmInstall -x npm_run_bundle.

Out of scope: replenishment autopick uses its own PicklistService.getSuggestedItems, which is being fixed in a separate PR.

CI note: frontend-tests.yml and build.gradle on develop still pin Node 14 / npm 6, which has broken npm ci on other PRs. This PR touches no frontend code.


Devin-Org: engineering


Product Engineer opened this PR for Matthew
Implemented in session Fix worst openboxes bug with coverage
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Custom reviewers

  • 🧪 Test 2 reviewer: no findings · View
  • 🚩 TD Enterprise Architecture: no findings · View
  • 👁️ TD Information Security: no findings · View
  • 🧠 TD French Language (Bill 96): no findings · View
  • ⏱️ TD API Contracts: no findings · View

Devin Review


Boolean isExpired() {
Date expirationDate = inventoryItem?.expirationDate
return expirationDate ? expirationDate.before(new Date().clearTime() + 1) : false

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🔍 Expiration-day policy differs from description

For lots expiring today, isExpired() excludes them from autopick, while the PR description promises eligibility. The updated test explicitly enforces exclusion. This matches getExpirationStatus, but leaves the stated expiration-day policy inconsistent.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants