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>
This commit is contained in:
@@ -210,13 +210,13 @@ func (s *Service) RecalculateAllPricesWithProgress(onProgress func(RecalculatePr
|
||||
|
||||
// Logic mirrors "Обновить цены" in admin pricing.
|
||||
var components []models.LotMetadata
|
||||
if err := s.db.Find(&components).Error; err != nil {
|
||||
if err := s.db.Where("pricelist_type = 'estimate'").Find(&components).Error; err != nil {
|
||||
return 0, len(components)
|
||||
}
|
||||
total := len(components)
|
||||
|
||||
var allLotNames []string
|
||||
if err := s.db.Model(&models.LotMetadata{}).Pluck("lot_name", &allLotNames).Error; err != nil {
|
||||
if err := s.db.Model(&models.LotMetadata{}).Where("pricelist_type = 'estimate'").Pluck("lot_name", &allLotNames).Error; err != nil {
|
||||
// Log error but continue
|
||||
allLotNames = []string{}
|
||||
}
|
||||
@@ -389,7 +389,7 @@ func (s *Service) RecalculateAllPricesWithProgress(onProgress func(RecalculatePr
|
||||
ctx3, cancel3 := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
updateStart := time.Now()
|
||||
updateErr := s.db.WithContext(ctx3).Model(&models.LotMetadata{}).
|
||||
Where("lot_name = ?", comp.LotName).
|
||||
Where("lot_name = ? AND pricelist_type = 'estimate'", comp.LotName).
|
||||
Updates(map[string]interface{}{
|
||||
"current_price": finalPrice,
|
||||
"price_updated_at": now,
|
||||
@@ -509,7 +509,7 @@ func (s *Service) RecalculateAllPricesWithProgress(onProgress func(RecalculatePr
|
||||
|
||||
ctx3, cancel3 := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
updateErr := s.db.WithContext(ctx3).Model(&models.LotMetadata{}).
|
||||
Where("lot_name = ?", comp.LotName).
|
||||
Where("lot_name = ? AND pricelist_type = 'estimate'", comp.LotName).
|
||||
Updates(map[string]interface{}{
|
||||
"current_price": finalPrice,
|
||||
"price_updated_at": now,
|
||||
|
||||
Reference in New Issue
Block a user