# Bins & QR Scanning

_Enterprise_

Bins are physical storage locations — a shelf, a bay, an aisle slot. Each bin has a name (free-text) and an auto-generated QR code printed on a label. When you receive stock or hunt down an item, scan the bin QR with your phone to jump straight to its contents. Lives at Inventory > Bins.

## Steps
1. Go to Inventory > Bins. Click "+ Add bin" — give it a descriptive name ("A-04-2", "Cold Room — Shelf 3"), optional notes. Hit save.
2. Open the bin to see its QR code (rendered as SVG, embedded in the list response so no per-row fetch). Click "Print label" — opens a print-friendly view with the QR + bin name.
3. Stick the label on the shelf, bin, or rack.
4. On the mobile app, open Inventory > Scan bin. Point the camera at the label — the bin detail screen opens with current contents, last received date, and a "Receive into this bin" shortcut.
5. During PO receiving, you can pass a binId per line item to pin received stock to a specific bin. Last-receive wins (single-bin model for Phase 1).

## Tips
- QR codes are stable — re-printing produces the same code for the same bin. Don't re-create bins to "get a new code"; just re-print the label.
- Free-text bin names are allowed alongside the bin model. Items have both a bin (free-text legacy field) and binId (the FK). Both are populated during transitions; binId is the source of truth.
- Mobile scan uses expo-camera. It works through the front-facing camera too in a pinch, though the rear camera is much faster.

## Example
A warehouse uses a grid system: aisle letter, bay number, shelf height. Each shelf slot gets a 2x2 inch QR sticker. New receivers don't need to memorize the layout — they scan the bin, then scan the item, then enter quantity. A receive that used to take 4 minutes per pallet now takes 90 seconds.

## Troubleshooting
- **Mobile camera permission denied** — The first time you open the scan screen, the OS prompts for camera access. If you tapped "Don't allow" the prompt won't fire again. Fix: iOS: Settings > Privacy & Security > Camera > CRMown → on. Android: Settings > Apps > CRMown > Permissions > Camera → allow.
- **QR scan jumps to wrong bin** — You scanned a QR from a different system (carrier label, product UPC, etc.) — bin QRs encode an internal id, not a URL. Fix: Bin labels say "BIN" above the QR. If you scanned the wrong code, the scan endpoint returns 404 and the screen shows "No bin found for that code."
- **Bin shows 0 items but inventory says it should have stock** — Items have a binId only when stock was last received with a binId param. Items added through the Items panel without a bin assignment won't appear in any bin's contents. Fix: Edit the item and set its Bin field, or receive its stock through a PO with a binId. Either path populates the FK.

## Plans
Enterprise suite required.
