feat(pos): add 5 quick improvements — dark mode, email quotes, barcode scan, returns, offline catalog

1. Auto dark mode: detect system prefers-color-scheme, auto-switch industrial/modern theme
2. Email quotation endpoint: POST /quotations/:id/email sends HTML email via SMTP
3. Camera barcode scanner: BarcodeDetector API with getUserMedia overlay in catalog
4. Returns with warranty: POST /returns endpoint with stock restoration and sale status tracking
5. Partial offline catalog: cache top 500 parts in IndexedDB, search when offline

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 08:03:28 +00:00
parent 39f2aaf98f
commit c61e58ac6a
9 changed files with 751 additions and 23 deletions

View File

@@ -0,0 +1,32 @@
-- v1.5 Returns & warranty support
-- Applied to each tenant database
CREATE TABLE IF NOT EXISTS returns (
id SERIAL PRIMARY KEY,
sale_id INTEGER REFERENCES sales(id),
customer_id INTEGER REFERENCES customers(id),
employee_id INTEGER REFERENCES employees(id),
total_refund NUMERIC(12,2) NOT NULL DEFAULT 0,
reason TEXT NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'completed',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS return_items (
id SERIAL PRIMARY KEY,
return_id INTEGER REFERENCES returns(id) ON DELETE CASCADE,
sale_item_id INTEGER,
inventory_id INTEGER REFERENCES inventory(id),
quantity INTEGER NOT NULL,
unit_price NUMERIC(12,2),
refund_amount NUMERIC(12,2)
);
CREATE INDEX IF NOT EXISTS idx_returns_sale_id ON returns(sale_id);
CREATE INDEX IF NOT EXISTS idx_returns_customer_id ON returns(customer_id);
CREATE INDEX IF NOT EXISTS idx_returns_created_at ON returns(created_at);
CREATE INDEX IF NOT EXISTS idx_return_items_return_id ON return_items(return_id);
CREATE INDEX IF NOT EXISTS idx_return_items_sale_item_id ON return_items(sale_item_id);
-- Add 'partially_returned' and 'returned' to sales status if not using enum
-- (sales.status is VARCHAR, so no ALTER TYPE needed)