feat: вкладка Аренда — колонки Estimate/Цена продажи; lot_description для прайслистов
Вкладка «Аренда»: добавлены колонки Estimate и Цена продажи (+ итоги), чекбокс «БУ» перенесён первым слева, таблица переведена на тот же разметку/классы, что и таблицы вкладки «Ценообразование». Прайслисты: local_pricelist_items получает lot_description (синхронизируется из qt_pricelist_items.lot_description) вместо устаревших available_qty/ partnumbers, которые нигде не заполнялись. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7edb80e498
commit
39e6fd5642
@@ -26,6 +26,7 @@ Rules:
|
|||||||
- user-authored tables must not be dropped as a recovery shortcut;
|
- user-authored tables must not be dropped as a recovery shortcut;
|
||||||
- `local_pricelist_items` is the only valid runtime source of prices and component catalog; do not add a separate component cache table;
|
- `local_pricelist_items` is the only valid runtime source of prices and component catalog; do not add a separate component cache table;
|
||||||
- `local_pricelist_items.lot_category` is the single source of a LOT's category at runtime (populated by sync from `qt_pricelist_items.lot_category`); do not derive category from a lot_name prefix or from `qt_categories`/`qt_lot_metadata`;
|
- `local_pricelist_items.lot_category` is the single source of a LOT's category at runtime (populated by sync from `qt_pricelist_items.lot_category`); do not derive category from a lot_name prefix or from `qt_categories`/`qt_lot_metadata`;
|
||||||
|
- `local_pricelist_items.lot_description` is the single source of a LOT's description at runtime (populated by sync from `qt_pricelist_items.lot_description`); do not join the legacy `lot` table for it;
|
||||||
- configuration `items` and `vendor_spec` are stored as JSON payloads inside configuration rows;
|
- configuration `items` and `vendor_spec` are stored as JSON payloads inside configuration rows;
|
||||||
- `local_components` table has been removed; any reference to it is dead code.
|
- `local_components` table has been removed; any reference to it is dead code.
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ These tables are retained for historical data. QuoteForge does not read or write
|
|||||||
|
|
||||||
Rules:
|
Rules:
|
||||||
- QuoteForge runtime must not depend on any legacy RFQ tables;
|
- QuoteForge runtime must not depend on any legacy RFQ tables;
|
||||||
- QuoteForge sync reads prices and categories from `qt_pricelists` / `qt_pricelist_items` only;
|
- QuoteForge sync reads prices, categories and descriptions from `qt_pricelists` / `qt_pricelist_items` only;
|
||||||
- QuoteForge does not enrich local pricelist rows from `parts_log` or any other raw supplier log table;
|
- QuoteForge does not enrich local pricelist rows from `parts_log` or any other raw supplier log table;
|
||||||
- normal UI requests must not query MariaDB tables directly;
|
- normal UI requests must not query MariaDB tables directly;
|
||||||
- `qt_client_local_migrations` exists in the 2026-04-15 schema dump, but runtime sync does not depend on it.
|
- `qt_client_local_migrations` exists in the 2026-04-15 schema dump, but runtime sync does not depend on it.
|
||||||
@@ -256,12 +257,16 @@ PK: lot_name
|
|||||||
| pricelist_id | bigint UNSIGNED NOT NULL | FK → qt_pricelists.id |
|
| pricelist_id | bigint UNSIGNED NOT NULL | FK → qt_pricelists.id |
|
||||||
| lot_name | varchar(255) NOT NULL | INDEX with pricelist_id |
|
| lot_name | varchar(255) NOT NULL | INDEX with pricelist_id |
|
||||||
| lot_category | varchar(50) | |
|
| lot_category | varchar(50) | |
|
||||||
|
| lot_description | varchar(10000) | added by migration 032; backfilled once from `lot.lot_description`. QF syncs this column directly — do not join `lot` per-row to get a description |
|
||||||
| price | decimal(12,2) NOT NULL | |
|
| price | decimal(12,2) NOT NULL | |
|
||||||
| price_method | varchar(20) | |
|
| price_method | varchar(20) | synced to local and shown in the pricelist detail "Настройки" column |
|
||||||
| price_period_days | bigint DEFAULT 90 | |
|
| price_period_days | bigint DEFAULT 90 | synced to local, same as above |
|
||||||
| price_coefficient | decimal(5,2) DEFAULT 0 | |
|
| price_coefficient | decimal(5,2) DEFAULT 0 | synced to local, same as above |
|
||||||
| manual_price | decimal(12,2) | |
|
| manual_price | decimal(12,2) | synced to local, same as above |
|
||||||
| meta_prices | varchar(1000) | |
|
| meta_prices | varchar(1000) | synced to local, same as above |
|
||||||
|
| lead_time_weeks | int | exists in the real table; not read by QF — no corresponding field in `models.PricelistItem` |
|
||||||
|
|
||||||
|
Fields QF never populates and does not model: `AvailableQty`/`Partnumbers` (removed from `models.PricelistItem` and `LocalPricelistItem` — no writer ever set them; always empty).
|
||||||
|
|
||||||
### qt_pricelist_sync_status
|
### qt_pricelist_sync_status
|
||||||
PK: username
|
PK: username
|
||||||
|
|||||||
@@ -180,16 +180,16 @@ func (h *PricelistHandler) GetItems(c *gin.Context) {
|
|||||||
resultItems := make([]gin.H, 0, len(items))
|
resultItems := make([]gin.H, 0, len(items))
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
resultItems = append(resultItems, gin.H{
|
resultItems = append(resultItems, gin.H{
|
||||||
"id": item.ID,
|
"id": item.ID,
|
||||||
"lot_name": item.LotName,
|
"lot_name": item.LotName,
|
||||||
"lot_description": "",
|
"lot_description": item.LotDescription,
|
||||||
"price": item.Price,
|
"price": item.Price,
|
||||||
"category": item.LotCategory,
|
"category": item.LotCategory,
|
||||||
"available_qty": item.AvailableQty,
|
"price_method": item.PriceMethod,
|
||||||
"partnumbers": []string(item.Partnumbers),
|
"price_period_days": item.PricePeriodDays,
|
||||||
"partnumber_qtys": map[string]interface{}{},
|
"price_coefficient": item.PriceCoefficient,
|
||||||
"competitor_names": []string{},
|
"manual_price": item.ManualPrice,
|
||||||
"price_spread_pct": nil,
|
"meta_prices": item.MetaPrices,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,18 +42,19 @@ func (l *LocalDB) latestActivePricelistID(source string) (uint, error) {
|
|||||||
|
|
||||||
// pricelistItemRow is used for scanning rows from local_pricelist_items.
|
// pricelistItemRow is used for scanning rows from local_pricelist_items.
|
||||||
type pricelistItemRow struct {
|
type pricelistItemRow struct {
|
||||||
LotName string `gorm:"column:lot_name"`
|
LotName string `gorm:"column:lot_name"`
|
||||||
Category string `gorm:"column:lot_category"`
|
Category string `gorm:"column:lot_category"`
|
||||||
|
Description string `gorm:"column:lot_description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r pricelistItemRow) toLocalComponent() LocalComponent {
|
func (r pricelistItemRow) toLocalComponent() LocalComponent {
|
||||||
return LocalComponent{
|
return LocalComponent{
|
||||||
LotName: r.LotName,
|
LotName: r.LotName,
|
||||||
Category: r.Category,
|
Category: r.Category,
|
||||||
|
LotDescription: r.Description,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SearchLocalComponents searches components in the latest active estimate
|
// SearchLocalComponents searches components in the latest active estimate
|
||||||
// pricelist by lot_name.
|
// pricelist by lot_name.
|
||||||
func (l *LocalDB) SearchLocalComponents(query string, limit int) ([]LocalComponent, error) {
|
func (l *LocalDB) SearchLocalComponents(query string, limit int) ([]LocalComponent, error) {
|
||||||
@@ -72,7 +73,7 @@ func (l *LocalDB) SearchLocalComponents(query string, limit int) ([]LocalCompone
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rows []pricelistItemRow
|
var rows []pricelistItemRow
|
||||||
if err := db.Select("lot_name, lot_category").Order("lot_name").Limit(limit).Scan(&rows).Error; err != nil {
|
if err := db.Select("lot_name, lot_category, lot_description").Order("lot_name").Limit(limit).Scan(&rows).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
components := make([]LocalComponent, len(rows))
|
components := make([]LocalComponent, len(rows))
|
||||||
@@ -100,7 +101,7 @@ func (l *LocalDB) SearchLocalComponentsByCategory(category, query string, limit
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rows []pricelistItemRow
|
var rows []pricelistItemRow
|
||||||
if err := db.Select("lot_name, lot_category").Order("lot_name").Limit(limit).Scan(&rows).Error; err != nil {
|
if err := db.Select("lot_name, lot_category, lot_description").Order("lot_name").Limit(limit).Scan(&rows).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
components := make([]LocalComponent, len(rows))
|
components := make([]LocalComponent, len(rows))
|
||||||
@@ -134,7 +135,7 @@ func (l *LocalDB) ListComponents(filter ComponentFilter, offset, limit int) ([]L
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rows []pricelistItemRow
|
var rows []pricelistItemRow
|
||||||
if err := db.Select("lot_name, lot_category").Order("lot_name").Offset(offset).Limit(limit).Scan(&rows).Error; err != nil {
|
if err := db.Select("lot_name, lot_category, lot_description").Order("lot_name").Offset(offset).Limit(limit).Scan(&rows).Error; err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
components := make([]LocalComponent, len(rows))
|
components := make([]LocalComponent, len(rows))
|
||||||
@@ -154,7 +155,7 @@ func (l *LocalDB) GetLocalComponent(lotName string) (*LocalComponent, error) {
|
|||||||
|
|
||||||
var row pricelistItemRow
|
var row pricelistItemRow
|
||||||
if err := l.db.Table("local_pricelist_items").
|
if err := l.db.Table("local_pricelist_items").
|
||||||
Select("lot_name, lot_category").
|
Select("lot_name, lot_category, lot_description").
|
||||||
Where("pricelist_id = ? AND UPPER(lot_name) = ?", pricelistID, strings.ToUpper(lotName)).
|
Where("pricelist_id = ? AND UPPER(lot_name) = ?", pricelistID, strings.ToUpper(lotName)).
|
||||||
First(&row).Error; err != nil {
|
First(&row).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -230,4 +231,3 @@ func (l *LocalDB) CountComponents() int64 {
|
|||||||
l.db.Table("local_pricelist_items").Where("pricelist_id = ?", pricelistID).Count(&count)
|
l.db.Table("local_pricelist_items").Where("pricelist_id = ?", pricelistID).Count(&count)
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -331,30 +331,33 @@ func LocalToPricelist(local *LocalPricelist) *models.Pricelist {
|
|||||||
|
|
||||||
// PricelistItemToLocal converts models.PricelistItem to LocalPricelistItem
|
// PricelistItemToLocal converts models.PricelistItem to LocalPricelistItem
|
||||||
func PricelistItemToLocal(item *models.PricelistItem, localPricelistID uint) *LocalPricelistItem {
|
func PricelistItemToLocal(item *models.PricelistItem, localPricelistID uint) *LocalPricelistItem {
|
||||||
partnumbers := make(LocalStringList, 0, len(item.Partnumbers))
|
|
||||||
partnumbers = append(partnumbers, item.Partnumbers...)
|
|
||||||
return &LocalPricelistItem{
|
return &LocalPricelistItem{
|
||||||
PricelistID: localPricelistID,
|
PricelistID: localPricelistID,
|
||||||
LotName: models.NormalizeLotName(item.LotName),
|
LotName: models.NormalizeLotName(item.LotName),
|
||||||
LotCategory: item.LotCategory,
|
LotCategory: item.LotCategory,
|
||||||
Price: item.Price,
|
LotDescription: item.LotDescription,
|
||||||
AvailableQty: item.AvailableQty,
|
Price: item.Price,
|
||||||
Partnumbers: partnumbers,
|
PriceMethod: item.PriceMethod,
|
||||||
|
PricePeriodDays: item.PricePeriodDays,
|
||||||
|
PriceCoefficient: item.PriceCoefficient,
|
||||||
|
ManualPrice: item.ManualPrice,
|
||||||
|
MetaPrices: item.MetaPrices,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalToPricelistItem converts LocalPricelistItem to models.PricelistItem
|
// LocalToPricelistItem converts LocalPricelistItem to models.PricelistItem
|
||||||
func LocalToPricelistItem(local *LocalPricelistItem, serverPricelistID uint) *models.PricelistItem {
|
func LocalToPricelistItem(local *LocalPricelistItem, serverPricelistID uint) *models.PricelistItem {
|
||||||
partnumbers := make([]string, 0, len(local.Partnumbers))
|
|
||||||
partnumbers = append(partnumbers, local.Partnumbers...)
|
|
||||||
return &models.PricelistItem{
|
return &models.PricelistItem{
|
||||||
ID: local.ID,
|
ID: local.ID,
|
||||||
PricelistID: serverPricelistID,
|
PricelistID: serverPricelistID,
|
||||||
LotName: local.LotName,
|
LotName: local.LotName,
|
||||||
LotCategory: local.LotCategory,
|
LotCategory: local.LotCategory,
|
||||||
Price: local.Price,
|
LotDescription: local.LotDescription,
|
||||||
AvailableQty: local.AvailableQty,
|
Price: local.Price,
|
||||||
Partnumbers: partnumbers,
|
PriceMethod: local.PriceMethod,
|
||||||
|
PricePeriodDays: local.PricePeriodDays,
|
||||||
|
PriceCoefficient: local.PriceCoefficient,
|
||||||
|
ManualPrice: local.ManualPrice,
|
||||||
|
MetaPrices: local.MetaPrices,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,98 @@ var localMigrations = []localMigration{
|
|||||||
name: "Add rental_enabled to local_projects",
|
name: "Add rental_enabled to local_projects",
|
||||||
run: addLocalProjectRentalEnabled,
|
run: addLocalProjectRentalEnabled,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "2026_07_22_pricelist_items_price_settings",
|
||||||
|
name: "Add lot_description and price settings columns to local_pricelist_items, drop unused available_qty/partnumbers",
|
||||||
|
run: addPricelistItemDescriptionAndPriceSettings,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func addPricelistItemDescriptionAndPriceSettings(tx *gorm.DB) error {
|
||||||
|
type columnInfo struct {
|
||||||
|
Name string `gorm:"column:name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var columns []columnInfo
|
||||||
|
if err := tx.Raw(`
|
||||||
|
SELECT name FROM pragma_table_info('local_pricelist_items')
|
||||||
|
WHERE name IN ('lot_description', 'price_method', 'price_period_days', 'price_coefficient', 'manual_price', 'meta_prices', 'available_qty', 'partnumbers')
|
||||||
|
`).Scan(&columns).Error; err != nil {
|
||||||
|
return fmt.Errorf("check local_pricelist_items columns: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
have := make(map[string]bool, len(columns))
|
||||||
|
for _, c := range columns {
|
||||||
|
have[c.Name] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if have["lot_description"] && have["price_method"] && have["price_period_days"] &&
|
||||||
|
have["price_coefficient"] && have["manual_price"] && have["meta_prices"] &&
|
||||||
|
!have["available_qty"] && !have["partnumbers"] {
|
||||||
|
slog.Info("local_pricelist_items already migrated to description/price-settings schema")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SQLite: recreate table without the never-populated available_qty/partnumbers
|
||||||
|
// columns, adding lot_description and the price settings columns synced from
|
||||||
|
// qt_pricelist_items (needed to render the pricelist detail UI correctly).
|
||||||
|
if err := tx.Exec(`
|
||||||
|
CREATE TABLE local_pricelist_items_new (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
pricelist_id INTEGER NOT NULL,
|
||||||
|
lot_name TEXT NOT NULL,
|
||||||
|
lot_category TEXT,
|
||||||
|
lot_description TEXT,
|
||||||
|
price REAL NOT NULL,
|
||||||
|
price_method TEXT,
|
||||||
|
price_period_days INTEGER DEFAULT 90,
|
||||||
|
price_coefficient REAL DEFAULT 0,
|
||||||
|
manual_price REAL,
|
||||||
|
meta_prices TEXT
|
||||||
|
)
|
||||||
|
`).Error; err != nil {
|
||||||
|
return fmt.Errorf("create new local_pricelist_items table: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Exec(`
|
||||||
|
INSERT INTO local_pricelist_items_new (id, pricelist_id, lot_name, lot_category, price)
|
||||||
|
SELECT id, pricelist_id, lot_name, lot_category, price
|
||||||
|
FROM local_pricelist_items
|
||||||
|
`).Error; err != nil {
|
||||||
|
return fmt.Errorf("copy data to new local_pricelist_items table: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Exec(`DROP TABLE local_pricelist_items`).Error; err != nil {
|
||||||
|
return fmt.Errorf("drop old local_pricelist_items table: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Exec(`ALTER TABLE local_pricelist_items_new RENAME TO local_pricelist_items`).Error; err != nil {
|
||||||
|
return fmt.Errorf("rename new local_pricelist_items table: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Exec(`
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_local_pricelist_items_pricelist_lot
|
||||||
|
ON local_pricelist_items(pricelist_id, lot_name)
|
||||||
|
`).Error; err != nil {
|
||||||
|
return fmt.Errorf("recreate idx_local_pricelist_items_pricelist_lot: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Exec(`
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_local_pricelist_items_pricelist_lot_unique
|
||||||
|
ON local_pricelist_items(pricelist_id, lot_name)
|
||||||
|
`).Error; err != nil {
|
||||||
|
return fmt.Errorf("recreate unique index on local_pricelist_items: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Exec(`
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_local_pricelist_items_lot_category
|
||||||
|
ON local_pricelist_items(lot_category)
|
||||||
|
`).Error; err != nil {
|
||||||
|
return fmt.Errorf("recreate idx_local_pricelist_items_lot_category: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
slog.Info("added lot_description/price settings columns to local_pricelist_items and dropped available_qty/partnumbers")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func addLocalProjectRentalEnabled(tx *gorm.DB) error {
|
func addLocalProjectRentalEnabled(tx *gorm.DB) error {
|
||||||
|
|||||||
+18
-11
@@ -120,7 +120,7 @@ type LocalConfiguration struct {
|
|||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
SyncedAt *time.Time `json:"synced_at"`
|
SyncedAt *time.Time `json:"synced_at"`
|
||||||
ConfigType string `gorm:"default:server" json:"config_type"` // "server" | "storage"
|
ConfigType string `gorm:"default:server" json:"config_type"` // "server" | "storage"
|
||||||
SyncStatus string `gorm:"default:'local'" json:"sync_status"` // 'local', 'synced', 'modified'
|
SyncStatus string `gorm:"default:'local'" json:"sync_status"` // 'local', 'synced', 'modified'
|
||||||
OriginalUserID uint `json:"original_user_id"` // UserID from MariaDB for reference
|
OriginalUserID uint `json:"original_user_id"` // UserID from MariaDB for reference
|
||||||
OriginalUsername string `gorm:"not null;default:'';index" json:"original_username"`
|
OriginalUsername string `gorm:"not null;default:'';index" json:"original_username"`
|
||||||
@@ -180,7 +180,7 @@ type LocalPricelist struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
CreatedAt time.Time `gorm:"index:idx_local_pricelists_source_created_at,priority:2,sort:desc" json:"created_at"`
|
CreatedAt time.Time `gorm:"index:idx_local_pricelists_source_created_at,priority:2,sort:desc" json:"created_at"`
|
||||||
SyncedAt time.Time `json:"synced_at"`
|
SyncedAt time.Time `json:"synced_at"`
|
||||||
IsUsed bool `gorm:"default:false" json:"is_used"` // Used by any local configuration
|
IsUsed bool `gorm:"default:false" json:"is_used"` // Used by any local configuration
|
||||||
IsActive bool `gorm:"not null;default:true;index" json:"is_active"` // Mirrors qt_pricelists.is_active
|
IsActive bool `gorm:"not null;default:true;index" json:"is_active"` // Mirrors qt_pricelists.is_active
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,13 +190,20 @@ func (LocalPricelist) TableName() string {
|
|||||||
|
|
||||||
// LocalPricelistItem stores pricelist items
|
// LocalPricelistItem stores pricelist items
|
||||||
type LocalPricelistItem struct {
|
type LocalPricelistItem struct {
|
||||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||||
PricelistID uint `gorm:"not null;index" json:"pricelist_id"`
|
PricelistID uint `gorm:"not null;index" json:"pricelist_id"`
|
||||||
LotName string `gorm:"not null" json:"lot_name"`
|
LotName string `gorm:"not null" json:"lot_name"`
|
||||||
LotCategory string `gorm:"column:lot_category" json:"lot_category,omitempty"`
|
LotCategory string `gorm:"column:lot_category" json:"lot_category,omitempty"`
|
||||||
Price float64 `gorm:"not null" json:"price"`
|
LotDescription string `gorm:"column:lot_description" json:"lot_description,omitempty"`
|
||||||
AvailableQty *float64 `json:"available_qty,omitempty"`
|
Price float64 `gorm:"not null" json:"price"`
|
||||||
Partnumbers LocalStringList `gorm:"type:text" json:"partnumbers,omitempty"`
|
|
||||||
|
// Price calculation settings, mirrored from qt_pricelist_items for display
|
||||||
|
// in the pricelist detail UI (formatPriceSettings in pricelist_detail.html).
|
||||||
|
PriceMethod string `gorm:"column:price_method" json:"price_method,omitempty"`
|
||||||
|
PricePeriodDays int `gorm:"column:price_period_days;default:90" json:"price_period_days"`
|
||||||
|
PriceCoefficient float64 `gorm:"column:price_coefficient;default:0" json:"price_coefficient"`
|
||||||
|
ManualPrice *float64 `gorm:"column:manual_price" json:"manual_price,omitempty"`
|
||||||
|
MetaPrices string `gorm:"column:meta_prices" json:"meta_prices,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (LocalPricelistItem) TableName() string {
|
func (LocalPricelistItem) TableName() string {
|
||||||
@@ -365,8 +372,8 @@ type VendorSpecLotMapping struct {
|
|||||||
// SyncLogEntry records the outcome of a single sync operation for diagnostics.
|
// SyncLogEntry records the outcome of a single sync operation for diagnostics.
|
||||||
type SyncLogEntry struct {
|
type SyncLogEntry struct {
|
||||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||||
SyncType string `gorm:"not null;index;size:32" json:"sync_type"` // components | pricelists | push | full
|
SyncType string `gorm:"not null;index;size:32" json:"sync_type"` // components | pricelists | push | full
|
||||||
Status string `gorm:"not null;size:16" json:"status"` // ok | error | skipped
|
Status string `gorm:"not null;size:16" json:"status"` // ok | error | skipped
|
||||||
ErrorText string `gorm:"size:1000" json:"error_text,omitempty"`
|
ErrorText string `gorm:"size:1000" json:"error_text,omitempty"`
|
||||||
SyncedCount int `gorm:"default:0" json:"synced_count"`
|
SyncedCount int `gorm:"default:0" json:"synced_count"`
|
||||||
StartedAt time.Time `gorm:"not null;index" json:"started_at"`
|
StartedAt time.Time `gorm:"not null;index" json:"started_at"`
|
||||||
|
|||||||
@@ -7,14 +7,3 @@ import "strings"
|
|||||||
func NormalizeLotName(s string) string {
|
func NormalizeLotName(s string) string {
|
||||||
return strings.ToUpper(strings.TrimSpace(s))
|
return strings.ToUpper(strings.TrimSpace(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lot represents existing lot table
|
|
||||||
type Lot struct {
|
|
||||||
LotName string `gorm:"column:lot_name;primaryKey;size:255" json:"lot_name"`
|
|
||||||
LotDescription string `gorm:"column:lot_description;size:10000" json:"lot_description"`
|
|
||||||
LotCategory *string `gorm:"column:lot_category;size:50" json:"lot_category"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (Lot) TableName() string {
|
|
||||||
return "lot"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -55,24 +55,20 @@ func (Pricelist) TableName() string {
|
|||||||
|
|
||||||
// PricelistItem represents a single item in a pricelist
|
// PricelistItem represents a single item in a pricelist
|
||||||
type PricelistItem struct {
|
type PricelistItem struct {
|
||||||
ID uint `gorm:"primaryKey" json:"id"`
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
PricelistID uint `gorm:"not null;index:idx_pricelist_lot" json:"pricelist_id"`
|
PricelistID uint `gorm:"not null;index:idx_pricelist_lot" json:"pricelist_id"`
|
||||||
LotName string `gorm:"size:255;not null;index:idx_pricelist_lot" json:"lot_name"`
|
LotName string `gorm:"size:255;not null;index:idx_pricelist_lot" json:"lot_name"`
|
||||||
LotCategory string `gorm:"column:lot_category;size:50" json:"lot_category,omitempty"`
|
LotCategory string `gorm:"column:lot_category;size:50" json:"lot_category,omitempty"`
|
||||||
Price float64 `gorm:"type:decimal(12,2);not null" json:"price"`
|
LotDescription string `gorm:"column:lot_description;size:10000" json:"lot_description,omitempty"`
|
||||||
PriceMethod string `gorm:"size:20" json:"price_method"`
|
Price float64 `gorm:"type:decimal(12,2);not null" json:"price"`
|
||||||
|
PriceMethod string `gorm:"size:20" json:"price_method,omitempty"`
|
||||||
|
|
||||||
// Price calculation settings (snapshot from qt_lot_metadata)
|
// Price calculation settings (snapshot from qt_lot_metadata), shown in the
|
||||||
|
// pricelist detail UI as a compact "settings" summary next to each item.
|
||||||
PricePeriodDays int `gorm:"default:90" json:"price_period_days"`
|
PricePeriodDays int `gorm:"default:90" json:"price_period_days"`
|
||||||
PriceCoefficient float64 `gorm:"type:decimal(5,2);default:0" json:"price_coefficient"`
|
PriceCoefficient float64 `gorm:"type:decimal(5,2);default:0" json:"price_coefficient"`
|
||||||
ManualPrice *float64 `gorm:"type:decimal(12,2)" json:"manual_price,omitempty"`
|
ManualPrice *float64 `gorm:"type:decimal(12,2)" json:"manual_price,omitempty"`
|
||||||
MetaPrices string `gorm:"size:1000" json:"meta_prices,omitempty"`
|
MetaPrices string `gorm:"size:1000" json:"meta_prices,omitempty"`
|
||||||
|
|
||||||
// Virtual fields for display
|
|
||||||
LotDescription string `gorm:"-" json:"lot_description,omitempty"`
|
|
||||||
Category string `gorm:"-" json:"category,omitempty"`
|
|
||||||
AvailableQty *float64 `gorm:"-" json:"available_qty,omitempty"`
|
|
||||||
Partnumbers []string `gorm:"-" json:"partnumbers,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (PricelistItem) TableName() string {
|
func (PricelistItem) TableName() string {
|
||||||
|
|||||||
@@ -234,15 +234,6 @@ func (r *PricelistRepository) GetItems(pricelistID uint, offset, limit int, sear
|
|||||||
return nil, 0, fmt.Errorf("listing pricelist items: %w", err)
|
return nil, 0, fmt.Errorf("listing pricelist items: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enrich with lot descriptions
|
|
||||||
for i := range items {
|
|
||||||
var lot models.Lot
|
|
||||||
if err := r.db.Where("lot_name = ?", items[i].LotName).First(&lot).Error; err == nil {
|
|
||||||
items[i].LotDescription = lot.LotDescription
|
|
||||||
}
|
|
||||||
items[i].Category = strings.TrimSpace(items[i].LotCategory)
|
|
||||||
}
|
|
||||||
|
|
||||||
return items, total, nil
|
return items, total, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ func newTestPricelistRepository(t *testing.T) *PricelistRepository {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("open sqlite: %v", err)
|
t.Fatalf("open sqlite: %v", err)
|
||||||
}
|
}
|
||||||
if err := db.AutoMigrate(&models.Pricelist{}, &models.PricelistItem{}, &models.Lot{}); err != nil {
|
if err := db.AutoMigrate(&models.Pricelist{}, &models.PricelistItem{}); err != nil {
|
||||||
t.Fatalf("migrate: %v", err)
|
t.Fatalf("migrate: %v", err)
|
||||||
}
|
}
|
||||||
return NewPricelistRepository(db)
|
return NewPricelistRepository(db)
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ func TestSyncPricelists_BackfillsLotCategoryForUsedPricelistItems(t *testing.T)
|
|||||||
if err := serverDB.AutoMigrate(
|
if err := serverDB.AutoMigrate(
|
||||||
&models.Pricelist{},
|
&models.Pricelist{},
|
||||||
&models.PricelistItem{},
|
&models.PricelistItem{},
|
||||||
&models.Lot{},
|
|
||||||
); err != nil {
|
); err != nil {
|
||||||
t.Fatalf("migrate server tables: %v", err)
|
t.Fatalf("migrate server tables: %v", err)
|
||||||
}
|
}
|
||||||
@@ -33,14 +32,10 @@ func TestSyncPricelists_BackfillsLotCategoryForUsedPricelistItems(t *testing.T)
|
|||||||
t.Fatalf("create server pricelist: %v", err)
|
t.Fatalf("create server pricelist: %v", err)
|
||||||
}
|
}
|
||||||
if err := serverDB.Create(&models.PricelistItem{
|
if err := serverDB.Create(&models.PricelistItem{
|
||||||
PricelistID: serverPL.ID,
|
PricelistID: serverPL.ID,
|
||||||
LotName: "CPU_A",
|
LotName: "CPU_A",
|
||||||
LotCategory: "CPU",
|
LotCategory: "CPU",
|
||||||
Price: 10,
|
Price: 10,
|
||||||
PriceMethod: "",
|
|
||||||
MetaPrices: "",
|
|
||||||
ManualPrice: nil,
|
|
||||||
AvailableQty: nil,
|
|
||||||
}).Error; err != nil {
|
}).Error; err != nil {
|
||||||
t.Fatalf("create server pricelist item: %v", err)
|
t.Fatalf("create server pricelist item: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -439,7 +439,6 @@ func newServerDBForSyncTest(t *testing.T) *gorm.DB {
|
|||||||
&models.Configuration{},
|
&models.Configuration{},
|
||||||
&models.Pricelist{},
|
&models.Pricelist{},
|
||||||
&models.PricelistItem{},
|
&models.PricelistItem{},
|
||||||
&models.Lot{},
|
|
||||||
); err != nil {
|
); err != nil {
|
||||||
t.Fatalf("migrate server test schema: %v", err)
|
t.Fatalf("migrate server test schema: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
-- Tables affected: qt_pricelist_items
|
||||||
|
-- recovery.not-started: safe to re-run; ADD COLUMN IF NOT EXISTS
|
||||||
|
-- recovery.partial: ALTER TABLE qt_pricelist_items DROP COLUMN lot_description;
|
||||||
|
-- recovery.completed: no action needed
|
||||||
|
-- verify: lot_description column missing | SELECT 1 FROM information_schema.COLUMNS WHERE table_schema=DATABASE() AND table_name='qt_pricelist_items' AND column_name='lot_description' HAVING COUNT(*)=0
|
||||||
|
|
||||||
|
-- QuoteForge previously read a LOT's description via a per-row live join into
|
||||||
|
-- `lot` (internal/repository/pricelist.go GetItems), which never made it into
|
||||||
|
-- the local sync cache. Storing the description directly on the pricelist row
|
||||||
|
-- lets QF sync it like any other pricelist field and removes the join.
|
||||||
|
ALTER TABLE qt_pricelist_items
|
||||||
|
ADD COLUMN IF NOT EXISTS lot_description VARCHAR(10000) NULL;
|
||||||
|
|
||||||
|
UPDATE qt_pricelist_items i
|
||||||
|
JOIN lot l ON l.lot_name = i.lot_name
|
||||||
|
SET i.lot_description = l.lot_description
|
||||||
|
WHERE i.lot_description IS NULL OR i.lot_description = '';
|
||||||
+43
-23
@@ -315,7 +315,7 @@
|
|||||||
<div class="flex items-baseline gap-3 mb-1">
|
<div class="flex items-baseline gap-3 mb-1">
|
||||||
<h3 class="text-base font-semibold text-gray-800">Расчёт стоимости платного тестирования / аренды</h3>
|
<h3 class="text-base font-semibold text-gray-800">Расчёт стоимости платного тестирования / аренды</h3>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-xs text-gray-500 mb-3">Черновая методика — параметры и коэффициенты могут измениться. Цена всегда за 1 неделю: разовый платёж (один раз) + еженедельный платёж (за каждую неделю теста/аренды). Цена берётся из Estimate, увеличенного на аплифт ниже. Поддержка сюда не входит.</p>
|
<p class="text-xs text-gray-500 mb-3">Черновая методика — параметры и коэффициенты могут измениться. Цена всегда за 1 неделю: разовый платёж (один раз) + еженедельный платёж (за каждую неделю теста/аренды), с НДС. Цена продажи = Estimate, увеличенный на аплифт ниже. Поддержка сюда не входит.</p>
|
||||||
<div class="flex flex-wrap items-end gap-4 mb-4">
|
<div class="flex flex-wrap items-end gap-4 mb-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-medium text-gray-700 mb-1">Аплифт к Estimate, %</label>
|
<label class="block text-xs font-medium text-gray-700 mb-1">Аплифт к Estimate, %</label>
|
||||||
@@ -333,21 +333,25 @@
|
|||||||
<table class="w-full text-sm border-collapse">
|
<table class="w-full text-sm border-collapse">
|
||||||
<thead class="bg-gray-50 text-gray-700">
|
<thead class="bg-gray-50 text-gray-700">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th class="px-3 py-2 text-center border-b">БУ</th>
|
||||||
<th class="px-3 py-2 text-left border-b">LOT</th>
|
<th class="px-3 py-2 text-left border-b">LOT</th>
|
||||||
<th class="px-3 py-2 text-left border-b">Описание</th>
|
<th class="px-3 py-2 text-left border-b">Описание</th>
|
||||||
<th class="px-3 py-2 text-left border-b">Категория</th>
|
<th class="px-3 py-2 text-left border-b">Категория</th>
|
||||||
<th class="px-3 py-2 text-right border-b">Кол-во</th>
|
<th class="px-3 py-2 text-right border-b">Кол-во</th>
|
||||||
<th class="px-3 py-2 text-center border-b">БУ</th>
|
<th class="px-3 py-2 text-right border-b">Estimate</th>
|
||||||
|
<th class="px-3 py-2 text-right border-b">Цена продажи</th>
|
||||||
<th class="px-3 py-2 text-right border-b">Разовый платёж</th>
|
<th class="px-3 py-2 text-right border-b">Разовый платёж</th>
|
||||||
<th class="px-3 py-2 text-right border-b">Еженедельный платёж</th>
|
<th class="px-3 py-2 text-right border-b">Еженедельный платёж</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="rental-body">
|
<tbody id="rental-body">
|
||||||
<tr><td colspan="7" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>
|
<tr><td colspan="9" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot id="rental-foot" class="hidden bg-gray-50 font-semibold">
|
<tfoot id="rental-foot" class="hidden bg-gray-50 font-semibold">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="px-3 py-2 text-right">Итого (с НДС):</td>
|
<td colspan="5" class="px-3 py-2 text-right">Итого:</td>
|
||||||
|
<td class="px-3 py-2 text-right" id="rental-total-estimate">—</td>
|
||||||
|
<td class="px-3 py-2 text-right" id="rental-total-sale">—</td>
|
||||||
<td class="px-3 py-2 text-right" id="rental-total-onetime">—</td>
|
<td class="px-3 py-2 text-right" id="rental-total-onetime">—</td>
|
||||||
<td class="px-3 py-2 text-right" id="rental-total-weekly">—</td>
|
<td class="px-3 py-2 text-right" id="rental-total-weekly">—</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -3358,7 +3362,7 @@ async function renderRentalTab() {
|
|||||||
const foot = document.getElementById('rental-foot');
|
const foot = document.getElementById('rental-foot');
|
||||||
const warningsEl = document.getElementById('rental-warnings');
|
const warningsEl = document.getElementById('rental-warnings');
|
||||||
if (!configUUID || cart.length === 0) {
|
if (!configUUID || cart.length === 0) {
|
||||||
body.innerHTML = '<tr><td colspan="7" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>';
|
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>';
|
||||||
foot.classList.add('hidden');
|
foot.classList.add('hidden');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3378,13 +3382,13 @@ async function renderRentalTab() {
|
|||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
body.innerHTML = '<tr><td colspan="7" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
||||||
foot.classList.add('hidden');
|
foot.classList.add('hidden');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
result = await resp.json();
|
result = await resp.json();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
body.innerHTML = '<tr><td colspan="7" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
||||||
foot.classList.add('hidden');
|
foot.classList.add('hidden');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3399,26 +3403,42 @@ async function renderRentalTab() {
|
|||||||
const descByLot = {};
|
const descByLot = {};
|
||||||
cart.forEach(c => { descByLot[(c.lot_name || '').toUpperCase()] = c.description || ''; });
|
cart.forEach(c => { descByLot[(c.lot_name || '').toUpperCase()] = c.description || ''; });
|
||||||
|
|
||||||
const rows = (result.items || []).map(item => {
|
const items = result.items || [];
|
||||||
|
if (!items.length) {
|
||||||
|
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-gray-400">Нет компонентов</td></tr>';
|
||||||
|
foot.classList.add('hidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let totEst = 0, totSale = 0;
|
||||||
|
body.innerHTML = items.map(item => {
|
||||||
const isUsed = item.condition === 'used';
|
const isUsed = item.condition === 'used';
|
||||||
const desc = descByLot[(item.lot_name || '').toUpperCase()] || '';
|
const desc = descByLot[(item.lot_name || '').toUpperCase()] || '';
|
||||||
return '<tr class="border-b">' +
|
const estTotal = item.buy_price * item.quantity;
|
||||||
'<td class="px-3 py-2">' + escapeHtml(item.lot_name) + '</td>' +
|
const saleTotal = item.price * item.quantity;
|
||||||
'<td class="px-3 py-2 text-gray-500">' + escapeHtml(desc) + '</td>' +
|
totEst += estTotal;
|
||||||
'<td class="px-3 py-2 text-gray-500">' + escapeHtml(item.category || '') + '</td>' +
|
totSale += saleTotal;
|
||||||
'<td class="px-3 py-2 text-right">' + item.quantity + '</td>' +
|
return `<tr class="pricing-row-buy">
|
||||||
'<td class="px-3 py-2 text-center">' +
|
<td class="px-3 py-1.5 text-center text-xs border-t border-gray-200">
|
||||||
'<input type="checkbox" ' + (isUsed ? 'checked' : '') +
|
<input type="checkbox" ${isUsed ? 'checked' : ''}
|
||||||
' onchange="onRentalConditionChange(\'' + escapeHtml(item.lot_name).replace(/'/g, "\\'") + '\', this.checked)" class="rounded border-gray-300">' +
|
onchange="onRentalConditionChange('${escapeHtml(item.lot_name).replace(/'/g, "\\'")}', this.checked)"
|
||||||
'</td>' +
|
class="rounded border-gray-300">
|
||||||
'<td class="px-3 py-2 text-right">' + formatMoney(item.one_time) + '</td>' +
|
</td>
|
||||||
'<td class="px-3 py-2 text-right">' + formatMoney(item.weekly) + '</td>' +
|
<td class="px-3 py-1.5 text-xs border-t border-gray-200">${escapeHtml(item.lot_name)}</td>
|
||||||
'</tr>';
|
<td class="px-3 py-1.5 text-xs text-gray-500 truncate max-w-xs border-t border-gray-200">${escapeHtml(desc)}</td>
|
||||||
|
<td class="px-3 py-1.5 text-xs text-gray-500 border-t border-gray-200">${escapeHtml(item.category || '')}</td>
|
||||||
|
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${item.quantity}</td>
|
||||||
|
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(estTotal)}</td>
|
||||||
|
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(saleTotal)}</td>
|
||||||
|
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(item.one_time)}</td>
|
||||||
|
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(item.weekly)}</td>
|
||||||
|
</tr>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
body.innerHTML = rows || '<tr><td colspan="7" class="px-3 py-8 text-center text-gray-400">Нет компонентов</td></tr>';
|
|
||||||
|
|
||||||
document.getElementById('rental-total-onetime').textContent = formatMoney(result.one_time_total);
|
document.getElementById('rental-total-estimate').textContent = formatCurrency(totEst);
|
||||||
document.getElementById('rental-total-weekly').textContent = formatMoney(result.weekly_total);
|
document.getElementById('rental-total-sale').textContent = formatCurrency(totSale);
|
||||||
|
document.getElementById('rental-total-onetime').textContent = formatCurrency(result.one_time_total);
|
||||||
|
document.getElementById('rental-total-weekly').textContent = formatCurrency(result.weekly_total);
|
||||||
foot.classList.remove('hidden');
|
foot.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,6 @@
|
|||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Артикул</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Артикул</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Категория</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Категория</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Описание</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Описание</th>
|
||||||
<th id="th-qty" class="hidden px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase">Доступно</th>
|
|
||||||
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase">Цена, $</th>
|
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase">Цена, $</th>
|
||||||
<th id="th-settings" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Настройки</th>
|
<th id="th-settings" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Настройки</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -164,16 +163,9 @@
|
|||||||
|
|
||||||
function toggleWarehouseColumns() {
|
function toggleWarehouseColumns() {
|
||||||
const stock = isStockSource();
|
const stock = isStockSource();
|
||||||
document.getElementById('th-qty').classList.toggle('hidden', true);
|
|
||||||
document.getElementById('th-settings').classList.toggle('hidden', stock);
|
document.getElementById('th-settings').classList.toggle('hidden', stock);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatQty(qty) {
|
|
||||||
if (typeof qty !== 'number') return '—';
|
|
||||||
if (Number.isInteger(qty)) return qty.toString();
|
|
||||||
return qty.toLocaleString('ru-RU', { minimumFractionDigits: 0, maximumFractionDigits: 3 });
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapeHtml(text) {
|
function escapeHtml(text) {
|
||||||
if (text === null || text === undefined) return '';
|
if (text === null || text === undefined) return '';
|
||||||
return String(text)
|
return String(text)
|
||||||
|
|||||||
Reference in New Issue
Block a user