feat(pos): add inventory blueprint — CRUD, operations, physical count, reports, alerts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 02:12:48 +00:00
parent 659832ab16
commit 070e2df723
2 changed files with 863 additions and 0 deletions

View File

@@ -352,5 +352,28 @@ CREATE INDEX idx_audit_log_created ON audit_log(created_at);
CREATE UNIQUE INDEX idx_inventory_branch_part ON inventory(branch_id, part_number);
CREATE INDEX idx_employee_sessions_token ON employee_sessions(token);
-- =====================
-- PHYSICAL COUNTS (two-phase inventory count)
-- =====================
CREATE TABLE IF NOT EXISTS physical_counts (
id SERIAL PRIMARY KEY,
branch_id INTEGER NOT NULL REFERENCES branches(id),
status VARCHAR(20) NOT NULL DEFAULT 'draft', -- draft, approved, cancelled
notes TEXT,
employee_id INTEGER REFERENCES employees(id),
approved_by INTEGER REFERENCES employees(id),
created_at TIMESTAMP DEFAULT NOW(),
approved_at TIMESTAMP
);
CREATE TABLE IF NOT EXISTS physical_count_lines (
id SERIAL PRIMARY KEY,
physical_count_id INTEGER NOT NULL REFERENCES physical_counts(id),
inventory_id INTEGER NOT NULL REFERENCES inventory(id),
expected_quantity INTEGER NOT NULL,
counted_quantity INTEGER NOT NULL,
difference INTEGER NOT NULL
);
-- Barcode sequence
CREATE SEQUENCE IF NOT EXISTS barcode_seq START 1;