Fix inventory list: rename THC% column to THC, show mg for edibles, fix ct on hand
Build and push image / build (push) Successful in 1m1s

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 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 21:29:51 -04:00
parent 9aea9535e6
commit fdfaa4503d
+8 -5
View File
@@ -296,7 +296,7 @@ function Segmented<T extends string>({
}
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({
</div>
<div style={{ color: "var(--ink-2)" }}>{helpers.brandName(data, i.brandId)}</div>
<div style={{ color: "var(--ink-3)", fontSize: 12 }}>{helpers.shopName(data, i.shopId)}</div>
<div style={{ fontFamily: "var(--mono)", color: "var(--ink-2)" }}>{i.thc.toFixed(1)}</div>
<div style={{ fontFamily: "var(--mono)", color: "var(--ink-2)" }}>
{TYPES.find((t) => t.id === i.type)?.showCannabinoidPct !== false
? `${i.thc.toFixed(1)}%`
: `${i.unitWeight} mg`}
</div>
<div style={{ fontFamily: "var(--mono)" }}>{fmt.money(i.price)}</div>
<div
style={{