Harden pricelist formation and document architecture decisions
This commit is contained in:
@@ -5,6 +5,51 @@
|
||||
|
||||
---
|
||||
|
||||
## 2026-02-20: Pricelist Formation Hardening (Estimate/Warehouse/Meta)
|
||||
|
||||
### Decision
|
||||
|
||||
Hardened pricelist formation rules to remove ambiguity and prevent silent data loss in UI/API.
|
||||
|
||||
### What changed
|
||||
|
||||
- `estimate` snapshot now explicitly excludes hidden components (`qt_lot_metadata.is_hidden = 1`).
|
||||
- Category snapshot in `qt_pricelist_items.lot_category` now always has a deterministic fallback:
|
||||
`PART_` is assigned even when a LOT row is missing in `lot`.
|
||||
- `PricelistItem` JSON contract was normalized to a single category field
|
||||
(`LotCategory -> json:"category"`), removing duplicate JSON-tag ambiguity.
|
||||
- Meta-price source expansion now always includes the base LOT, then merges `meta_prices`
|
||||
sources with deduplication (exact + wildcard overlaps).
|
||||
|
||||
### Rationale
|
||||
|
||||
- Prevent hidden/ignored components from leaking into estimate pricelists.
|
||||
- Keep frontend category rendering stable for all items.
|
||||
- Avoid non-deterministic JSON serialization when duplicate tags are present.
|
||||
- Ensure meta-article pricing includes self-history and does not overcount duplicate sources.
|
||||
|
||||
### Constraints
|
||||
|
||||
- `estimate` pricelist invariant: `current_price > 0 AND is_hidden = 0`.
|
||||
- `category` in API must map from persisted `qt_pricelist_items.lot_category`.
|
||||
- Missing category source must default to `PART_`.
|
||||
- Meta source list must contain each LOT at most once.
|
||||
|
||||
### Files
|
||||
|
||||
- Model: `internal/models/pricelist.go`
|
||||
- Estimate/Warehouse snapshot service: `internal/services/pricelist/service.go`
|
||||
- Pricing handler/meta expansion: `internal/handlers/pricing.go`
|
||||
- Pricing service/meta expansion: `internal/services/pricing/service.go`
|
||||
- Tests:
|
||||
- `internal/services/pricelist/service_estimate_test.go`
|
||||
- `internal/services/pricelist/service_warehouse_test.go`
|
||||
- `internal/handlers/pricing_meta_expand_test.go`
|
||||
- `internal/services/pricing/service_meta_test.go`
|
||||
- `internal/services/stock_import_test.go`
|
||||
|
||||
---
|
||||
|
||||
## 2026-02-20: Seen Registry Deduplication by Partnumber
|
||||
|
||||
### Decision
|
||||
|
||||
Reference in New Issue
Block a user