Add BOM cost tracking
Suggested-default cost on CableType/DeviceTemplate, copied onto placed Device instances (same pattern as ports) and overridable per-connection/per-device in the diagram. BOM view shows per-line and grand-total cost, excluding (and flagging) anything without a computable cost rather than treating it as zero. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017DUU6CnxECCDeqDNYJgr5x
This commit is contained in:
@@ -20,6 +20,8 @@ export default function ConnectionInspector({ connectionId }: { connectionId: st
|
||||
return sourcePortType && targetPortType ? cableTypesForConnection(project, sourcePortType, targetPortType) : []
|
||||
}, [project, sourcePort, targetPort])
|
||||
|
||||
const cableCostPerUnit = availableCableTypes.find((ct) => ct.id === connection?.cableTypeId)?.costPerUnit
|
||||
|
||||
if (!connection || !sourceDevice || !targetDevice || !sourcePort || !targetPort) return null
|
||||
|
||||
return (
|
||||
@@ -76,6 +78,33 @@ export default function ConnectionInspector({ connectionId }: { connectionId: st
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label className="block text-xs font-medium text-slate-600">
|
||||
Cost override
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
<span className="text-xs text-slate-500">$</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.01}
|
||||
value={connection.cost ?? ''}
|
||||
onChange={(e) =>
|
||||
updateConnection(connection.id, {
|
||||
cost: e.target.value === '' ? undefined : Number(e.target.value),
|
||||
})
|
||||
}
|
||||
className="w-full rounded border border-slate-300 px-2 py-1 text-sm"
|
||||
placeholder={
|
||||
cableCostPerUnit !== undefined && connection.distance
|
||||
? `computed: $${(cableCostPerUnit * connection.distance).toFixed(2)}`
|
||||
: 'e.g. 24.99'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<p className="mt-1 text-[10px] text-slate-400">
|
||||
Overrides the cable type's per-unit cost for this run specifically. Leave blank to use cost/unit × distance.
|
||||
</p>
|
||||
</label>
|
||||
|
||||
<label className="block text-xs font-medium text-slate-600">
|
||||
Label
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user