formlab-mcp 0.7.10 → 0.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/data.js CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  import { readFileSync, watch } from 'node:fs';
10
10
  import { resolve } from 'node:path';
11
+ import { appFlatten } from './theoretical.js';
11
12
 
12
13
  // Module-level mutable store — re-assigned on hot-reload when the
13
14
  // watched file changes. Tools read from getStore() to always see
@@ -144,6 +145,12 @@ export function resolveById(collection, idOrUid) {
144
145
  // Walks sub-formula rows recursively (cap depth to break cycles).
145
146
  // Mirrors the algorithm in FormLab's js/nesting.js _flattenComposition.
146
147
  export function flattenComposition(formulation, depth = 0) {
148
+ // 27q: the app's own engine first, so pieces and "Not mixed in" parts read as the app shows them (a candle's
149
+ // 1 wick beside 92 % wax and 8 % fragrance is not 1 g of 101). The code below is the fallback.
150
+ if (depth === 0 && formulation && Array.isArray(formulation.composition)) {
151
+ const app = appFlatten(getStore().db, formulation);
152
+ if (app && Array.isArray(app.rows)) return app;
153
+ }
147
154
  const MAX_DEPTH = 5;
148
155
  if (!formulation || !Array.isArray(formulation.composition) || depth > MAX_DEPTH) {
149
156
  return { rows: [] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formlab-mcp",
3
- "version": "0.7.10",
3
+ "version": "0.7.12",
4
4
  "mcpName": "io.github.juliu1980/formlab-mcp",
5
5
  "description": "Read-only Model Context Protocol server for FormLab. Lets Claude and other MCP clients read and analyze your FormLab data, from a local export file or your live cloud workspace.",
6
6
  "homepage": "https://formvix.com/mcp",
package/server.json CHANGED
@@ -2,13 +2,13 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.juliu1980/formlab-mcp",
4
4
  "description": "Read-only MCP server for FormLab formulation data: a local export file or your live cloud workspace.",
5
- "version": "0.7.10",
5
+ "version": "0.7.12",
6
6
  "websiteUrl": "https://formvix.com/mcp",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "formlab-mcp",
11
- "version": "0.7.10",
11
+ "version": "0.7.12",
12
12
  "runtimeHint": "npx",
13
13
  "transport": {
14
14
  "type": "stdio"
package/theoretical.js CHANGED
@@ -50,6 +50,23 @@ const EPILOGUE = `
50
50
  // vendored; this is the same walk over the flattened leaves.
51
51
  // The viewer's display-currency preference lives in the browser; here there is none, so costs read in USD unless the
52
52
  // formula's target price names a currency (0.6.86). Labor, overhead and EU reference intakes: 0.6.87.
53
+ function __flat(fj) {
54
+ var f = JSON.parse(fj);
55
+ var name = function (id) { var i = (db.ingredients || []).find(function (x) { return x && x.id === id; }); return (i && i.name) || id; };
56
+ var r = _flattenComposition(f);
57
+ var merged = {}, order = [];
58
+ (r.rows || []).forEach(function (x) {
59
+ if (!x || !x.ingredientId || !(x._weight > 0)) return;
60
+ if (merged[x.ingredientId]) { merged[x.ingredientId].weightFraction += x._weight; return; }
61
+ merged[x.ingredientId] = { ingredientId: x.ingredientId, ingredientName: name(x.ingredientId), weightFraction: x._weight, role: x.role || '' };
62
+ order.push(x.ingredientId);
63
+ });
64
+ var comp = (f.composition || []).filter(function (c) { return c && (c.ingredientId || c.formulationId); });
65
+ var aside = typeof flCountedAside === 'function' ? flCountedAside(comp) : new Set();
66
+ var counted = comp.filter(function (c) { return aside.has(c); }).map(function (c) { return { ingredientId: c.ingredientId, ingredientName: name(c.ingredientId), amount: c.amount, unit: c.unit || '' }; });
67
+ var unresolved = (r.unresolved || []).filter(function (u) { return u && u.ingredientId; }).map(function (u) { return { ingredientId: u.ingredientId, ingredientName: name(u.ingredientId), reason: u.reason, unit: u.unit || '' }; });
68
+ return JSON.stringify({ rows: order.map(function (k) { return merged[k]; }), countedAside: counted, unresolved: unresolved });
69
+ }
53
70
  var localStorage = { getItem: function () { return null; }, setItem: function () {} };
54
71
  // The app's HTML escaper (js/utils.js, not vendored): the EU list builds its bold version with it.
55
72
  function esc(v) { return String(v == null ? '' : v).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }
@@ -168,6 +185,17 @@ function contextFor(db) {
168
185
  return ctx;
169
186
  }
170
187
 
188
+ // A formula's leaf wt-fractions by the app's own engine (js/nesting.js _flattenComposition, 27q): rows counted in
189
+ // pieces convert through the ingredient's weight per piece, and a part marked "Not mixed in" beside % rows (1 wick)
190
+ // sits outside the 100% (countedAside) instead of reading as 1 g or 1 %. null when the engine can't run.
191
+ export function appFlatten(db, formulation) {
192
+ try {
193
+ const ctx = contextFor(db);
194
+ vm.runInContext('var __fj = ' + JSON.stringify(JSON.stringify(formulation)) + ';', ctx);
195
+ return JSON.parse(vm.runInContext('__flat(__fj)', ctx, { timeout: 2000 }));
196
+ } catch (_) { return null; }
197
+ }
198
+
171
199
  // An ingredient's reactive groups as the app reads them (js/reactive.js): [{ group, label, datasheet ("AHEW 42.6
172
200
  // g/eq"), meqPerG, entered: { basis, value } }], plus the rows it ignores and why (ignored: true, why).
173
201
  export function reactiveGroups(db, id) {
@@ -154,6 +154,10 @@ const get_formulation = {
154
154
  role: c.role || '',
155
155
  })),
156
156
  compositionFlattenedWtPct: flatRows,
157
+ // Counted beside a % recipe, outside its 100 % (a wick marked "Not mixed in"): per piece of product (27q).
158
+ ...(flat.countedAside && flat.countedAside.length ? { countedAside: flat.countedAside.map(c => ({ ingredientId: c.ingredientId, ingredient: c.ingredientName, amount: c.amount, unit: c.unit })) } : {}),
159
+ // Rows the wt-% can't place: a piece with no weight per piece, a volume with no density.
160
+ ...(flat.unresolved && flat.unresolved.length ? { compositionUnresolved: flat.unresolved.map(u => ({ ingredient: u.ingredientName, unit: u.unit, reason: u.reason === 'no-weight' ? 'counted in pieces with no weight per piece' : u.reason })) } : {}),
157
161
  stepCount: (f.steps || []).length,
158
162
  // The actual procedure — the tool description promises "step procedure",
159
163
  // so return the ordered steps, not just the count. Keep only the
@@ -69,6 +69,8 @@ function _trimIngredient(i) {
69
69
  densityUnit: i.densityUnit || (i.density != null ? 'kg/L' : null),
70
70
  // What one piece weighs (a wick): a recipe row counted in pieces converts through it (0.7.8).
71
71
  ...(_pieceKg(i) ? { weightPerPiece: { value: Number(i.unitMass.value), unit: i.unitMass.unit } } : {}),
72
+ // A part per unit (a wick, a jar) left out of a recipe's 100 % and counted per piece (27q).
73
+ ...(i.notMixedIn ? { notMixedIn: true } : {}),
72
74
  cost: (cost && cost.value != null && cost.value !== '')
73
75
  ? { value: cost.value, currency: cost.currency || 'USD', unit: cost.unit || 'kg' } : null,
74
76
  costPerKg: _costPerKg(i),
package/tools/lab.js CHANGED
@@ -394,7 +394,7 @@ const list_batches = {
394
394
  const get_batch = {
395
395
  definition: {
396
396
  name: 'get_batch',
397
- description: 'Get full details for a single batch including the raw lots it drew (lotsUsed: lot number, quantity, and the status of each lot now, with holdReason for a lot on hold), hold (now) and holdHistory (every hold with its release: when, by whom, and the note, e.g. "Released with lot ETH-1"), its actual composition (as-prepared, when logged), child samples, lineage (parent / sub-blend parents), and — treating the batch as a finished-goods lot — its storage `location` and finished-goods `stockLedger` (shipments out + adjustments; on-hand = produced − sample pulls − sub-batch draws + Σ ledger). Plus finished-product density + actual volume (measured directly or derived as actual mass ÷ measured density — never summed from per-ingredient volumes). Accepts internal id or UID. Also returns `theoreticalParameters` computed on the batch as made (its actual composition when logged — `basis: "actual"` — else the recipe of its formula), with the batch parameter list when it overrides the one on the formula; same fields as get_formulation. `reactiveBalance` is the same as get_formulation\'s, on what was weighed (basis "as weighed"), e.g. a soap batch\'s superfat and lye excess.',
397
+ description: 'Get full details for a single batch including the raw lots it drew (lotsUsed: lot number, quantity, and the status of each lot now, with holdReason for a lot on hold), hold (now) and holdHistory (every hold with its release: when, by whom, and the note, e.g. "Released with lot ETH-1"), certificates (each Certificate of Analysis as issued and saved: number, when, by whom, customer, PO, verdict, override reason, the results it printed; a shipment\'s coaNumber names the one it went with), its actual composition (as-prepared, when logged), child samples, lineage (parent / sub-blend parents), and — treating the batch as a finished-goods lot — its storage `location` and finished-goods `stockLedger` (shipments out + adjustments; on-hand = produced − sample pulls − sub-batch draws + Σ ledger). Plus finished-product density + actual volume (measured directly or derived as actual mass ÷ measured density — never summed from per-ingredient volumes). Accepts internal id or UID. Also returns `theoreticalParameters` computed on the batch as made (its actual composition when logged — `basis: "actual"` — else the recipe of its formula), with the batch parameter list when it overrides the one on the formula; same fields as get_formulation. `reactiveBalance` is the same as get_formulation\'s, on what was weighed (basis "as weighed"), e.g. a soap batch\'s superfat and lye excess.',
398
398
  inputSchema: {
399
399
  type: 'object',
400
400
  properties: {
@@ -443,6 +443,8 @@ const get_batch = {
443
443
  ...(e.customer ? { customer: e.customer } : {}),
444
444
  ...(Array.isArray(e.qcOpen) && e.qcOpen.length ? { shippedWithQcOpen: e.qcOpen, qcReason: e.qcReason || null } : {}),
445
445
  // 2 Dec: the CoA it went with (null = none issued), and no ingredient lots recorded. Older shipments carry neither.
446
+ // 0.7.12: the saved certificate it went with (its number in certificates).
447
+ ...(e.kind === 'shipment' && e.coaId ? { coaNumber: ((Array.isArray(b.coas) ? b.coas : []).find(c => c && c.id === e.coaId) || {}).n ?? null } : {}),
446
448
  ...(e.kind === 'shipment' && 'coaAt' in e ? { coaIssuedAt: e.coaAt || null, ...(e.coaCustomer ? { coaCustomer: e.coaCustomer } : {}), ...(e.coaPo ? { coaPo: e.coaPo } : {}), noLotsRecorded: !!e.noLots } : {}),
447
449
  })),
448
450
  shippedQty: (Array.isArray(b.stockLedger) ? b.stockLedger : []).reduce((s, e) => e.kind === 'shipment' ? s + Math.abs(parseFloat(e.delta) || 0) : s, 0),
@@ -450,6 +452,14 @@ const get_batch = {
450
452
  hold: (b.fgHold && b.fgHold.at && !b.fgHold.releasedAt) ? { since: b.fgHold.at, by: b.fgHold.by || '', reason: b.fgHold.reason || '' } : null,
451
453
  // 0.6.94: every hold this batch had, oldest first, with its release (when, by whom, the note: "Released with lot X").
452
454
  holdHistory: _batchHoldHistory(getStore().db, b),
455
+ // 0.7.12: each Certificate of Analysis as issued (saved on the batch; a reprint shows the same document), oldest first.
456
+ certificates: (Array.isArray(b.coas) ? b.coas : []).filter(c => c && c.id).map(c => ({
457
+ number: c.n ?? null, issuedAt: c.issuedAt || null, issuedBy: c.issuedBy || '', product: c.product || '', customer: c.customer || '', po: c.po || '',
458
+ resultsUpTo: c.upTo || null, verdict: c.conforms === false ? 'does not conform' : c.untested ? 'not tested (override)' : c.conforms === true ? 'conforms' : 'reported',
459
+ ...(c.override ? { overrideReason: c.override } : {}), ...(Array.isArray(c.notTested) && c.notTested.length ? { notTested: c.notTested } : {}),
460
+ results: (c.rows || []).map(r => ({ parameter: r.name, ...(r.cond ? { conditions: r.cond } : {}), value: r.value, unit: r.unit || '', spec: r.spec || null, status: r.status || 'reported', testReport: r.testUid || null, testDate: r.testDate || null, ...(r.doubt ? { inDoubt: r.doubt } : {}) })),
461
+ sourceReports: c.sources || [],
462
+ })),
453
463
  // 0.6.92: the raw lots this batch drew (net of returns), each with its status now. A lot on hold
454
464
  // here ("status: hold" + holdReason) is why a recall reaches this batch, held or not.
455
465
  lotsUsed: _batchLotsUsed(getStore().db, b.id),
package/vendor/cost.js CHANGED
@@ -842,6 +842,60 @@ function flIsPieceUnit(u) {
842
842
  const hit = t => Object.keys(t).some(k => k === raw || k.toLowerCase() === lower);
843
843
  return !hit(MASS_TO_KG) && !hit(VOL_TO_L) && !(typeof LENGTH_TO_M !== 'undefined' && hit(LENGTH_TO_M));
844
844
  }
845
+ // A row counted in pieces whose ingredient is marked "Not mixed in" (a wick, a jar: a part per unit, not a share of the
846
+ // mix) sits outside the mix (Jun, 3 Dec): not a share of the whole, not part of the total, the mixed-basis check or the
847
+ // per-kg cost; it goes into the batch as counted, and its price per piece of product. In a wt% or vol% recipe and, since
848
+ // 27c ("Yes, everywhere"), in a recipe by weight too. Half an apple is mixed in: it stays in. Returns the set of such
849
+ // rows; empty when nothing else is mixed (a kit of a jar, a lid and a label stays as written).
850
+ function flCountedAside(comp) {
851
+ comp = (comp || []).filter(c => c && (c.ingredientId || c.formulationId));
852
+ const frac = c => { const u = String(c.unit || 'wt%').trim().toLowerCase(); return u === '%' || u.startsWith('wt') || u.startsWith('vol'); };
853
+ const notMixed = c => { const ing = (typeof db !== 'undefined' && db && db.ingredients || []).find(i => i.id === c.ingredientId); return !!(ing && ing.notMixedIn); };
854
+ const aside = comp.filter(c => !c.formulationId && c.ingredientId && !frac(c) && flIsPieceUnit(c.unit) && notMixed(c));
855
+ return aside.length && aside.length < comp.length ? new Set(aside) : new Set();
856
+ }
857
+ // How many pieces of product a batch makes, for parts counted per piece beside a % recipe (1 wick per candle): the
858
+ // batch's own count (12 candles), else its mass over the formula's fill (Pricing per piece: 226.8 g), else 1 (3 Dec).
859
+ function flProductUnits(f, batchKg, count) {
860
+ const n = parseFloat(count);
861
+ if (isFinite(n) && n > 0) return n;
862
+ const fl = f && f.pricing && f.pricing.fill, v = fl ? parseFloat(fl.value) : NaN;
863
+ if (batchKg > 0 && isFinite(v) && v > 0) {
864
+ let fillKg = null;
865
+ if (fl.unit in MASS_TO_KG) fillKg = v * MASS_TO_KG[fl.unit];
866
+ else if (fl.unit in VOL_TO_L) { const d = typeof _rolledUpDensity === 'function' ? _rolledUpDensity(f) : null; if (d) fillKg = v * VOL_TO_L[fl.unit] * d; }
867
+ if (fillKg > 0) return batchKg / fillKg;
868
+ }
869
+ // A recipe by weight is one piece of product (226.8 g of candle, 1 wick): 2,721.6 g makes 12 (27c).
870
+ if (batchKg > 0 && f && typeof computeCompositionFractions === 'function') {
871
+ const fr = computeCompositionFractions(f);
872
+ if (fr && !fr.allWt && !fr.allVol && !fr.mixedBasis && fr.totalMassKg > 0) return batchKg / fr.totalMassKg;
873
+ }
874
+ return 1;
875
+ }
876
+ // A recipe's rows without its Not mixed in parts, in any unit: an as-prepared "0.5 g" of wick is still not part of the
877
+ // mix (27f). All rows marked (a kit) keeps them all.
878
+ function flMixRows(comp) {
879
+ comp = Array.isArray(comp) ? comp : [];
880
+ const marked = c => { const ing = c && !c.formulationId && c.ingredientId ? (typeof db !== 'undefined' && db && db.ingredients || []).find(i => i.id === c.ingredientId) : null; return !!(ing && ing.notMixedIn); };
881
+ const keep = comp.filter(c => !marked(c));
882
+ return keep.length && keep.length < comp.length ? keep : comp;
883
+ }
884
+ // The mass of one piece of product, in g: the formula's fill by mass (or volume × density), else a recipe written by
885
+ // weight (226.8 g of candle, 1 wick). Null when neither says. A piece batch prefills its mass per unit with it (27e).
886
+ function flOnePieceGrams(f) {
887
+ if (!f) return null;
888
+ const fl = f.pricing && f.pricing.fill, v = fl ? parseFloat(fl.value) : NaN;
889
+ if (isFinite(v) && v > 0) {
890
+ if (fl.unit in MASS_TO_KG) return v * MASS_TO_KG[fl.unit] * 1000;
891
+ if (fl.unit in VOL_TO_L) { const d = typeof _rolledUpDensity === 'function' ? _rolledUpDensity(f) : null; if (d) return v * VOL_TO_L[fl.unit] * d * 1000; }
892
+ }
893
+ if (typeof computeCompositionFractions === 'function') {
894
+ const fr = computeCompositionFractions(f);
895
+ if (fr && !fr.allWt && !fr.allVol && !fr.mixedBasis && fr.totalMassKg > 0) return fr.totalMassKg * 1000;
896
+ }
897
+ return null;
898
+ }
845
899
  // A recipe row counted in pieces ("1 wick"), as kg through its ingredient's weight per piece. Null for any other row,
846
900
  // or a piece row whose ingredient has no weight per piece (it stays unpriced and unscaled, as before).
847
901
  function flPieceRowKg(c) {
@@ -1194,9 +1248,10 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
1194
1248
  };
1195
1249
 
1196
1250
  // A piece row with a weight per piece counts as mass (2 Dec).
1197
- const kinds = comp.map(c => flPieceRowKg(c) != null ? 'mass-abs' : classifyUnit(c.unit));
1198
- const allWt = comp.length && kinds.every(k => k === 'wt-frac');
1199
- const allVol = comp.length && kinds.every(k => k === 'vol-frac');
1251
+ const _aside = flCountedAside(comp);
1252
+ const kinds = comp.map(c => _aside.has(c) ? 'counted' : (flPieceRowKg(c) != null ? 'mass-abs' : classifyUnit(c.unit)));
1253
+ const allWt = comp.length && kinds.every(k => k === 'wt-frac' || k === 'counted') && kinds.includes('wt-frac');
1254
+ const allVol = comp.length && kinds.every(k => k === 'vol-frac' || k === 'counted') && kinds.includes('vol-frac');
1200
1255
  // A counted row still missing its weight per piece is reported on its own; it must not knock the gram rows off the absolute basis.
1201
1256
  const allAbs = comp.length && kinds.every((k, i) => k === 'mass-abs' || k === 'vol-abs' || (k !== 'wt-frac' && k !== 'vol-frac' && flIsPieceUnit(comp[i].unit)))
1202
1257
  && kinds.some(k => k === 'mass-abs' || k === 'vol-abs');
@@ -1208,6 +1263,7 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
1208
1263
  if (allVol) {
1209
1264
  let sumKg = 0, ok = true;
1210
1265
  for (const c of comp) {
1266
+ if (_aside.has(c)) continue;
1211
1267
  let d = null;
1212
1268
  if (c.formulationId) {
1213
1269
  d = subResolve.get(c)?.density || null;
@@ -1245,6 +1301,7 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
1245
1301
  d = _densityToKgPerL(ing.density, ing.densityUnit);
1246
1302
  }
1247
1303
  if (!isFinite(amt) || flBadAmount(c.amount, c.unit)) continue;
1304
+ if (_aside.has(c)) continue; // not mixed in: outside the recipe's mass (27c)
1248
1305
  const _pk = flPieceRowKg(c);
1249
1306
  if (_pk != null || u in MASS_TO_KG) {
1250
1307
  const m = _pk != null ? _pk : amt * MASS_TO_KG[u];
@@ -1273,6 +1330,19 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
1273
1330
  let totalPerKg = 0;
1274
1331
  let totalPct = 0;
1275
1332
 
1333
+ // A counted part's cost for one piece of product (1 wick at $0.12), in the display currency: a price per piece times
1334
+ // the count, or a price per kg (or L) through the weight per piece. Null when it can't be priced (3 Dec).
1335
+ let countedPerPiece = 0;
1336
+ const countedUnpriced = [];
1337
+ const _countedRowCost = (ing, c) => {
1338
+ if (!ing.cost || ing.cost.value == null || ing.cost.value === '') return null;
1339
+ const v = parseFloat(ing.cost.value), n = parseFloat(c.amount);
1340
+ if (!isFinite(v) || !isFinite(n)) return null;
1341
+ let own = null;
1342
+ if (flIsPieceUnit(ing.cost.unit || '')) own = v * n;
1343
+ else { const pk = costPerKgInOwnCurrency(ing.cost, ing.density, ing.densityUnit, ing.unitMass), kg = flPieceRowKg(c); if (pk != null && kg != null) own = pk * kg; }
1344
+ return own == null ? null : convertCurrencySync(own, ing.cost.currency || 'USD', displayCcy);
1345
+ };
1276
1346
  const tryAutoPrice = (ing, c, unit, amount, kind) => {
1277
1347
  if (!ing.cost || ing.cost.value == null || ing.cost.value === '') return { ok: false, reason: 'no cost on file' };
1278
1348
  const perKgOwn = costPerKgInOwnCurrency(ing.cost, ing.density, ing.densityUnit, ing.unitMass);
@@ -1374,6 +1444,11 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
1374
1444
  if (flBadAmount(c.amount, c.unit)) { missing.push({ reason: `bad amount (${flBadAmount(c.amount, c.unit)})`, ingredient: ing }); continue; }
1375
1445
  if (!isFinite(amount)) { missing.push({ reason: 'no amount', ingredient: ing }); continue; }
1376
1446
 
1447
+ if (_aside.has(c)) { // counted beside a % recipe: outside the per-kg cost (flCountedAside); priced per piece of product
1448
+ const cc = _countedRowCost(ing, c);
1449
+ if (cc == null) countedUnpriced.push(ing); else countedPerPiece += cc;
1450
+ continue;
1451
+ }
1377
1452
  const kind = flPieceRowKg(c) != null ? 'mass-abs' : classifyUnit(unit);
1378
1453
  if (kind === 'unknown') {
1379
1454
  missing.push({ reason: flIsPieceUnit(c.unit) ? `set a weight per piece on ${ing.name || 'the ingredient'} to cost "${c.unit}"` : `unsupported composition unit "${c.unit}"`, ingredient: ing });
@@ -1444,6 +1519,7 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
1444
1519
  // Sub-formula rows use their rolled-up density.
1445
1520
  let sumA = 0, sumW = 0;
1446
1521
  for (const c of comp) {
1522
+ if (_aside.has(c)) continue;
1447
1523
  let d = null;
1448
1524
  if (c.formulationId) {
1449
1525
  d = subResolve.get(c)?.density || null;
@@ -1505,6 +1581,10 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
1505
1581
  missing,
1506
1582
  basis, // 'wt' or 'vol' (recipe basis, not display basis)
1507
1583
  formulationKgPerL, // only meaningful when basis === 'vol'
1584
+ // Parts counted per piece of product beside a % recipe (1 wick): their cost for one piece, outside perKg; null
1585
+ // when there are none, or one of them has no usable price (countedUnpriced names it).
1586
+ countedPerPiece: _aside.size && !countedUnpriced.length ? countedPerPiece : null,
1587
+ countedUnpriced,
1508
1588
  };
1509
1589
  }
1510
1590
 
@@ -1552,6 +1632,7 @@ function convertPricePerBasis(price, fromBasis, toBasis, formulationKgPerL, fill
1552
1632
  // ============================================================
1553
1633
  function computeCompositionFractions(formulation) {
1554
1634
  const comp = formulation.composition || [];
1635
+ const _aside = flCountedAside(comp);
1555
1636
 
1556
1637
  const canonUnit = u => {
1557
1638
  const raw = String(u || '').trim();
@@ -1581,6 +1662,7 @@ function computeCompositionFractions(formulation) {
1581
1662
  const out = { composition: c, ingredient: ing, subFormula, amount, unit: rawU, density: d };
1582
1663
  const resolved = !!(ing || subFormula);
1583
1664
  if (!isFinite(amount) || !resolved || flBadAmount(c.amount, c.unit)) { out.kind = 'invalid'; return out; }
1665
+ if (_aside.has(c)) { out.kind = 'counted'; out.pieces = true; return out; } // outside the 100% (flCountedAside)
1584
1666
  if (u.startsWith('wt') || u === '%') { out.kind = 'wt-frac'; return out; }
1585
1667
  if (u.startsWith('vol')) { out.kind = 'vol-frac'; return out; }
1586
1668
  const cu = canonUnit(rawU);
@@ -1614,22 +1696,22 @@ function computeCompositionFractions(formulation) {
1614
1696
  if (r.volL != null) totalVolL += r.volL;
1615
1697
  if (r.lengthM != null) totalLengthM += r.lengthM;
1616
1698
  });
1617
- const allWt = rows.length && rows.every(r => r.kind === 'wt-frac');
1618
- const allVol = rows.length && rows.every(r => r.kind === 'vol-frac');
1699
+ const allWt = rows.length && rows.every(r => r.kind === 'wt-frac' || r.kind === 'counted') && rows.some(r => r.kind === 'wt-frac');
1700
+ const allVol = rows.length && rows.every(r => r.kind === 'vol-frac' || r.kind === 'counted') && rows.some(r => r.kind === 'vol-frac');
1619
1701
  const allLen = rows.length && rows.every(r => r.kind === 'length-abs');
1620
1702
 
1621
1703
  // For pure wt% / vol% recipes, derive formulation density from densities
1622
1704
  // so we can also compute the *other* fraction (vol for wt%, mass for vol%).
1623
1705
  let wtFormKgPerL = null;
1624
1706
  let volFormKgPerL = null;
1625
- if (allWt && rows.every(r => r.density)) {
1707
+ if (allWt && rows.every(r => r.density || r.kind === 'counted')) {
1626
1708
  let invSum = 0; // sum over rows of (wt_frac / density)
1627
- rows.forEach(r => { invSum += (r.amount / 100) / r.density; });
1709
+ rows.forEach(r => { if (r.kind === 'counted') return; invSum += (r.amount / 100) / r.density; });
1628
1710
  if (invSum > 0) wtFormKgPerL = 1 / invSum;
1629
1711
  }
1630
- if (allVol && rows.every(r => r.density)) {
1712
+ if (allVol && rows.every(r => r.density || r.kind === 'counted')) {
1631
1713
  let sum = 0;
1632
- rows.forEach(r => { sum += (r.amount / 100) * r.density; });
1714
+ rows.forEach(r => { if (r.kind === 'counted') return; sum += (r.amount / 100) * r.density; });
1633
1715
  if (sum > 0) volFormKgPerL = sum;
1634
1716
  }
1635
1717
 
@@ -1735,7 +1817,7 @@ function smartScaleAmount(value, unit) {
1735
1817
  // • no finished density → ideal-mix estimate, exactly as before: row volume
1736
1818
  // fractions × target (parts add up, which is the assumption).
1737
1819
  // Mass targets are unaffected either way.
1738
- function scaleCompositionToBatch(formulation, batchAmount, batchUnit) {
1820
+ function scaleCompositionToBatch(formulation, batchAmount, batchUnit, opts) {
1739
1821
  const amt = parseFloat(batchAmount);
1740
1822
  if (!isFinite(amt) || amt <= 0) return null;
1741
1823
  const dim = (batchUnit in MASS_TO_KG) ? 'mass'
@@ -1748,10 +1830,19 @@ function scaleCompositionToBatch(formulation, batchAmount, batchUnit) {
1748
1830
  let anyNull = false;
1749
1831
  const pd = (typeof formulaPlanningDensity === 'function') ? formulaPlanningDensity(formulation) : null;
1750
1832
  const useFinished = dim === 'volume' && pd && pd.source === 'finished';
1833
+ // A counted row beside the % rows (1 wick, flCountedAside) goes in as counted, not scaled: its count, and in a mass
1834
+ // batch its weight when the ingredient has a weight per piece.
1835
+ // Counted per piece of product: × the pieces the batch makes (opts.count: a count batch's own count; flProductUnits).
1836
+ const _bKg = dim === 'mass' ? amt * MASS_TO_KG[batchUnit] : (pd ? amt * VOL_TO_L[batchUnit] * pd.kgPerL : null);
1837
+ const units = fr.rows.some(r => r.kind === 'counted') ? flProductUnits(formulation, _bKg, opts && opts.count) : 1;
1838
+ const counted = new Set(comp.filter((c, i) => fr.rows[i] && fr.rows[i].kind === 'counted'));
1839
+ const _cntAmt = c => { if (dim !== 'mass') return null; const kg = flPieceRowKg(c); return kg != null ? kg * units / MASS_TO_KG[batchUnit] : null; };
1840
+ const _cntPieces = (out) => fr.rows.forEach((r, i) => { if (r.kind === 'counted') out.set(comp[i], flPieceCount(parseFloat(comp[i].amount) * units)); });
1751
1841
  if (useFinished) {
1752
1842
  const totalMassKg = amt * VOL_TO_L[batchUnit] * pd.kgPerL;
1753
1843
  let partsSum = 0;
1754
1844
  fr.rows.forEach((r, i) => {
1845
+ if (r.kind === 'counted') { byRow.set(comp[i], null); return; }
1755
1846
  const mf = r.massFraction;
1756
1847
  const rowD = (r.density != null && isFinite(r.density) && r.density > 0) ? r.density : null; // kg/L
1757
1848
  const ok = (mf != null && isFinite(mf) && rowD != null);
@@ -1765,15 +1856,17 @@ function scaleCompositionToBatch(formulation, batchAmount, batchUnit) {
1765
1856
  const c = comp[i], one = r.pieces ? flPieceRowKg(Object.assign({}, c, { amount: 1 })) : null;
1766
1857
  if (one && r.massFraction != null && isFinite(r.massFraction)) pieces.set(c, flPieceCount((r.massFraction * totalMassKg) / one));
1767
1858
  });
1768
- return { unit: batchUnit, dim, byRow, anyNull, density: pd, totalMassKg, partsSum, pieces };
1859
+ _cntPieces(pieces);
1860
+ return { unit: batchUnit, dim, byRow, anyNull, density: pd, totalMassKg, partsSum, pieces, units, counted };
1769
1861
  }
1770
1862
  fr.rows.forEach((r, i) => {
1863
+ if (r.kind === 'counted') { byRow.set(comp[i], _cntAmt(comp[i])); return; }
1771
1864
  const frac = dim === 'mass' ? r.massFraction : r.volFraction;
1772
1865
  const ok = (frac != null && isFinite(frac));
1773
1866
  if (!ok) anyNull = true;
1774
1867
  byRow.set(comp[i], ok ? frac * amt : null);
1775
1868
  });
1776
- const out = { unit: batchUnit, dim, byRow, anyNull };
1869
+ const out = { unit: batchUnit, dim, byRow, anyNull, units, counted };
1777
1870
  // Piece rows (wicks) also as a count: their scaled mass over the weight per piece (2 Dec).
1778
1871
  if (dim === 'mass') {
1779
1872
  out.pieces = new Map();
@@ -1781,6 +1874,7 @@ function scaleCompositionToBatch(formulation, batchAmount, batchUnit) {
1781
1874
  const c = comp[i], g = byRow.get(c), one = r.pieces ? flPieceRowKg(Object.assign({}, c, { amount: 1 })) : null;
1782
1875
  if (one && g != null && isFinite(g)) out.pieces.set(c, flPieceCount((g * MASS_TO_KG[batchUnit]) / one));
1783
1876
  });
1877
+ _cntPieces(out.pieces);
1784
1878
  }
1785
1879
  if (dim === 'volume' && pd) {
1786
1880
  out.density = pd; out.totalMassKg = amt * VOL_TO_L[batchUnit] * pd.kgPerL; out.partsSum = amt;
@@ -1790,6 +1884,7 @@ function scaleCompositionToBatch(formulation, batchAmount, batchUnit) {
1790
1884
  const c = comp[i], one = r.pieces ? flPieceRowKg(Object.assign({}, c, { amount: 1 })) : null;
1791
1885
  if (one && r.massFraction != null && isFinite(r.massFraction)) out.pieces.set(c, flPieceCount((r.massFraction * out.totalMassKg) / one));
1792
1886
  });
1887
+ _cntPieces(out.pieces);
1793
1888
  }
1794
1889
  return out;
1795
1890
  }
@@ -1943,8 +2038,9 @@ const QS_ROLE = 'Balance (q.s.)';
1943
2038
  function sumActualRowsMassKg(rows, formula) {
1944
2039
  if (!Array.isArray(rows)) return null;
1945
2040
  let kg = 0, n = 0;
2041
+ const _aside = typeof flCountedAside === 'function' ? flCountedAside(rows) : new Set(); // 10 wicks: counted, not in the mass (27e)
1946
2042
  for (const c of rows) {
1947
- if (!c || !(c.ingredientId || c.formulationId)) continue;
2043
+ if (!c || !(c.ingredientId || c.formulationId) || _aside.has(c)) continue;
1948
2044
  const amt = parseFloat(c.amount);
1949
2045
  if (!isFinite(amt)) continue;
1950
2046
  const u = (c.unit || '').trim();
@@ -1979,7 +2075,7 @@ function applyQsBalance(rows, targetQty) {
1979
2075
  const bi = rows.findIndex(r => r && r.comp && r.comp.role === QS_ROLE);
1980
2076
  if (bi < 0) return out;
1981
2077
  let others = 0;
1982
- rows.forEach((r, i) => { if (i !== bi && r.amount != null && isFinite(r.amount)) others += r.amount; });
2078
+ rows.forEach((r, i) => { if (i !== bi && !r.counted && r.amount != null && isFinite(r.amount)) others += r.amount; }); // a counted wick is not in the batch mass (3 Dec)
1983
2079
  let bal = targetQty - others;
1984
2080
  out.qsApplied = true;
1985
2081
  out.qsShort = bal < -1e-9;
@@ -2053,7 +2149,8 @@ function renderWeighoutPanel(w, actuals, formula, copyOnclick, noun) {
2053
2149
  const key = c.formulationId ? ('f:' + c.formulationId) : (c.ingredientId ? ('i:' + c.ingredientId) : '');
2054
2150
  const amt = parseFloat(c.amount);
2055
2151
  const u = c.unit || '';
2056
- const comparable = (typeof isMassUnit === 'function' && isMassUnit(u)) || (typeof isVolUnit === 'function' && isVolUnit(u));
2152
+ const comparable = (typeof isMassUnit === 'function' && isMassUnit(u)) || (typeof isVolUnit === 'function' && isVolUnit(u))
2153
+ || (key.slice(0, 2) === 'i:' && typeof flIsPieceUnit === 'function' && flIsPieceUnit(u)); // "10 piece" of wick compares through its weight (27e)
2057
2154
  if (key && comparable && isFinite(amt)) actMap.set(key, { amount: amt, unit: u });
2058
2155
  });
2059
2156
  const hasActuals = actMap.size > 0;
@@ -2125,10 +2222,10 @@ function renderWeighoutPanel(w, actuals, formula, copyOnclick, noun) {
2125
2222
  const a = actMap.get(r.key);
2126
2223
  const planned = (r.amount != null && isFinite(r.amount)) ? r.amount : null;
2127
2224
  let actInUnit = null;
2128
- if (a) { actInUnit = toUnit(a.amount, a.unit, r.key); if (actInUnit != null) actualTotal += actInUnit; }
2225
+ if (a) { actInUnit = toUnit(a.amount, a.unit, r.key); if (actInUnit != null && !r.counted) actualTotal += actInUnit; } // a wick: not in the total (27e)
2129
2226
  const delta = (hasActuals && planned != null && actInUnit != null) ? (actInUnit - planned) : null;
2130
2227
  const rel = (delta != null && planned > 0) ? Math.abs(delta) / planned : (delta != null && actInUnit > 0 ? 1 : null);
2131
- return { key: r.key, name: r.name, planned, actInUnit, actRaw: a, delta, rel, purity: r.purity, activeAmount: r.activeAmount, qs: r.qs, lotDev: r.lotDev || null, lotBasis: r.lotBasis || null, pieces: r.pieces != null ? r.pieces : null, pieceUnit: r.pieceUnit || '' };
2228
+ return { key: r.key, name: r.name, planned, actInUnit, actRaw: a, delta, rel, purity: r.purity, activeAmount: r.activeAmount, qs: r.qs, lotDev: r.lotDev || null, lotBasis: r.lotBasis || null, pieces: r.pieces != null ? r.pieces : null, pieceUnit: r.pieceUnit || '', counted: !!r.counted };
2132
2229
  });
2133
2230
  // Union in ingredients that were ADDED to the As-prepared table but aren't in
2134
2231
  // the recipe (a spike / colorant / q.s. carrier). Without this the weigh-out
@@ -2235,7 +2332,7 @@ function renderWeighoutPanel(w, actuals, formula, copyOnclick, noun) {
2235
2332
  : `<div class="fl-wo-why" style="font-size:11px;color:var(--dk-muted, #64748b);margin-top:1px;font-variant-numeric:tabular-nums">${cv(r.activeAmount)} ${esc(displayUnit)} active ÷ ${esc(String(+r.purity))}% ${r.lotBasis ? `(lot <span translate="no">${esc(String(r.lotBasis.lotNumber))}</span> assay)` : '(nominal)'} = <strong style="color:var(--dk-text-2, #334155)">${cv(r.planned)} ${esc(displayUnit)}</strong></div>`;
2236
2333
  const body = rows.map((r, i) => `<tr data-wo-key="${esc(r.key)}" style="${hasActuals ? dRowBg(r.rel) : ''}">
2237
2334
  <td style="padding:4px 8px;color:var(--dk-faint, #94a3b8)">${i + 1}</td>
2238
- <td style="padding:4px 8px">${esc(r.name)}${purityWhy(r)}${r.pieces != null ? `<div class="fl-wo-why" style="font-size:11px;color:var(--dk-muted, #64748b);margin-top:1px">${esc(String(r.pieces))} ${esc(r.pieceUnit === 'piece' && r.pieces !== 1 ? 'pieces' : r.pieceUnit)} by count</div>` : ''}${r._added ? ` <span style="font-size:9.5px;color:var(--dk-red-fg, #b91c1c);font-weight:600;background:var(--dk-red-bg, #fef2f2);border:1px solid var(--dk-red-line, #fecaca);border-radius:4px;padding:0 4px;vertical-align:middle;white-space:nowrap" title="Added to the as-prepared batch — not part of the linked recipe">+ not in recipe</span>` : ''}</td>
2335
+ <td style="padding:4px 8px">${esc(r.name)}${purityWhy(r)}${r.pieces != null ? `<div class="fl-wo-why" style="font-size:11px;color:var(--dk-muted, #64748b);margin-top:1px">${esc(String(r.pieces))} ${esc(r.pieceUnit === 'piece' && r.pieces !== 1 ? 'pieces' : r.pieceUnit)} by count${r.counted ? ' · not in the total' : ''}</div>` : ''}${r._added ? ` <span style="font-size:9.5px;color:var(--dk-red-fg, #b91c1c);font-weight:600;background:var(--dk-red-bg, #fef2f2);border:1px solid var(--dk-red-line, #fecaca);border-radius:4px;padding:0 4px;vertical-align:middle;white-space:nowrap" title="Added to the as-prepared batch — not part of the linked recipe">+ not in recipe</span>` : ''}</td>
2239
2336
  <td style="padding:4px 8px;text-align:right;font-variant-numeric:tabular-nums;font-weight:600;color:var(--dk-text, #0f172a)">${r.planned != null ? `${cv(r.planned)}${purityTag(r)}${qsTag(r)}` : '<span style="color:var(--dk-dim, #cbd5e1)">—</span>'}</td>
2240
2337
  ${hasActuals ? `<td style="padding:4px 8px;text-align:right;font-variant-numeric:tabular-nums">${
2241
2338
  r.actInUnit != null ? cv(r.actInUnit)
@@ -2449,13 +2546,17 @@ function computeBatchCost(batch, displayCcy = getDisplayCurrency()) {
2449
2546
  // every volume-unit batch silently reported no total.)
2450
2547
  const _umk = (typeof _batchUnitMassKg === 'function') ? _batchUnitMassKg(batch) : null;
2451
2548
  const sizeKg = quantityToKg(batch.targetQuantity, batch.unit, f, _umk);
2549
+ // Parts counted per piece (1 wick per candle) × the pieces the batch makes (3 Dec).
2550
+ const _isCount = _umk != null && !(batch.unit in MASS_TO_KG) && !(batch.unit in VOL_TO_L);
2551
+ const countedCost = perKg.countedPerPiece ? perKg.countedPerPiece * flProductUnits(f, sizeKg, _isCount ? batch.targetQuantity : null) : 0;
2452
2552
  return {
2453
2553
  formulation: f,
2454
2554
  perKg: perKg.perKg,
2455
2555
  sizeKg,
2456
- total: sizeKg != null ? perKg.perKg * sizeKg : null,
2556
+ total: sizeKg != null ? perKg.perKg * sizeKg + countedCost : null,
2557
+ counted: countedCost || null,
2457
2558
  currency: displayCcy,
2458
- missing: perKg.missing,
2559
+ missing: perKg.missing.concat((perKg.countedUnpriced || []).map(ing => ({ reason: 'no cost on file (counted per piece)', ingredient: ing }))),
2459
2560
  };
2460
2561
  }
2461
2562
 
@@ -2691,14 +2792,17 @@ function quantityCost(qty, unit, formula, displayCcy) {
2691
2792
  const ccy = displayCcy ||
2692
2793
  (typeof getDisplayCurrency === 'function' ? getDisplayCurrency() : null) ||
2693
2794
  (formula && formula.costCurrency) || 'USD';
2694
- let perKg = null;
2795
+ let perKg = null, perPiece = null;
2695
2796
  try {
2696
2797
  const c = formula && typeof computeFormulationCost === 'function' ? computeFormulationCost(formula, ccy) : null;
2697
2798
  if (c && isFinite(c.perKg)) perKg = c.perKg;
2799
+ if (c && c.countedPerPiece > 0) perPiece = c.countedPerPiece;
2698
2800
  } catch (_) { perKg = null; }
2699
2801
  const kg = quantityToKg(qty, unit, formula);
2700
- const computed = (perKg != null && kg != null) ? perKg * kg : null;
2701
- return { perKg, kg, computed, ccy, convertible: kg != null };
2802
+ // A wick, priced per piece of product (27f: a candle sample read $1.72 without its $0.12 wick).
2803
+ const counted = (perPiece != null && kg > 0 && typeof flProductUnits === 'function') ? perPiece * flProductUnits(formula, kg, null) : 0;
2804
+ const computed = (perKg != null && kg != null) ? perKg * kg + counted : null;
2805
+ return { perKg, kg, computed, ccy, convertible: kg != null, counted };
2702
2806
  }
2703
2807
 
2704
2808
  // Open the global Display-currency setting — Settings modal → Preferences tab
@@ -2785,7 +2889,7 @@ function entityCostCellHtml(summary, label) {
2785
2889
  // o = { kind:'sample'|'batch', id, qty, unit, formula, override }.
2786
2890
  function entityCostValueHtml(o) {
2787
2891
  if (typeof flCostHidden === 'function' && flCostHidden()) return '<span style="color:var(--dk-faint, #94a3b8)">—</span>'; // 0267: cost hidden from Viewers
2788
- const { perKg, computed, ccy, convertible } = quantityCost(o.qty, o.unit, o.formula);
2892
+ const { perKg, computed, ccy, convertible, counted } = quantityCost(o.qty, o.unit, o.formula);
2789
2893
  const money = v => (typeof formatMoney === 'function') ? formatMoney(v, ccy) : (ccy + ' ' + (+v).toFixed(2));
2790
2894
  const ovRaw = (o.override != null && o.override !== '' && isFinite(parseFloat(o.override))) ? parseFloat(o.override) : null;
2791
2895
  // The override was entered in o.overrideCcy (legacy values w/o a stamp are
@@ -2849,7 +2953,7 @@ function entityCostValueHtml(o) {
2849
2953
  const col = (why === 'needs-density') ? 'var(--dk-amber-fg, #b45309)' : 'var(--text-muted)';
2850
2954
  return `<span style="color:var(--text-muted)">—</span> <span style="font-size:11px;color:${col}">${msg}</span>${editBtn}`;
2851
2955
  }
2852
- const breakdown = `<span style="font-size:11px;color:var(--text-muted);margin-left:6px">${esc(String(o.qty))} ${esc(o.unit || '')} × ${money(perKg)}/kg</span>`;
2956
+ const breakdown = `<span style="font-size:11px;color:var(--text-muted);margin-left:6px">${esc(String(o.qty))} ${esc(o.unit || '')} × ${money(perKg)}/kg${counted > 0 ? ` + ${money(counted)} counted parts` : ''}</span>`;
2853
2957
  return `<strong>${money(computed)}</strong>${breakdown}${editBtn}${ccyLine}`;
2854
2958
  }
2855
2959
 
package/vendor/nesting.js CHANGED
@@ -274,7 +274,11 @@ function _rowWtFractionsWithin(f, unresolved) {
274
274
  const comp = raw.filter(c => c && (c.ingredientId || c.formulationId));
275
275
  if (!comp.length) return [];
276
276
 
277
+ // A counted part marked "Not mixed in" beside % rows (1 wick, flCountedAside) is outside the 100%: no share of the
278
+ // mix here, and not a mixed basis (3 Dec).
279
+ const _aside = typeof flCountedAside === 'function' ? flCountedAside(comp) : new Set();
277
280
  const kinds = comp.map(c => {
281
+ if (_aside.has(c)) return 'aside';
278
282
  const u = String(c.unit || 'wt%').trim();
279
283
  const lower = u.toLowerCase();
280
284
  if (lower.startsWith('wt') || u === '%') return 'wt';
@@ -301,9 +305,9 @@ function _rowWtFractionsWithin(f, unresolved) {
301
305
  return comp.map(_ => 0);
302
306
  }
303
307
 
304
- const allWt = kinds.every(k => k === 'wt');
308
+ const allWt = kinds.every(k => k === 'wt' || k === 'aside');
305
309
  if (allWt) {
306
- const nums = comp.map(c => _usableAmount(c, unresolved));
310
+ const nums = comp.map((c, i) => kinds[i] === 'aside' ? 0 : _usableAmount(c, unresolved));
307
311
  const sum = nums.reduce((a, b) => a + b, 0);
308
312
  if (sum <= 0) return nums.map(_ => 0);
309
313
  return nums.map(n => n / sum);
@@ -345,6 +349,13 @@ function _rowWtFractionsWithin(f, unresolved) {
345
349
  }
346
350
  if (kinds[i] === 'wt') return amt; // treat as relative weight
347
351
  if (kinds[i] === 'vol') return amt; // treat as relative volume (best-effort)
352
+ // A row that can't be weighed (a piece with no weight per piece, an unknown unit) is named, not dropped in silence:
353
+ // the rest would otherwise read as 100% (3 Dec, Designer). A part not mixed in (a wick) is no share of the mix.
354
+ if (kinds[i] === 'unknown' && c.ingredientId) {
355
+ const pc = typeof flIsPieceUnit === 'function' && flIsPieceUnit(c.unit);
356
+ const ing = db.ingredients.find(x => x.id === c.ingredientId);
357
+ if (!(pc && ing && ing.notMixedIn)) unresolved && unresolved.push({ reason: pc ? 'no-weight' : 'unknown-unit', ingredientId: c.ingredientId, unit: c.unit || '' });
358
+ }
348
359
  return 0;
349
360
  });
350
361
  const sum = kgPerRow.reduce((a, b) => a + b, 0);