Bug: Fuel logs display 0.000 for efficiency and gallons due to DECIMAL type mismatch #49
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The fuel logs screen displays incorrect values:
0.00 gallonsinstead of actual total0.000 @ $0.000instead of{gallons} @ ${pricePerGallon}Root Cause Analysis
PostgreSQL DECIMAL columns are returned as strings by the
pgdriver. The backendtoEnhancedResponse()method infuel-logs.service.tsconvertstotal_costto a number but notfuel_unitsorcost_per_unit:Frontend components have defensive checks that fail for strings:
Affected Files
backend/src/features/fuel-logs/domain/fuel-logs.service.ts:273-295Number()conversion onfuel_unitsandcost_per_unitfrontend/src/features/fuel-logs/hooks/useFuelLogs.tsx:46-49Steps to Reproduce
0.00 gallonsfor Total Fuel0.000 @ $0.000instead of actual valuesExpected Behavior
14.5 gallons){gallons} @ ${pricePerGallon}(e.g.,5.500 @ $3.459)Acceptance Criteria
toEnhancedResponse()convertsfuel_unitsandcost_per_unitto numbers usingNumber()Technical Notes
getVehicleStats()method already handles this correctly withNumber(r.fuel_units)totalCost: Number(row.total_cost)useFuelLogs.tsxmutationonSuccessto ensure proper query invalidation