Equipment & Cost Overrides
Purpose
Six retail/branch banking building blocks (SER/Hub Room, Check-in Counter, QMS Screen, Semi Private Meeting/Presentation Point, Machine Bay, Queuing Space for Machine Bay) have no standard equipment mappings in the database. Craig manually adjusts quantities in his Excel spreadsheet for these blocks. The override system lets users do the same in the web app — edit any auto-calculated equipment quantity or unit cost, add entirely new equipment items, and override any cell in the 15-row cost summary.
Two Override Types
Equipment Overrides
Stored in project_equipment_overrides table. Applied during calculation after all auto-calculation steps but before building the tech breakdown output.
| Field | Type | Purpose |
|---|---|---|
| item_name | VARCHAR(200) | Equipment item name (matches calculator’s equipmentTotals key) |
| category | VARCHAR(100) | Equipment category for display grouping |
| quantity_override | NUMERIC(10,2) | Override auto-calculated quantity |
| unit_cost_override | DECIMAL(12,2) | Override regional unit price |
| is_addition | BOOLEAN | true = manually added item, false = override of existing |
Two modes:
- Override existing: Changes quantity and/or unit cost of an auto-calculated item (e.g., change WAP qty from 3 to 5)
- Add new item: Inserts a completely new equipment line (e.g., add custom ATM equipment not in reference data)
Cost Overrides
Stored in project_cost_overrides table. Applied after the calculator produces the 15-row cost summary. Any individual cell (Equipment, Installation, CAPEX, OPEX, BAU) on any row can be overridden.
| Field | Type | Purpose |
|---|---|---|
| cost_line_item_id | INTEGER | References cost_line_items table (row 1-15) |
| equipment_override | DECIMAL(12,2) | Override Equipment column |
| installation_override | DECIMAL(12,2) | Override Installation column |
| capex_override | DECIMAL(12,2) | Override CAPEX column |
| opex_override | DECIMAL(12,2) | Override OPEX column |
| bau_override | DECIMAL(12,2) | Override BAU column |
Calculation Chain Integration
Equipment overrides are applied as Step 3e in the calculation chain — after building blocks, network design, derived items, and security items, but before category totals:
- Space Aggregation
- Data Points
- Tech Breakdown (auto-calculated)
- Network Design
- Derived Items (access switches, cabling, cabinets)
- Security Items (CCTV)
- Equipment Overrides applied here
- Category Totals (qty x regional unit prices)
- Cost Summary (15-row table)
- Cost Overrides applied here
API Endpoints
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /api/projects/:id/equipment-overrides | Load saved equipment overrides |
| PUT | /api/projects/:id/equipment-overrides | Save equipment overrides (delete + insert) |
| GET | /api/projects/:id/cost-overrides | Load saved cost overrides |
| PUT | /api/projects/:id/cost-overrides | Save cost overrides (delete + insert) |
All PUT endpoints use a delete-then-insert pattern within a transaction — the full set of overrides is replaced each time.
Frontend Components
EditableTechBreakdown (EditableTechBreakdown.tsx)
Replaces the read-only tech breakdown table. Features:
- Click any Qty or Unit Cost cell to edit inline
- Overridden cells highlighted with orange background
- Added items marked with “(added)” label
- Per-row clear button (X) to revert to auto-calculated value
- “Add Equipment Item” form at bottom: category dropdown, item name, qty, unit cost
EditableCostSummaryTable (inline in ProjectView.tsx)
Extends the existing cost summary table. Features:
- Click any cell (Equipment, Installation, CAPEX, OPEX, BAU) to edit
- Overridden cells highlighted with orange background
- Per-cell clear button to revert
- Auto-formatted as currency on blur
Save and Recalculate Flow
- User edits equipment quantities, unit costs, or cost summary cells
- “Save and Recalculate” button appears (only when changes exist)
- On click: saves both equipment and cost overrides to DB via PUT endpoints
- Triggers POST /api/calculations to recalculate with persisted overrides
- Refreshes the project view with updated results
Persistence
Cost overrides were previously only accepted transiently via the calculation request body. Now both override types are persisted in the database and loaded automatically during calculation. The calculation route loads overrides from DB as a fallback if none are provided in the request body.
Key Files
| File | Purpose |
|---|---|
| backend/src/services/calculator.ts | Override application in calculation chain (Step 3e) |
| backend/src/routes/projects.ts | 4 override CRUD endpoints |
| backend/src/routes/calculations.ts | Loads overrides from DB, passes to calculator |
| frontend/src/components/EditableTechBreakdown.tsx | Editable equipment table |
| frontend/src/pages/ProjectView.tsx | Editable cost summary + save/recalculate wiring |
| scripts/init-db.sql | project_equipment_overrides table definition |