Linear stock to buy
64-bitThe number of pieces and the total length of each hardwood section in the job.
length = Σ qty × length; pieces = Σ qty
The products are added in part order and the total is rounded to six decimals once, after the sum. Groups are keyed by the exact width and thickness, so two widths that differ in the last digit are listed separately. No cutting allowance is added.
export function linearList(linear) {
const g = new Map();
for (const p of linear.map(cleanPart).filter(Boolean)) {
const k = p.material + '|' + p.thickness + '|' + p.width;
if (!g.has(k)) g.set(k, { material: p.material, thickness: p.thickness, width: p.width, pieces: 0, length: 0 });
const e = g.get(k);
e.pieces += p.qty; e.length += p.qty * p.length;
}
return [...g.values()].map((e) => ({ ...e, length: r6(e.length) })).sort((a, b) => a.material.localeCompare(b.material) || a.width - b.width);
}