23 Commits

Author SHA1 Message Date
Mikhail Chusavitin
5f8aec456b Unified Quote Journal (parts_log) v3
- New unified append-only quote log table parts_log replaces three
  separate log tables (stock_log, partnumber_log_competitors, lot_log)
- Migrations 042-049: extend supplier, create parts_log/import_formats/
  ignore_rules, rework qt_lot_metadata composite PK, add lead_time_weeks
  to pricelist_items, backfill data, migrate ignore rules
- New services: PartsLogBackfillService, ImportFormatService,
  UnifiedImportService; new world pricelist type (all supplier types)
- qt_lot_metadata PK changed to (lot_name, pricelist_type); all queries
  now filter WHERE pricelist_type='estimate'
- Fix pre-existing bug: qt_component_usage_stats column names
  quotes_last30d/quotes_last7d (no underscore) — added explicit gorm tags
- Bible: full table inventory, baseline schema snapshot, updated pricelist/
  data-rules/api/history/architecture docs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 17:25:54 +03:00
Mikhail Chusavitin
f73e3d144d Vendor mapping: wildcard ignore patterns, bulk CSV import, multi-lot qty
- Add glob pattern support (* and ?) for ignore rules stored in
  qt_vendor_partnumber_seen (is_pattern flag, migration 041)
- Pattern matching applied in stock/competitor import, partnumber book
  snapshot, and vendor mappings list (Go-side via NormalizeKey)
- BulkUpsertMappings: replace N+1 loop with two batch SQL upserts,
  validating all lots in a single query (~1500 queries → 3-4)
