Modularize Go files, extract JS to static, implement competitor pricelists
Go refactoring: - Split handlers/pricing.go (2446→291 lines) into 5 focused files - Split services/stock_import.go (1334→~400 lines) into stock_mappings.go + stock_parse.go - Split services/sync/service.go (1290→~250 lines) into 3 files JS extraction: - Move all inline <script> blocks to web/static/js/ (6 files) - Templates reduced: admin_pricing 2873→521, lot 1531→304, vendor_mappings 1063→169, etc. Competitor pricelists (migrations 033-039): - qt_competitors + partnumber_log_competitors tables - Excel import with column mapping, dedup, bulk insert - p/n→lot resolution via weighted_median, discount applied - Unmapped p/ns written to qt_vendor_partnumber_seen - Quote counts (unique/total) shown on /admin/competitors - price_method="weighted_median", price_period_days=0 stored explicitly Fix price_method/price_period_days for warehouse items: - warehouse: weighted_avg, period=0 - competitor: weighted_median, period=0 - Removes misleading DB defaults (was: median/90) Update bible: architecture.md, pricelist.md, history.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
27
migrations/033_add_competitors.sql
Normal file
27
migrations/033_add_competitors.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE IF NOT EXISTS qt_competitors (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
code VARCHAR(100) NOT NULL UNIQUE,
|
||||
delivery_basis VARCHAR(50) NOT NULL DEFAULT 'DDP',
|
||||
expected_discount_pct DECIMAL(5,2) NOT NULL DEFAULT 0.00,
|
||||
column_mapping JSON NULL,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS partnumber_log_competitors (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
competitor_id BIGINT UNSIGNED NOT NULL,
|
||||
lot_name VARCHAR(255) NOT NULL,
|
||||
raw_partnumber VARCHAR(255) NULL,
|
||||
price DECIMAL(12,2) NOT NULL,
|
||||
quote_date DATE NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_plc_competitor_id (competitor_id),
|
||||
INDEX idx_plc_lot_name (lot_name),
|
||||
INDEX idx_plc_competitor_lot_date (competitor_id, lot_name, quote_date),
|
||||
CONSTRAINT fk_plc_competitor
|
||||
FOREIGN KEY (competitor_id) REFERENCES qt_competitors(id)
|
||||
ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
Reference in New Issue
Block a user