3.3 KiB
3.3 KiB
Pricelists
Types
PriceForge supports three pricelist types (source field):
| Type | Data source | Status |
|---|---|---|
estimate |
qt_lot_metadata — snapshot of current prices |
Active |
warehouse |
stock_log — stock import data |
Active |
competitor |
B2B marketplace APIs | Reserved |
Estimate
Source: snapshot of current component prices from qt_lot_metadata.
Filter:
- Include only rows with
current_price > 0. - Exclude hidden rows (
is_hidden = 1).
Stores:
price_period_days— price calculation windowprice_coefficient— markup coefficientmanual_price— manually set pricemeta_prices— historical prices
Purpose: primary pricelist for calculations and estimates.
Categories: loaded from lot.lot_category for each component.
Warehouse
Source: stock_log (stock import records).
Rules (CRITICAL):
- Only mapped partnumbers — only positions with a record in
lot_partnumbersare included. Unmapped partnumbers must not appear in any form. - No pricing settings — do not load from
lot_metadata: noprice_period_days,price_coefficient,manual_price,meta_prices. - Price method: always
weighted_avg(quantity-weighted average). - Field
price_methodalways contains"weighted_avg". - These are raw stock prices without additional processing.
Categories: loaded from lot.lot_category.
Implementation: internal/warehouse/snapshot.go
Competitor
Reserved for future integration with B2B marketplace APIs (automated quotes).
Data Model
type Pricelist struct {
ID uint `gorm:"primaryKey"`
Version string
Source string // "estimate" | "warehouse" | "competitor"
// ...
}
type PricelistItem struct {
ID uint `gorm:"primaryKey"`
PricelistID uint
LotName string `gorm:"size:255"`
Price float64 `gorm:"type:decimal(12,2)"`
LotCategory *string `gorm:"column:lot_category;size:50" json:"category,omitempty"`
// Virtual fields (via JOIN or programmatically)
LotDescription string `gorm:"-:migration" json:"lot_description,omitempty"`
AvailableQty *float64 `gorm:"-" json:"available_qty,omitempty"`
Partnumbers []string `gorm:"-" json:"partnumbers,omitempty"`
}
gorm:"-:migration"— no DB column created, but mapped on SELECT.gorm:"-"— fully ignored in all DB operations.
Categories (lot_category)
- Source:
lot.lot_categorycolumn in tablelot. - NOT from
qt_lot_metadata. - NOT derived from LOT name.
- Persisted into
qt_pricelist_items.lot_categorywhen pricelist is created. - JSON field name:
"category". - JOIN with
lotis only needed forlot_description; category is already inqt_pricelist_items. - Default value when category is missing:
PART_.
Pricelist Creation (background task)
Creation runs via Task Manager. Handler returns task_id; frontend polls.
POST /api/pricelists/create
→ { "task_id": "uuid" }
→ polling GET /api/tasks/:id
→ { "status": "completed", "result": { "pricelist_id": 42 } }
Task type: TaskTypePricelistCreate.
Implementation:
- Service:
internal/services/pricelist/service.go - Warehouse calc:
internal/warehouse/snapshot.go - Handler:
internal/handlers/pricelist.go