fix: safe status-recommendation flow, MO-016 order independence, brand constant, message codes
- Add a single shared, pure vehicle-status evaluator (app/services/vehicle_status.py)
used identically by the data-quality scanner, a new non-mutating status-recommendation
preview endpoint, and a transactional apply endpoint with optimistic-concurrency token
revalidation -- eliminates the old opaque "calculate and apply" action and the unsafe
"maintenance + active booking -> auto rented" shortcut. Frontend
DataQualityIssueDetail.tsx now shows a review/decide/confirm panel with localized
why/evidence/consequence text in nl-BE/en-GB/fr-BE, with an exact "Change status to
<status>" confirm action per the brief.
- Fix MO-016 issue-order dependency: resolving the booking-overlap issue before vs.
after the status-conflict issue now converges on the same final vehicle status,
proven by test_mo_016_status_conflict_recommendation_is_order_independent.
- Make "Fleet Ops" a non-localizable brand constant (frontend/src/product.ts,
backend PRODUCT_NAME) via {{productName}} interpolation everywhere the brand name
appeared in locale prose; add a permanent test guarding against a translation file
ever defining the brand name or an "appName" key again.
- Convert dynamic backend prose to stable message codes + params: return status
reasons, audit field/actor-type labels, automation last_error, and search
section/vehicle/booking/issue results all now carry codes the frontend localizes,
with raw technical text demoted to a "Technical details" disclosure.
- docs/fleet-ops-correction/: gap audit, i18n inventory, and the vehicle-status
decision table documenting the evaluator's rules and safe-status principles.
148 backend tests + Ruff + mypy green; Alembic migration verified upgrade/downgrade;
frontend tsc/build and the i18n-coverage Playwright suite green.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
18344bc8b7
commit
6deb95524d
@@ -180,13 +180,48 @@
|
||||
"heading": "Resolve the status conflict",
|
||||
"description": "One authoritative rule recommends a corrected operational status for this vehicle.",
|
||||
"currentStatus": "Current status",
|
||||
"calculateAndApply": "Calculate and apply recommended status",
|
||||
"confirmTitle": "Confirm status change",
|
||||
"confirmBody": "Apply the authoritative recommended status for this vehicle?",
|
||||
"reviewRecommendation": "Review recommendation",
|
||||
"loadingRecommendation": "Loading recommendation…",
|
||||
"recommendationFailed": "Could not load a recommendation.",
|
||||
"recommendedStatus": "Recommended status",
|
||||
"whyHeading": "Why",
|
||||
"evidenceHeading": "Facts",
|
||||
"consequenceHeading": "Consequence",
|
||||
"consequence": {
|
||||
"statusWillChange": "The vehicle status will change to {{status}}.",
|
||||
"issueWillBeRechecked": "This quality issue will be re-checked.",
|
||||
"changeWillBeAudited": "The change will be recorded in the audit trail.",
|
||||
"bookingsNotDeleted": "The bookings themselves are not deleted."
|
||||
},
|
||||
"changeStatusTo": "Change status to {{status}}",
|
||||
"applying": "Applying…",
|
||||
"confirmYes": "Yes, apply",
|
||||
"applied": "Applied {{status}} — {{reason}}",
|
||||
"applyFailed": "Could not apply a recommended status."
|
||||
"applyFailed": "Could not apply a recommended status.",
|
||||
"staleRecommendation": "The situation has changed since this recommendation was shown. Review it again before applying.",
|
||||
"reviewAgain": "Review recommendation again",
|
||||
"manualReview": {
|
||||
"heading": "Manual review required",
|
||||
"body": "The facts for this vehicle contradict each other. An Operations Manager needs to review this in person rather than apply an automatic status change.",
|
||||
"hint": "Use 'Defer' or 'Reject' below, or investigate the vehicle and the related bookings manually."
|
||||
},
|
||||
"noConflict": {
|
||||
"heading": "No change needed",
|
||||
"body": "This vehicle's current status already matches the facts."
|
||||
},
|
||||
"evidence": {
|
||||
"activeBookings": "Active booking(s): {{refs}}",
|
||||
"overlappingBookings": "Overlapping bookings: {{pairs}}",
|
||||
"serviceThresholdReached": "Odometer reading ({{odometer}} km) has reached the service threshold ({{threshold}} km).",
|
||||
"openOverlapIssue": "Open booking-overlap issue: {{ref}}"
|
||||
},
|
||||
"reasonCodes": {
|
||||
"vehicle.active_rental": "This vehicle has an active rental but is not recorded as rented. The status is corrected to reflect the actual situation.",
|
||||
"vehicle.service_threshold_reached": "This vehicle has reached its service threshold. It is set to maintenance so it is not deployed before servicing takes place.",
|
||||
"vehicle.booking_conflict": "This vehicle has two overlapping bookings. Blocking it prevents it from being considered available again before the booking conflict is resolved.",
|
||||
"vehicle.rental_ended": "The rental for this vehicle has ended and there is no active booking left. It is set back to available.",
|
||||
"vehicle.manual_review_required": "The facts for this vehicle contradict each other (for example, an active booking while the vehicle is in maintenance, or a service threshold reached alongside an active rental). This requires a human review rather than an automatic status change.",
|
||||
"vehicle.no_conflict": "This vehicle's current status already matches the facts. No change is needed."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user