# Primewear POS — Full client workflow (Phases 0–6)

This is what **you tell the client**, and what **you / IT do on each till PC**.

---

## A. What to tell the client (simple)

### What they get

1. **Normal selling** in a desktop app (no Chrome print preview for receipts/labels).
2. **If internet drops**, cashiers can still sell from a product cache; sales sync when the network returns.
3. **Receipt printer** and **XP-420B label printer** are separate — each till has its own settings.
4. **Offline also supports (Phase 6):**
   - Find / attach cached customers
   - Discounts within the cashier % limit
   - Refunds against **recent sales already cached** on that till
5. **Still online-only (by design):**
   - Lay-by create / pay
   - Stock receive / purchase orders
   - Offline exchanges (replacement SKU needs live stock)
   - Reports / new product create (except Quick Add while online)

### One sentence for the owner

> “Tills keep selling offline and print silently; when the network returns, sales and simple refunds sync safely without double stock cuts. Lay-bys and stock receiving stay on the server.”

---

## B. What YOU do before going to the store

### Server (Laragon / hosting)

1. Deploy latest code.
2. Run:
   ```powershell
   cd d:\laragon\www\pos
   php artisan migrate --force
   npm run build
   ```
3. Settings (admin login):
   - Enable **Offline mode**
   - Set **cashier discount limit**
   - Enable **refunds allowed** if they refund offline
   - Confirm stores + **POS terminals** (Counter 1, Counter 2…)
4. Create staff users with roles; each cashier linked to a store.
5. Build desktop installer (on your machine):
   ```powershell
   cd d:\laragon\www\pos\desktop
   npm install
   npm run dist
   ```
   Share: `desktop\dist\Primewear-POS-Setup-*.exe`

### Network

- Production: HTTPS URL to the POS (e.g. `https://pos.clientdomain.co.za`)
- Local shop server: `http://SHOP-PC-NAME` or Laragon vhost reachable from tills

---

## C. What YOU do on each client till PC

### 1) Install

1. Install printers:
   - Receipt thermal (80mm) Windows driver
   - XP-420B label printer Windows driver + 40×30 paper
2. Run **Primewear-POS-Setup-*.exe**
3. Open **Primewear POS**
4. **Till → Till settings**
   - POS URL = server URL
   - Store / counter labels (optional)
   - **Receipt printer** = thermal (never XP-420B)
   - **Label printer** = XP-420B
   - Test receipt + Test label
5. Login with cashier account
6. Checkout → select **Checkout counter** (required for offline)
7. Stay online 1–2 minutes so catalog + customers + recent sales cache

### 2) Hand over to cashier

Give them:

- `docs/TRAINING_ONE_PAGER.md` (print 1 page)
- Daily checklist: open app → Online + 0 pending → test print once

### 3) Multi-till

Repeat C1 on every till PC. Each PC has its own printer settings. Counters are different terminals in Checkout.

---

## D. Scenario workflows (all cases)

### Scenario 1 — Online sale + silent receipt

| Who | Steps |
|-----|--------|
| Cashier | Login → counter selected → scan → pay → Complete |
| System | Sale saved on server → receipt silent print (desktop) |
| You | Nothing, unless printer wrong → Till settings |

### Scenario 2 — Label print (Quick Add / Labels)

| Who | Steps |
|-----|--------|
| Staff | Create/print labels while online |
| System | Desktop sends to **label printer** only |
| You | Confirm XP-420B selected under Label printer |

### Scenario 3 — Internet drops mid-day (offline sale)

| Who | Steps |
|-----|--------|
| Cashier | Badge shows **Offline** → scan from cache → Complete → “Saved offline” |
| System | Sale in local queue; local stock cache drops; optional local receipt |
| When online | Auto sync → badge back to Online / 0 pending |
| You | If stuck pending: Till → Open log folder; check server; Review panel Retry/Void |

### Scenario 4 — Two tills offline sell last unit of same SKU

| Who | Steps |
|-----|--------|
| System | First sync **accepted**; second → **rejected_insufficient_stock** |
| Cashier/Manager | Sync needs review → fix stock OR Void local |
| You | Explain: server stock is truth; no silent double-sell |

