From fdfaa4503d9f02ec2744b1aa1dde92a59391e862 Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 7 May 2026 21:29:51 -0400 Subject: [PATCH] Fix inventory list: rename THC% column to THC, show mg for edibles, fix ct on hand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Column now shows "75.4%" for flower/concentrate and "200 mg" for edibles. Discrete "on hand" sums raw counts instead of count × unitWeight, fixing the inflated value (was showing 1000 instead of 5 for edibles). Co-Authored-By: Claude Opus 4.6 --- web/src/views/Inventory.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/web/src/views/Inventory.tsx b/web/src/views/Inventory.tsx index f8aa433..a7980ca 100644 --- a/web/src/views/Inventory.tsx +++ b/web/src/views/Inventory.tsx @@ -296,7 +296,7 @@ function Segmented({ } const COL_SORT: (SortKey | null)[] = [null, "name", null, null, "thc", "price", "remaining", "audit", null]; -const COL_LABELS = ["", "Item", "Brand", "Shop", "THC %", "Price", "Remaining", "Last checked", "Bin"]; +const COL_LABELS = ["", "Item", "Brand", "Shop", "THC", "Price", "Remaining", "Last checked", "Bin"]; function HeaderRow({ sortBy, onSort }: { sortBy: SortKey; onSort: (k: SortKey) => void }) { return ( @@ -358,13 +358,12 @@ function GroupHeader({ items: Item[]; }; }) { - // Aggregate remaining: bulk uses estimatedRemaining; discrete uses unitWeight × count. + // Aggregate remaining: bulk uses estimatedRemaining; discrete uses raw count. // Counts use status === "active" only — archived rows shouldn't inflate "on hand." const active = group.items.filter((i) => i.status === "active"); const totalRemaining = active.reduce((s, i) => { if (i.kind === "bulk") return s + helpers.estimatedRemaining(i, TODAY_STR); - const cur = i.countLastAudit ?? i.countOriginal; - return s + cur * (i.unitWeight || 0); + return s + (i.countLastAudit ?? i.countOriginal); }, 0); const lastBuy = group.items.reduce((max, i) => { const t = +new Date(i.purchaseDate); @@ -495,7 +494,11 @@ function ItemRow({
{helpers.brandName(data, i.brandId)}
{helpers.shopName(data, i.shopId)}
-
{i.thc.toFixed(1)}
+
+ {TYPES.find((t) => t.id === i.type)?.showCannabinoidPct !== false + ? `${i.thc.toFixed(1)}%` + : `${i.unitWeight} mg`} +
{fmt.money(i.price)}