Parts Management

Parts Management

The Parts Management system tracks every component used during a repair, automatically adjusts inventory levels, calculates costs, and alerts you when stock runs low. Each part added to a repair is recorded as a RepairPart entry linked to both the repair and the parts inventory.

RepairPart data fields

When you add a part to a repair, the system records the following fields:

Field Description
repair_idUUID of the parent repair record
part_idUUID linking to PartsInventory (null for ad-hoc entries)
part_nameDisplay name of the part
part_skuStock keeping unit code for identification
quantityNumber of units used in the repair
unit_costCost per unit in your base currency
total_costAuto-calculated as quantity × unit_cost
supplier_idUUID linking to the part supplier
warranty_itemBoolean flag indicating the part is covered under warranty
notesOptional notes about this part usage

Automatic cost calculations

When a RepairPart is saved, the system performs three automatic calculations:

  1. Line total — The total_cost is set to quantity × unit_cost on every save.
  2. Repair parts cost — The parent repair's parts_cost field is updated to the sum of all linked RepairPart total_cost values.
  3. Repair total cost — The repair's total_cost is recalculated as labor_cost + parts_cost + external_cost.

These recalculations also run when a part is deleted from a repair, ensuring costs always reflect the current parts list.

Adding a part to a repair

Open the repair detail page and click Add Part to open the parts dialog. The autocomplete field searches by part name or SKU and displays each result with its SKU and a stock level chip showing current quantity in hand. Enter the required quantity and confirm.

Behind the scenes, PartsService::addPartToRepair runs inside a database transaction. It creates the RepairPart record, deducts the specified quantity from inventory, and updates the repair's parts cost. If the requested quantity exceeds available stock, the operation is rejected with an "Insufficient stock" error to prevent over-allocation.

Removing a part from a repair

To remove a part, click the delete icon on the parts table row. PartsService::removePartFromRepair returns the quantity to inventory, deletes the RepairPart record, and recalculates the repair's parts cost — all within a single transaction.

Parts table display

The parts table on the repair page shows the following columns:

  • Part Name — clickable link to the inventory entry
  • SKU — the part_sku value
  • Qty — quantity used
  • Unit Cost — cost per item
  • Total — line total (quantity × unit cost)
  • Stock Warning — a warning icon appears when remaining inventory falls below 5 units
  • Delete — remove the part and return stock

A footer row displays the Total Parts Cost summing all line totals.

Part number format

Parts follow the format PRT-NNNNNN (for example, PRT-000001). When a new part is created without a part number, PartsService::generatePartNumber finds the highest existing number and increments it, zero-padded to six digits.

Reorder alerts and bulk ordering

After every stock removal, PartsService::checkReorderAlert checks whether the part's quantity_in_stock has dropped to or below its minimum_stock_level. If so, a reorder warning is logged with the part number, current stock, minimum level, recommended reorder quantity, and supplier details.

PartsService::generateReorderList compiles all parts that need restocking into a single list. Each entry includes the part number, name, category, current stock, minimum level, recommended order quantity, unit cost, and estimated total cost. Results are grouped by supplier_id so you can place bulk orders with each supplier efficiently.

API routes

Method Endpoint Action
GET/repairs/{id}/partsList all parts used in a repair
POST/repairs/{id}/partsAdd a part to a repair (requires part_id, quantity)
DELETE/repairs/{id}/parts/{partId}Remove a part and return stock to inventory

Tips and best practices

  • Use inventory parts over ad-hoc entries — linking to PartsInventory enables automatic stock deduction and reorder tracking.
  • Set minimum stock levels — configure the minimum level and reorder quantity on each part to receive timely alerts before stock runs out.
  • Review the reorder list weekly — use generateReorderList to stay ahead of shortages and consolidate orders by supplier.
  • Mark warranty parts — set the warranty_item flag on parts covered by a manufacturer or equipment warranty to exclude them from cost reports.

Next steps

Continue to the next article to learn about Repair Checklists, where you can create structured task lists to ensure every repair follows a consistent quality process.

Was this article helpful?