printedparts: QR label with gage tag + revision; record taken rev
Label switches from CODE128 to a QR encoding 'TAG|rev' (gage lab tag + latest print-file revision), so a physical part carries which revision it was printed from - short payload stays low-version + reliable at 0.5in (margin quiet zone, EC M, no logo). Item exposes latestrevision; kiosk strips the |rev to resolve and records the scanned revision on the take (migration 0004 adds printeditemtransactions.revision) for traceability of which rev was consumed. Manual entry records a null revision.
This commit is contained in:
@@ -266,7 +266,8 @@ from ..models import PrintedItemTransaction
|
||||
from ..services.badges import BadgeError, resolve_badge
|
||||
|
||||
|
||||
def _ledger_write(item, transactiontype, quantitychange, sso, name, reason=None):
|
||||
def _ledger_write(item, transactiontype, quantitychange, sso, name, reason=None,
|
||||
revision=None):
|
||||
"""Append a ledger row and move the cached quantity in ONE commit.
|
||||
|
||||
The single-commit invariant is what keeps quantityonhand equal to the
|
||||
@@ -284,6 +285,7 @@ def _ledger_write(item, transactiontype, quantitychange, sso, name, reason=None)
|
||||
employeesso=sso,
|
||||
employeename=name,
|
||||
reason=reason,
|
||||
revision=revision,
|
||||
))
|
||||
db.session.commit()
|
||||
if (quantitychange < 0
|
||||
@@ -413,8 +415,10 @@ def _kiosk_find_item(itemcode):
|
||||
"""Resolve a scanned or typed code to an active item.
|
||||
|
||||
Accepts the full code (WJRP0042) or bare digits from the touch keypad
|
||||
(42 -> prefix + zero-pad), so manual entry never needs letters."""
|
||||
scanned = (itemcode or '').strip().upper()
|
||||
(42 -> prefix + zero-pad), so manual entry never needs letters. A label QR
|
||||
carries 'TAG|rev'; the revision is stripped here (it identifies the physical
|
||||
part's file rev, not a different item)."""
|
||||
scanned = (itemcode or '').split('|', 1)[0].strip().upper()
|
||||
item = PrintedItem.query.filter(
|
||||
or_(PrintedItem.itemcode == scanned,
|
||||
PrintedItem.gagelabtag == scanned),
|
||||
@@ -472,7 +476,19 @@ def kiosk_take():
|
||||
return error_response(ErrorCodes.VALIDATION_ERROR, str(badge_error),
|
||||
http_code=422)
|
||||
|
||||
_ledger_write(item, 'take', -quantity, sso, name)
|
||||
# Print-file revision the scanned part carried: explicit field, else the
|
||||
# 'TAG|rev' tail of the scanned code. Recorded for traceability.
|
||||
revision = data.get('revision')
|
||||
if revision is None and '|' in (data.get('itemcode') or ''):
|
||||
tail = data['itemcode'].split('|', 1)[1].strip()
|
||||
revision = tail if tail.isdigit() else None
|
||||
if revision is not None:
|
||||
try:
|
||||
revision = int(revision)
|
||||
except (ValueError, TypeError):
|
||||
revision = None
|
||||
|
||||
_ledger_write(item, 'take', -quantity, sso, name, revision=revision)
|
||||
return success_response(item.to_dict(),
|
||||
message=f'Took {quantity}, {item.quantityonhand} left')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user