Add price refresh functionality to configurator

- Add price_updated_at field to qt_configurations table to track when prices were last updated
- Add RefreshPrices() method in configuration service to update all component prices with current values from database
- Add POST /api/configs/:uuid/refresh-prices API endpoint for price updates
- Add "Refresh Prices" button in configurator UI next to Save button
- Display last price update timestamp in human-readable format (e.g., "5 min ago", "2 hours ago")
- Create migration 004_add_price_updated_at.sql for database schema update
- Update CLAUDE.md documentation with new API endpoint and schema changes
- Add MIGRATION_PRICE_REFRESH.md with detailed migration instructions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 10:31:00 +03:00
parent 3132ab2fa2
commit f31ae69233
8 changed files with 310 additions and 18 deletions

View File

@@ -118,8 +118,11 @@ CREATE TABLE qt_configurations (
name VARCHAR(200) NOT NULL,
items JSON NOT NULL, -- [{"lot_name": "CPU_AMD_9654", "quantity": 2, "unit_price": 11500}]
total_price DECIMAL(12,2),
custom_price DECIMAL(12,2), -- User-defined target price (for discounts)
notes TEXT,
is_template BOOLEAN DEFAULT FALSE,
server_count INT DEFAULT 1, -- Number of servers in configuration
price_updated_at TIMESTAMP, -- Last time prices were refreshed
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES qt_users(id)
);
@@ -268,12 +271,13 @@ POST /api/export/xlsx → {"items": [...], "name": "Config 1"} → XLSX file
### Configurations
```
GET /api/configs → list user's configurations
POST /api/configs → save new configuration
GET /api/configs/:uuid → get by UUID
PUT /api/configs/:uuid → update
DELETE /api/configs/:uuid → delete
GET /api/configs/:uuid/export → export as JSON
GET /api/configs → list user's configurations
POST /api/configs → save new configuration
GET /api/configs/:uuid → get by UUID
PUT /api/configs/:uuid → update
POST /api/configs/:uuid/refresh-prices → refresh prices for all components
DELETE /api/configs/:uuid → delete
GET /api/configs/:uuid/export → export as JSON
```
### Pricing Admin (requires role: pricing_admin or admin)