# ADR-0006 — Milk (cat 1) and medicine (cat 8) special-cased in statistics

> Produced by the Reversa **Detective** (phase: interpretation) · doc_level: `complete`
> Retroactive ADR reconstructed from Git history: MR!16 "Customer | Fixed summary wrong for orders without some categories" (`8a91e71`), MR!17 "Customer | Fixed summary medicine wrong" (`6e2438b`), and `refactor(order): extract hardcoded statistic category_id into class vars` (`7f49a21`).

- **Status:** Accepted (as-built) 🟢
- **Confidence:** 🟢 CONFIRMED

## Context

The owner tracks two product categories separately for business reasons — **milk (Sữa, category id 1)** and **medicine (Thuốc, category id 8)** — while treating all other categories as a single aggregate.

## Decision

Hard-code category ids 1 and 8 as their own buckets in the statistics rollup (`Order::summaryLogging`) and in the read path (`CustomerController::statis`); collapse the remainder into "other". After bugfixes for orders missing some categories and a medicine-specific miscount, the magic ids were extracted from inline literals into class variables (`7f49a21`) to reduce the risk of them drifting apart between the write and read paths.

## Consequences

- 🟢 Two priority categories are reported distinctly with minimal schema (no per-category config table).
- 🟡 The special cases are **coupled to specific database ids** (1, 8). Reseeding categories or changing those ids silently breaks the rollup semantics.
- 🟢 The refactor to class vars is a mitigation, not a cure — the coupling to ids 1/8 remains by design.
- 🟢 Two production bugs (`8a91e71`, `6e2438b`) trace directly to this special-casing, confirming it as a genuine maintenance hotspot.
