Files
PriceForge/bible/data-rules.md
Mikhail Chusavitin 7d402b756d docs: add bible/ as single source of architectural truth
- Created bible/ with hierarchical documentation (architecture, pricelists,
  vendor mapping, background tasks, data rules, patterns, API, operations, history)
- CLAUDE.md reduced to one instruction: read and follow the bible
- README.md reduced to quick start only
- Removed MEMORY.md and csv_export.md (content consolidated into bible/)
- Fixed stale facts found during audit: weighted_avg (not weighted_median),
  correct API route names (/export-csv, /recalculate-all)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 14:16:47 +03:00

1.4 KiB

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: load lot.lot_category for all components.
  2. Warehouse: load lot.lot_category for all positions.
  3. Persist into lot_category column of qt_pricelist_items.

Model

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: 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).