Fix offline usage tracking and active pricelist sync

This commit is contained in:
Mikhail Chusavitin
2026-02-04 09:54:13 +03:00
parent a3dc264efd
commit 1b87c53609
3 changed files with 39 additions and 6 deletions

View File

@@ -132,6 +132,11 @@ func (s *QuoteService) ValidateAndCalculate(req *QuoteRequest) (*QuoteValidation
// RecordUsage records that components were used in a quote
func (s *QuoteService) RecordUsage(items []models.ConfigItem) error {
if s.statsRepo == nil {
// Offline mode: usage stats are unavailable and should not block config saves.
return nil
}
for _, item := range items {
revenue := item.UnitPrice * float64(item.Quantity)
if err := s.statsRepo.IncrementUsage(item.LotName, item.Quantity, revenue); err != nil {