Commit Graph

4 Commits

Author SHA1 Message Date
grabowski bbc4b1e763 fix: Robust barcode scan handling for ANSI MH10.8.2 and InvenTree 1.x
- Capture scanner control keystrokes (Ctrl+]/^/\/_ → GS/RS/FS/US) in the
  scan input so ANSI MH10.8.2 field separators survive the HTML input
  filter, eliminating the Q-quantity-vs-next-DI ambiguity.
- Fall back to a DI-aware lazy regex when separators are stripped
  (e.g. pasted scans), so Q digits stop at the next data identifier
  instead of greedily eating into 11Z/12Z/etc.
- Make pending-part dicts JSON-serializable by isoformat-ing the
  timestamp; without this the worker's import_complete socket emit
  threw and the entry was never removed from the queue, causing
  every re-scan to 400 with "already queued" forever.
- Make /api/part/import idempotent: a re-scan of an already-queued
  part updates qty/location and returns 200 with already_queued=true
  instead of 400.
- Surface search/queue errors in the client log instead of silently
  swallowing them, and stop treating a 500 from /api/part/search as
  "not found" (which was causing re-queue loops).
- Log full tracebacks for /api/part/search failures and split the
  get_part_info / get_part_parameters error paths so failures can be
  attributed.
- Migrate get_part_parameters to the InvenTree 1.x endpoint
  /api/parameter/?model_type=part.part&model_id=<id>. The old
  /api/part/parameter/?part=<id> returns 404 on this instance, and
  even on the new endpoint the ?part= filter is silently ignored
  (would have returned every parameter in the database).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 14:25:35 +07:00
grabowski 8dadd66f45 fix: Add support for ANSI MH10.8.2 barcode format
Fixes barcode parsing for ANSI MH10.8.2 format barcodes that don't use GS/RS separators.

Problem:
- Barcodes like [)>06PSAM9019-ND1PJL-100-25-T... were not being parsed
- Only separator-based and JSON formats were supported
- User's real-world barcodes were being added to queue as raw strings

Solution:
- Added ANSI MH10.8.2 format detection ([)>06 prefix)
- Extract part code between P and first field marker (1P, 30P)
- Extract quantity from Q<digits> pattern
- Updated both desktop and web app parsing logic

Tested with real barcode:
- Input: [)>06PSAM9019-ND1PJL-100-25-T30PSAM9019-NDK1...Q1811...
- Parsed: Part=SAM9019-ND, Qty=1811 

Files Changed:
- src/stocktool/stock_tool_gui_v2.py - Enhanced parse_scan()
- src/stocktool/web/static/js/app.js - Enhanced parseBarcode()
- test_barcode_parsing.py - Test script for validation
- test_barcode_analyze.py - Barcode structure analysis tool
- QUICKSTART_WEB.md - Quick start guide for web app

Supported Formats Now:
1. JSON-like: {PM:PART-CODE,QTY:10}
2. Separator-based: GS/RS (\x1D, \x1E) separated fields
3. ANSI MH10.8.2: [)>06P<part>...Q<qty>... (NEW!)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 11:29:20 +07:00
grabowski 0fdc319774 feat: Add async background part import queue
Implements non-blocking part import to prevent UI freezing when scanning unknown parts.

Features:
- Background import worker thread processes unknown parts
- New "Pending Imports" UI section shows import progress
- User can continue scanning other parts while imports run
- Automatic retry on failure (up to 3 attempts)
- Parts automatically processed when import completes

Changes:
- Added PendingPart and ImportResult data structures
- Added PartImportWorker background thread class
- Replaced blocking find_or_import_part() with async find_part()
- Added pending parts queue UI with status display
- Added _on_import_complete() callback handler
- Added _update_pending_parts_ui() for real-time updates
- Added proper cleanup on window close

Benefits:
- No more 30+ second UI freezes during part imports
- Can scan multiple unknown parts in quick succession
- Visual feedback showing import status for each part
- Automatic error handling and retry logic

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 11:07:50 +07:00
grabowski 9c742af585 refactor: Convert to UV Python project with proper package structure
- Restructured project to use src/stocktool package layout
- Migrated to UV for dependency management
- Added pyproject.toml with all dependencies (sv-ttk, pillow, requests, pyyaml)
- Organized test files into tests/ directory
- Updated .gitignore for UV projects
- Comprehensive README with installation and usage instructions
- Removed old unused files (main.py, stock_tool_gui.py, duplicate copy)
- Added CLI entry point: stock-tool command

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 10:52:10 +07:00