Skip to content

F25 (part 1): Product catalog — egg products, grade mappings, packed-unit conversions #97

Closed

Description

@mforce

Spec §10.1–10.2 + §9.7. Phase 1.1 item "Product catalog with egg products (replace raw grade strings)", split in two sequential PRs to keep review and rollback sane:

  • Part 1 (this issue): the catalog itself — products, egg-grade mappings, packed-unit conversions. No sales changes.
  • Part 2 (filed after part 1 merges): sales order items switch from raw eggGradeId to productId + unit + snapshotted base_unit_factor/quantity_base, with data migration of existing lines.

Scope (part 1)

Domain:

  • Product: name, productType (egg only usable now; enum carries the future values from §10.1), defaultUnit, defaultPriceMinorUnits?, currency snapshot, active, notes, Version. Aggregate with Version concurrency per AGENTS.md.
  • ProductEggGradeMapping: product → egg grade. Phase 1: exactly one mapping per egg product (multi-grade products like mixed cartons come later); unique per product.
  • EggUnitConversion: unitCode (individual/dozen/flat/tray/carton/case/other), eggsPerUnit, active. Account-level for the MVP (farm override column reserved per spec but single-farm today). Seed defaults on account creation: individual=1, dozen=12, flat/tray=30, carton=12, case=360 — farm-editable because carton/case sizes are market-specific (§9.7: no implicit fixed factors).

API (/api/v1/products, /api/v1/egg-unit-conversions):

  • Products: create/update/deactivate + list. Writes AdminOnly (catalog is configuration, F19 principle); reads open (workers see product names when selling later).
  • Conversions: list open; update AdminOnly. eggsPerUnit ≥ 1. No delete — deactivate only; individual is not editable (always 1).
  • Audit events on catalog writes (Product.Create/Update/Deactivate, EggUnitConversion.Update) per §18.
  • Egg products must reference an existing, active egg grade; mapping travels with product create/update.

SPA: admin Products page (list + create + edit + deactivate, mapping picker sourced from grades, conversions editor). GLOSSARY + Help sync.

Tests

  • CRUD + validation (duplicate name per account, mapping to missing/inactive grade, eggsPerUnit < 1)
  • Version concurrency parallel race (delta exactly 1)
  • Worker 403 on writes, 200 on reads
  • Tenant isolation
  • Seeded conversion defaults present for a new account
  • Audit events written with the writes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions