From 5c62b6ac965f99b8c666ab737e4ce24bdf136d1b Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Sat, 17 Jan 2026 22:37:59 -0600 Subject: [PATCH] fix: convert DECIMAL columns to numbers in fuel logs API (refs #49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PostgreSQL DECIMAL columns return as strings from pg driver. - Add Number() conversion for fuelUnits and costPerUnit in toEnhancedResponse() - Add query invalidation for 'all' key to fix dynamic updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- backend/src/features/fuel-logs/domain/fuel-logs.service.ts | 4 ++-- frontend/src/features/fuel-logs/hooks/useFuelLogs.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/features/fuel-logs/domain/fuel-logs.service.ts b/backend/src/features/fuel-logs/domain/fuel-logs.service.ts index bb28d0d..1b70350 100644 --- a/backend/src/features/fuel-logs/domain/fuel-logs.service.ts +++ b/backend/src/features/fuel-logs/domain/fuel-logs.service.ts @@ -282,8 +282,8 @@ export class FuelLogsService { tripDistance: row.trip_distance ?? undefined, fuelType: row.fuel_type as FuelType, fuelGrade: row.fuel_grade ?? undefined, - fuelUnits: row.fuel_units, - costPerUnit: row.cost_per_unit, + fuelUnits: Number(row.fuel_units), + costPerUnit: Number(row.cost_per_unit), totalCost: Number(row.total_cost), locationData: row.location_data ?? undefined, notes: row.notes ?? undefined, diff --git a/frontend/src/features/fuel-logs/hooks/useFuelLogs.tsx b/frontend/src/features/fuel-logs/hooks/useFuelLogs.tsx index b9a0a02..1238811 100644 --- a/frontend/src/features/fuel-logs/hooks/useFuelLogs.tsx +++ b/frontend/src/features/fuel-logs/hooks/useFuelLogs.tsx @@ -45,6 +45,7 @@ export const useFuelLogs = (vehicleId?: string) => { mutationFn: (data: CreateFuelLogRequest) => fuelLogsApi.create(data), onSuccess: (_res, variables) => { queryClient.invalidateQueries({ queryKey: ['fuelLogs', variables.vehicleId] }); + queryClient.invalidateQueries({ queryKey: ['fuelLogs', 'all'] }); queryClient.invalidateQueries({ queryKey: ['fuelLogsStats', variables.vehicleId] }); }, });