Skip to content

fix(pos): honor scanned barcode UOM in item selection dialog#311

Open
NotAbdelrahmanelsayed wants to merge 2 commits into
BrainWise-DEV:developfrom
NotAbdelrahmanelsayed:fix/barcode-uom-dialog-selection
Open

fix(pos): honor scanned barcode UOM in item selection dialog#311
NotAbdelrahmanelsayed wants to merge 2 commits into
BrainWise-DEV:developfrom
NotAbdelrahmanelsayed:fix/barcode-uom-dialog-selection

Conversation

@NotAbdelrahmanelsayed

Copy link
Copy Markdown
Contributor

Problem

When a barcode is tied to a UOM that differs from the item's stock UOM — e.g. a barcode keyed to Nos on an item stocked in grams — scanning it adds the item in the stock UOM, not the barcode's UOM.

search_by_barcode already resolves this correctly: it sets item.uom from Item Barcode.uom and returns the right conversion_factor. But when the scan opens the UOM dialog (scanner mode without auto-add), ItemSelectionDialog.loadOptions() defaulted the selected option to options[0] (the stock UOM) whenever there was more than one UOM. Its single-barcode auto-select couldn't help either, because search_by_barcode doesn't populate barcode_uoms on its response — so the dialog always landed on the stock UOM.

Fix

When defaulting the UOM selection, prefer an explicitly resolved UOM:

resolved_uom (weighted/priced barcodes) → scanned barcode UOM (item.uom when it differs from stock_uom) → a sole barcode_uoms entry → stock UOM.

No behaviour change when item.uom is absent or equals the stock UOM (normal grid taps, single-UOM items), so existing flows are unaffected.

Test plan

  • Item stocked in gram, barcode keyed to Nos (1 Nos = N g). Scan in scanner mode → UOM dialog now defaults to Nos (was gram).
  • Normal item tap (no barcode UOM) → still defaults to stock UOM.
  • Weighted/priced barcode (resolved_uom) → unchanged.

🤖 Generated with Claude Code

NotAbdelrahmanelsayed and others added 2 commits June 12, 2026 20:33
When a barcode is tied to a non-stock UOM (e.g. a barcode keyed to "Nos"
on a gram-stocked item), search_by_barcode resolves item.uom to that UOM,
but ItemSelectionDialog defaulted the UOM radio to the stock UOM whenever
there was more than one possible UOM. barcode_uoms isn't carried on the
search_by_barcode response, so its single-barcode auto-select never fired
either, and the scan landed on the stock UOM instead of the barcode's UOM.

Prefer an explicitly resolved UOM when defaulting the selection:
resolved_uom -> scanned barcode UOM (item.uom != stock_uom) -> a sole
barcode UOM -> stock UOM. No behaviour change when item.uom is absent or
equals the stock UOM.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…dialog-selection

# Conflicts:
#	POS/src/components/sale/ItemSelectionDialog.vue
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.

1 participant