Parts — what they are, how they move
A Part is anything you stock or buy to keep an asset running — an oil filter, a brake pad, a coolant gallon, a windshield wiper. Each Part is master data: one row per SKU, with name, manufacturer, part number, unit of measure, and an optional default vendor.
Stock lives per-Location. The same brake-pad SKU can have 12 units at the Oakland yard and 0 at the LA yard — those are two PartStock rows. Adding a Part does NOT create stock; you raise stock by recording a purchase-in transaction at a specific location.
Every movement is journalled in Part Transactions. Five types: PURCHASE_IN (you bought parts from a vendor), WO_OUT (a work order consumed parts), RETURN_TO_VENDOR (you sent parts back), TRANSFER (moved stock between two locations), ADJUSTMENT (audit correction with a reason). The ledger is append-only — even reversals create a new offsetting transaction, so the audit trail is complete.
Low Stock is a derived view: any (Part × Location) where on-hand quantity drops below the per-Part `min_stock_threshold`. Use it as your reorder dashboard — one click to start a PURCHASE_IN against the default vendor.
- Add Part → POST /parts (master record only — no stock yet).
- Receive stock → /part-stock/purchase-in (location + qty + unit cost + vendor; auto-creates a Core Return row if the SKU has a core deposit).
- Consume via WO → mark a work order COMPLETED and the parts attached to it auto-emit WO_OUT transactions against the WO's location.
- Move stock → /part-stock/transfer (atomic; both legs in one transaction).
- Audit correction → /part-stock/adjust (always requires a reason; flagged in the audit trail).