The else branch in CreateForSourceWithProgress was reading from
qt_lot_metadata (estimate snapshot) for any source when no items
were provided. This caused estimate prices, coefficients, manual
prices and meta_prices to be copied verbatim into competitor/warehouse
pricelists when called with empty item list.
Fix: else branch is now guarded to source=="estimate" only.
Any other source with no items returns an explicit error instead
of silently falling back to estimate data.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Track positions added to a pricelist (not present in the previous one)
and display them in a separate "Новые позиции" section in the price
changes modal on both pricelists and admin_pricing pages.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
Две ключевые исправления:
1. Потоковая отправка прогресса создания (SSE):
- Эндпоинт CreateWithProgress теперь отправляет Server-Sent Events
вместо возврата JSON с task_id
- Полирует статус задачи и отправляет обновления прогресса в реальном времени
- Отправляет финальное событие с данными прайслиста или ошибкой
- Фронтенд уже ожидал этого формата SSE
2. Исправление маппинга колонки lot_category:
- Добавлен явный тег column в поле Category модели PricelistItem
чтобы маппиться на колонку 'lot_category' в БД
- Категория теперь хранится как снимок в таблице pricelist_items
- Обновлены запросы репозитория для использования сохраненной
категории вместо динамических JOIN с таблицей lot
Это исправляет ошибки:
- "Создание прервано: не получен результат" (фронтенд ожидал streaming)
- "Unknown column 'category' in 'INSERT INTO'" (несоответствие схемы БД)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- 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