- CSV import: multi-lot per PN via repeated rows, optional qty column
- CSV export: updated column format vendor;partnumber;lot_name;qty;description;ignore;notes
- UI: ignore patterns section with add/delete, import progress feedback
- Update bible-local/vendor-mapping.md with new CSV format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 09:41:48 +03:00
Mikhail Chusavitin
df5be91353 Improve performance on poor connections: local assets, gzip, caching
- Replace Tailwind CDN (~350KB) with purged local CSS (~22KB)
- Replace htmx unpkg CDN with local static file
- Add Gzip middleware (standard library, sync.Pool) for all responses
- Add Cache-Control: public, max-age=3600 for /static/* assets
- Reduce status polling interval from 5s to 30s
- Add scripts/build-css.sh for CSS regeneration after template changes
- Document in bible-local/operations.md and history.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 14:51:21 +03:00
Mikhail Chusavitin
ec182abe99 Competitor pricelist: aggregate all competitors, rebuild without re-import
- Add GetLatestQuotesAllCompetitors() repo method: latest quote per
  (competitor_id, partnumber) across all active competitors
- Add RebuildPricelist() service method: loads all quotes, applies each
  competitor's discount, aggregates with weighted_median per lot,
  creates single combined competitor pricelist
- Add POST /api/competitors/pricelist handler + route
- JS: "Создать прайслист" on competitor tab calls new endpoint instead
  of the generic one that required explicit items

This allows recreating the competitor pricelist after new lot mappings
are added, without requiring a new file upload.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 08:17:44 +03:00
Mikhail Chusavitin
3f26a2935a Refactor vendor mappings to canonical PN catalog 2026-03-07 23:11:42 +03:00
Mikhail Chusavitin
96572be712 Harden local admin and secret storage 2026-03-07 22:14:31 +03:00
Mikhail Chusavitin
b2b2f4774c Refactor scheduler and settings UI 2026-03-07 21:10:20 +03:00
Mikhail Chusavitin
04ce74ca1b Refine vendor mapping CSV operations and ignore import flow 2026-02-27 16:49:39 +03:00
Mikhail Chusavitin
6f1de7a20e Add vendor mappings CSV import modal and fix vendor rename save 2026-02-26 12:44:11 +03:00
Mikhail Chusavitin
63454554c1 Fix vendor mapping delete behavior and update docs 2026-02-25 19:06:28 +03:00
a4457a0a28 Add partnumber book snapshots for QuoteForge integration
- Migrations 026-028: qt_partnumber_books + qt_partnumber_book_items
  tables; is_primary_pn on lot_partnumbers; version VARCHAR(30);
  description VARCHAR(10000) on items (required by QuoteForge sync)
- Service: CreateSnapshot expands bundles, filters empty lot_name and
  ignored PNs, copies description, activates new book atomically,
  applies GFS retention (7d/5w/12m/10y) with explicit item deletion
- Task type TaskTypePartnumberBookCreate; handlers ListPartnumberBooks
  and CreatePartnumberBook; routes GET/POST /api/admin/pricing/partnumber-books
- UI: snapshot list + "Создать снапшот сопоставлений" button with
  progress polling on /vendor-mappings page
- Bible: history, api, background-tasks, vendor-mapping updated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-21 22:16:16 +03:00
Mikhail Chusavitin
c22328bf03 Implement global vendor mappings with bundle support and seen-based ignore 2026-02-18 19:54:07 +03:00
Mikhail Chusavitin
c939ce18ad Merge origin/main 2026-02-18 10:12:07 +03:00
985e64d1b5 chore: apply pending changes 2026-02-18 07:01:49 +03:00
f64c4fd6b2 feat: optimize background tasks and fix warehouse pricelist workflow
Optimize task retention from 5 minutes to 30 seconds to reduce polling overhead since toast notifications are shown only once. Add conditional warehouse pricelist creation via checkbox. Fix category storage in warehouse pricelists to properly load from lot table. Replace SSE with task polling for all long operations. Add comprehensive logging for debugging while minimizing noise from polling endpoints.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16 11:08:10 +03:00
Mikhail Chusavitin
c8ad43677d refactor: separate LOT management to dedicated page
- Create new /lot page with two tabs:
  1. LOT: component management (formerly in /admin/pricing)
  2. Сопоставления: partnumber ↔ LOT mappings (formerly in Warehouse tab)
- Remove LOT tab from Pricing Admin page
- Remove stock mappings section from Warehouse tab
- Update main menu: LOT link now points to /lot
- Default tab in Pricing Admin changed to Estimate
- Add Lot() handler in web.go
- Add /lot route in main.go

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-10 16:13:04 +03:00
e97cd5048c feat: implement background task system with notifications
- Added background task manager with goroutine execution and panic recovery
- Replaced SSE streaming with background task execution for:
  * Price recalculation (RecalculateAll)
  * Stock import (ImportStockLog)
  * Pricelist creation (CreateWithProgress)
- Implemented unified polling for task status and DB connection in frontend
- Added task indicator in top bar showing running tasks count
- Added toast notifications for task completion/error
- Tasks automatically cleaned up after 10 minutes
- Tasks show progress (0-100%) with descriptive messages
- Updated handler constructors to receive task manager
- Added API endpoints for task status (/api/tasks, /api/tasks/:id)

Fixes issue with SSE disconnection on slow connections during long-running operations
2026-02-08 20:39:59 +03:00
9bc01831c9 feat: add pricelist CSV export and improve description display
- Add CSV export functionality for pricelists with download button
- Export includes all pricelist items with proper UTF-8 encoding
- Support both warehouse and estimate pricelist sources
- Remove description column from admin pricing tables
- Show description as tooltip on row hover instead
- Improve table layout by removing redundant column

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 12:26:45 +03:00
85062e007c feat: add LOT creation, auto-save mappings, disable auto warehouse pricelist
- Add LOT creation functionality in pricing admin
  - New API endpoint POST /api/admin/pricing/lots
  - Modal form for creating new LOT with auto-category detection
  - Creates entries in both lot and qt_lot_metadata tables

- Implement auto-save for stock mappings
  - Auto-save on change for partnumber → LOT mappings
  - Visual feedback (orange during save, green on success, red on error)
  - Works in both main mappings table and import suggestions

- Improve stock import suggestions UI
  - Remove "Причина" column from suggestions table
  - Increase LOT and Partnumber column widths to 33% each
  - Better visual balance in the table layout

- Disable automatic warehouse pricelist creation on stock_log import
  - Import now completes at 100% after stock_log update
  - Manual pricelist creation available via UI when needed
  - Faster import process without auto-generation overhead

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 11:34:43 +03:00
319400106c Restore connection settings modal from top nav 2026-02-08 10:54:31 +03:00
bf5dce9f18 chore: remove remaining QuoteForge/qfs references 2026-02-07 21:49:32 +03:00
005478ac6b refactor to MariaDB-only runtime and simplify PriceForge 2026-02-07 21:42:26 +03:00
20309d1f0e Fork from QuoteForge → PriceForge
Renamed module path git.mchus.pro/mchus/quoteforge → git.mchus.pro/mchus/priceforge,
renamed package quoteforge → priceforge, moved binary from cmd/qfs to cmd/pfs.
2026-02-07 21:42:26 +03:00