# POS Exchange Return Serial Editing Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Add safe serial editing to POS exchange return rows and package the deployable files.

**Architecture:** Extend the existing dynamic exchange-row renderer in `public/js/pos.js`. Reuse the existing receipt-line modal as the editor, and keep generic serial validation limited to actual serial-tracked rows.

**Tech Stack:** JavaScript, jQuery, Node.js built-in test runner, PHP/Laravel asset configuration.

## Global Constraints

- Returned serials must come from the original sold serial list.
- Return quantity must continue to equal the selected serial count.
- Do not add a serial field to non-serial return rows.
- Package production files under their original relative paths.

---

### Task 1: Regression coverage

**Files:**
- Create: `tests/js/pos_exchange_return_serial.test.js`

- [ ] Write behavior tests for tracked and non-tracked return rows.
- [ ] Run the test and confirm it fails because the editor and tracking branch are absent.

### Task 2: Return-row behavior

**Files:**
- Modify: `public/js/pos.js`

- [ ] Pass the serial-tracked flag into the return-row builder.
- [ ] Render an Edit serials button only for tracked rows.
- [ ] Reopen the existing exchange modal with the row's current selection.
- [ ] Trigger validation whenever an existing or new tracked row is synchronized.
- [ ] Run the regression test and confirm it passes.

### Task 3: Cache invalidation and package

**Files:**
- Modify: `config/constants.php`
- Create: `08122026_pos_exchange_return_serial_edit_fix/public/js/pos.js`
- Create: `08122026_pos_exchange_return_serial_edit_fix/config/constants.php`

- [ ] Increment the asset version from 630 to 631.
- [ ] Run JavaScript syntax checking and focused tests.
- [ ] Copy the production files into the deployment folder using their original paths.
- [ ] Compare packaged file hashes with the updated source files.
