# Data Rules ## Component Categories (lot_category) ### Source Categories are **always** taken from `lot.lot_category` (table `lot`). **NOT** from `qt_lot_metadata`. **NOT** derived from the LOT name or article name. ### When creating pricelists 1. **Estimate**: include only components with `current_price > 0` and `is_hidden = 0`, then load `lot.lot_category`. 2. **Warehouse**: load `lot.lot_category` for all positions. 3. Persist into `lot_category` column of `qt_pricelist_items`. ### Model ```go type PricelistItem struct { LotCategory *string `gorm:"column:lot_category;size:50" json:"category,omitempty"` // JSON field is "category" for the frontend } ``` ### Rules - Category is **not** a virtual field — it is persisted to DB when the pricelist is created. - JOIN with `lot` is only needed for `lot_description`; category is already in `qt_pricelist_items`. - Default value when category is absent in source or LOT row is missing: `PART_`. --- ## Price Method - Warehouse pricelist: `price_method` = `"weighted_avg"` (quantity-weighted average). - Estimate pricelist: method determined by per-component settings. --- ## Warehouse: Filtering by lot_partnumbers **Rule (CRITICAL)**: only positions with a matching record in `lot_partnumbers` are included in the warehouse pricelist. Unmapped partnumbers are completely excluded. --- ## Component Data Source - Source: MariaDB (not SQLite). - `handlers/component.go` uses `componentService.List()` (MariaDB).