feat: складские цены и «только наличие» — настройки уровня проекта

Добавлен чекбокс «Складские цены» (по аналогии с «Аренда»), управляющий
показом складских цен во всех ценовых интерфейсах конфигурации, включая
CSV-экспорт. «Только наличие» перенесён из настроек цен конфигурации в
настройки проекта и активен только при включённых складских ценах.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-08-12 17:05:39 +03:00
co-authored by Claude Sonnet 5
parent 18282452a1
commit 9629521495
18 changed files with 244 additions and 166 deletions
-1
View File
@@ -34,7 +34,6 @@ type CreateConfigRequest struct {
CompetitorPricelistID *uint `json:"competitor_pricelist_id,omitempty"`
ConfigType string `json:"config_type,omitempty"` // "server" | "storage"
DisablePriceRefresh bool `json:"disable_price_refresh"`
OnlyInStock bool `json:"only_in_stock"`
}
type ArticlePreviewRequest struct {
-6
View File
@@ -103,7 +103,6 @@ func (s *LocalConfigurationService) Create(ownerUsername string, req *CreateConf
CompetitorPricelistID: req.CompetitorPricelistID,
ConfigType: req.ConfigType,
DisablePriceRefresh: req.DisablePriceRefresh,
OnlyInStock: req.OnlyInStock,
CreatedAt: time.Now(),
}
if cfg.ConfigType == "" {
@@ -204,7 +203,6 @@ func (s *LocalConfigurationService) Update(uuid string, ownerUsername string, re
localCfg.WarehousePricelistID = req.WarehousePricelistID
localCfg.CompetitorPricelistID = req.CompetitorPricelistID
localCfg.DisablePriceRefresh = req.DisablePriceRefresh
localCfg.OnlyInStock = req.OnlyInStock
localCfg.UpdatedAt = time.Now()
localCfg.SyncStatus = "pending"
@@ -328,7 +326,6 @@ func (s *LocalConfigurationService) CloneToProject(configUUID string, ownerUsern
WarehousePricelistID: original.WarehousePricelistID,
CompetitorPricelistID: original.CompetitorPricelistID,
DisablePriceRefresh: original.DisablePriceRefresh,
OnlyInStock: original.OnlyInStock,
CreatedAt: time.Now(),
}
@@ -566,7 +563,6 @@ func (s *LocalConfigurationService) UpdateNoAuth(uuid string, req *CreateConfigR
localCfg.WarehousePricelistID = req.WarehousePricelistID
localCfg.CompetitorPricelistID = req.CompetitorPricelistID
localCfg.DisablePriceRefresh = req.DisablePriceRefresh
localCfg.OnlyInStock = req.OnlyInStock
localCfg.UpdatedAt = time.Now()
localCfg.SyncStatus = "pending"
@@ -685,7 +681,6 @@ func (s *LocalConfigurationService) CloneNoAuthToProjectFromVersion(configUUID s
WarehousePricelistID: original.WarehousePricelistID,
CompetitorPricelistID: original.CompetitorPricelistID,
DisablePriceRefresh: original.DisablePriceRefresh,
OnlyInStock: original.OnlyInStock,
CreatedAt: time.Now(),
}
@@ -1648,7 +1643,6 @@ func (s *LocalConfigurationService) rollbackToVersion(configurationUUID string,
current.WarehousePricelistID = rollbackData.WarehousePricelistID
current.CompetitorPricelistID = rollbackData.CompetitorPricelistID
current.DisablePriceRefresh = rollbackData.DisablePriceRefresh
current.OnlyInStock = rollbackData.OnlyInStock
current.VendorSpec = rollbackData.VendorSpec
if rollbackData.Line > 0 {
current.Line = rollbackData.Line
@@ -154,7 +154,6 @@ func TestUpdateNoAuthCreatesRevisionWhenPricingSettingsChanged(t *testing.T) {
Items: models.ConfigItems{{LotName: "CPU_A", Quantity: 1, UnitPrice: 1000}},
ServerCount: 1,
DisablePriceRefresh: true,
OnlyInStock: true,
}); err != nil {
t.Fatalf("update pricing settings: %v", err)
}
+13 -5
View File
@@ -46,11 +46,13 @@ type CreateProjectRequest struct {
}
type UpdateProjectRequest struct {
Code *string `json:"code,omitempty"`
Variant *string `json:"variant,omitempty"`
Name *string `json:"name,omitempty"`
TrackerURL *string `json:"tracker_url,omitempty"`
RentalEnabled *bool `json:"rental_enabled,omitempty"`
Code *string `json:"code,omitempty"`
Variant *string `json:"variant,omitempty"`
Name *string `json:"name,omitempty"`
TrackerURL *string `json:"tracker_url,omitempty"`
RentalEnabled *bool `json:"rental_enabled,omitempty"`
ShowStockPrices *bool `json:"show_stock_prices,omitempty"`
OnlyInStock *bool `json:"only_in_stock,omitempty"`
}
type ProjectConfigurationsResult struct {
@@ -152,6 +154,12 @@ func (s *ProjectService) Update(projectUUID, ownerUsername string, req *UpdatePr
if req.RentalEnabled != nil {
localProject.RentalEnabled = *req.RentalEnabled
}
if req.ShowStockPrices != nil {
localProject.ShowStockPrices = *req.ShowStockPrices
}
if req.OnlyInStock != nil {
localProject.OnlyInStock = *req.OnlyInStock
}
localProject.UpdatedAt = time.Now()
localProject.SyncStatus = "pending"
if err := s.localDB.SaveProject(localProject); err != nil {
+2
View File
@@ -218,6 +218,8 @@ func (s *Service) ImportProjectsToLocal() (*ProjectImportResult, error) {
existing.IsActive = project.IsActive
existing.IsSystem = project.IsSystem
existing.RentalEnabled = project.RentalEnabled
existing.ShowStockPrices = project.ShowStockPrices
existing.OnlyInStock = project.OnlyInStock
existing.CreatedAt = project.CreatedAt
existing.UpdatedAt = project.UpdatedAt
serverID := project.ID