53 lines
2.0 KiB
Markdown
53 lines
2.0 KiB
Markdown
# ro.status vs ro.workStatus — Field Confusion
|
|
|
|
Two repair order fields with similar names, completely different meanings. Confusing them causes silent bugs.
|
|
|
|
## The Fields
|
|
|
|
| Field | Meaning | Values | Used For |
|
|
|-------|---------|--------|----------|
|
|
| `ro.status` | Customer service status | `waiter`, `drop-off` | Red/blue badge on RO card |
|
|
| `ro.workStatus` | Work progress status | `diagnosing`, `in-progress`, `waiting-for-approval`, `waiting-for-parts`, `waiting-for-pickup`, `completed` | Work progress badge, dashboard counters, overdue filters, completion logic |
|
|
|
|
## Common Bug: Filtering by `ro.status === 'completed'`
|
|
|
|
**Symptom:** Dashboard shows "Completed: 0" despite having completed repair orders.
|
|
|
|
**Root cause:** Code filters by `ro.status === 'completed'` but `status` only stores `waiter` or `drop-off`. Completed orders have `ro.status` = `waiter` or `drop-off`, and `ro.workStatus` = `completed`.
|
|
|
|
**Wrong:**
|
|
```javascript
|
|
const completed = orders.filter(ro => ro.status === 'completed');
|
|
```
|
|
|
|
**Correct:**
|
|
```javascript
|
|
const completed = orders.filter(ro => ro.workStatus === 'completed');
|
|
```
|
|
|
|
## Common Bug: Filtering by `ro.status === 'picked-up'`
|
|
|
|
There is NO `picked-up` status value. The correct check is `ro.workStatus === 'waiting-for-pickup'`.
|
|
|
|
**Wrong:**
|
|
```javascript
|
|
ro.status !== 'completed' && ro.status !== 'picked-up'
|
|
```
|
|
|
|
**Correct:**
|
|
```javascript
|
|
ro.workStatus !== 'completed' && ro.workStatus !== 'waiting-for-pickup'
|
|
```
|
|
|
|
## Compound Bug: `ro.status` + Completed-Filtered Data Source
|
|
|
|
**Symptom:** Completed counter stays at 0 even after fixing status field checks.
|
|
|
|
**Additional cause:** `loadRepairOrders()` in dashboard.js filtered out ALL completed orders:
|
|
```javascript
|
|
const activeOrders = allOrders.filter(ro => ro.workStatus !== 'completed');
|
|
dashboardData.repairOrders = activeOrders; // completed orders NEVER loaded
|
|
```
|
|
|
|
**Fix:** Remove the filter from the data source. Let `dashboardData.repairOrders` contain ALL orders. Each consumer filters as needed.
|