### Scenario 5 — Offline customer + discount (Phase 6)

| Who | Steps |
|-----|--------|
| Cashier (offline) | Offline extras → Find customer OR enter new phone/name |
| Cashier | Apply discount ≤ cashier limit |
| System | Syncs with customer + discount when online |
| Note | Over-limit discount blocked offline (needs online + manager PIN) |

### Scenario 6 — Offline refund from cached sale (Phase 6)

| Who | Steps |
|-----|--------|
| Pre-req | Till was online recently (recent sales cached) |
| Cashier (offline) | Offline extras → sale number or barcode → Refund 1 |
| System | Queues return; syncs via API; may be **pending approval** |
| Not supported offline | Exchange for another SKU; return for sale never cached on this PC |

### Scenario 7 — Lay-by / stock receive while offline

| Who | Steps |
|-----|--------|
| Cashier | Tell them: **must wait for Online** |
| System | Not available offline (by design) |
| You | Do not promise offline lay-by unless Phase 6d is later funded |

### Scenario 8 — Printer wrong / no print

| Who | Steps |
|-----|--------|
| You on till | Till settings → correct printers → Test receipt / Test label |
| Check | Windows default printers, USB, paper size 40×30 for labels |
| Logs | Till → Open log folder |

### Scenario 9 — New till PC / reinstall

| Who | Steps |
|-----|--------|
| You | Install Setup EXE → set URL + printers → login → select counter → online cache |
| Note | Old pending offline sales live in that PC’s browser/IndexedDB profile — don’t wipe app data mid-day |

### Scenario 10 — End of day / morning open

| Cashier | Online + **0 pending** before closing |
| Manager | Server backup (Settings → Backup) — tills are not the backup |

---

## E. Command cheat-sheet (your machine)

```powershell
# Deploy DB + frontend assets
cd d:\laragon\www\pos
php artisan migrate --force
npm run build

# Desktop app (dev)
cd d:\laragon\www\pos\desktop
$env:POS_URL="http://pos.test"
npm start

# Windows installer for client PCs
cd d:\laragon\www\pos\desktop
npm run dist
```

PHP path if needed:

```powershell
$env:Path = "D:\laragon\bin\php\php-8.3.30-Win32-vs16-x64;" + $env:Path
```

---

## F. Feature matrix (what works where)

| Feature | Online | Offline |
|---------|--------|---------|
| Sell / pay | Yes | Yes (cached catalog) |
| Silent receipt | Yes (Electron) | Yes (local slip) |
| Silent labels | Yes (Electron) | No (need online label page) |
| Customer attach | Yes | Yes (cached + new phone) |
| Discount ≤ limit | Yes | Yes |
| Discount > limit | Manager PIN | Blocked |
| Refund (cached sale) | Yes | Yes (sync later) |
| Exchange | Yes | No |
| Lay-by | Yes | No |
| Stock receive | Yes | No |
| Reports | Yes | No |

---

## G. In-app help (leave these URLs with the client)

Open on the server (no login required):

| Page | URL |
|------|-----|
| Help centre | `/help` |
| Installation step-by-step | `/help/installation` |
| Offline workflow | `/help/offline` |
| Workflows (role + feature) | `/help/workflows` |
| Complete user guide | `/help/guide` |

Also linked from **login** (“Help & setup guides”) and the app sidebar (**Help**).

## H. Documents to leave with the client

| File | Audience |
|------|----------|
| `docs/TRAINING_ONE_PAGER.md` | Cashiers |
| `docs/OPS_CHECKLIST.md` | Store manager / opening staff |
| `docs/MULTI_TILL.md` | IT / multi-counter shops |
| `docs/CLIENT_FULL_WORKFLOW.md` | You + client IT (this file) |
| `docs/HYBRID_OFFLINE_ELECTRON_ROADMAP.md` | Project status |

---

*Phases 0–6a/b/c delivered. 6d lay-by offline and 6e stock receive offline remain out of scope unless the client funds them separately.*
