Repository navigation
Closed
Labels
area:apiAPI/endpoint layerAPI/endpoint layerarea:domainDomain layerDomain layerarea:frontendReact/Vite web clientReact/Vite web clientenhancementNew feature or requestNew feature or requestepic-1.1sliceThin vertical work itemThin vertical work item
Description
Spec §10.5 + §9.7 conversion rules. Second half of the Phase 1.1 product-catalog item; builds on the part-1 catalog (#97, PR #98).
Scope
Domain / persistence:
SalesOrderItemgains:ProductId,ProductTypeSnapshot(spec §10.5),Unit,BaseUnitFactor(eggs-per-unit snapshotted at line creation — §9.7: a later carton/case redefinition must never reinterpret existing orders),QuantityBase(always individual eggs:quantity × factor).Quantitybecomes the unit count.- Data migration: for each egg grade referenced by existing order items, auto-create a product (grade name, unit Egg, mapped to that grade) if none maps to it yet; backfill existing lines with that product,
Unit=Egg,BaseUnitFactor=1,QuantityBase=Quantity. Frozen history — no money changes.
Behavior:
- Add-item takes
productId+quantity+unit(defaults to the product'sDefaultUnit). Factor resolves from the account's activeEggUnitConversionrow at line creation and is snapshotted; missing/inactive conversion → 422. - Product must be active and an egg product; allocation reserves
QuantityBaseeggs FIFO from lots of the product's mapped grade (mapping resolved at line creation — later re-pointing never rewrites existing lines). - Unit price defaults from the product's default price (per selling unit) when the request omits it; stock/overselling guard runs on
QuantityBase. - Confirm/void/allocation release logic unchanged otherwise; version race tests per AGENTS.md.
SPA (SalesPage): line entry switches from grade picker to product picker (active products) + unit + quantity; shows resolved eggs-per-unit and line total; price prefilled from the product default, editable.
Sync: CSV export sales-order-items dataset gains the new columns; GLOSSARY (Product line, quantity_base) + Help (Customers & sales section) + Help TOC; audit filter untouched (no new actions).
Tests
- Line snapshots: carton=12 at sale, redefine carton=30, old line keeps factor 12 / new line gets 30
- quantity_base math + FIFO allocation from the mapped grade's lots; overselling guard on eggs
- Product inactive / non-mapped / missing conversion → 422
- Migration backfill: pre-existing grade-lines get auto-created products, factor 1, unchanged totals
- Grade re-point after sale: old lines keep the original allocation
- Worker can still record/confirm orders (production-side open); race tests
Metadata
Metadata
Assignees
Labels
area:apiAPI/endpoint layerAPI/endpoint layerarea:domainDomain layerDomain layerarea:frontendReact/Vite web clientReact/Vite web clientenhancementNew feature or requestNew feature or requestepic-1.1sliceThin vertical work itemThin vertical work item
Activity