// Screen: Compounding — formula library + cost rollup detail function Compounding({ density }) { const { useState } = React; const [selId, setSelId] = useState(FORMULAS[0].id); const sel = FORMULAS.find(f => f.id === selId); const ingCost = sel.ingredients.reduce((a, x) => a + x.cost, 0); const labor = 6.5; const totalCost = ingCost + labor; const margin = (sel.price - totalCost) / sel.price; return (
{/* Formula library */}
{FORMULAS.map(f => { const m = (f.price - f.costPerUnit - 6.5) / f.price; return ( setSelId(f.id)}> ); })}
Formula BUD Fills MTD Cost Price Margin
{f.name}
{f.category} · {f.form}
{f.bud} {f.mtdFills} ${(f.costPerUnit + 6.5).toFixed(2)} ${f.price.toFixed(2)} {(m * 100).toFixed(0)}%
{/* Detail */}
Master formula record

{sel.name}

{sel.form}
Lot
{sel.lot}
Beyond-use date
{sel.bud}
Fills MTD
{sel.mtdFills}
Most frequent prescriber
{sel.prescriber}
{sel.ingredients.map((ing, i) => ( ))}
IngredientQtyCost
{ing.name} {ing.qty} ${ing.cost.toFixed(2)}
Ingredients${ingCost.toFixed(2)}
Lab labor allocation${labor.toFixed(2)}
Price${sel.price.toFixed(2)}
Gross margin {(margin * 100).toFixed(1)}% · ${(sel.price - totalCost).toFixed(2)}/fill
); } Object.assign(window, { Compounding });