From d2283626172309ce9f8ed92909c3dfb937eb6b93 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 24 Dec 2025 09:35:46 +0100 Subject: [PATCH] fix: parse customer_rate as float in wizard (v1.3.61) - Fixed customer_rate being returned as string from DB (NUMERIC type) - Added parseFloat() when using customer_rate in calculations - Fixes customer stats showing '-' instead of actual hourly rate - Applied to loadCustomerContext(), displayCaseEntries(), and approveEntry() --- VERSION | 2 +- app/timetracking/frontend/wizard.html | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 0629a74..ee96f2f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.60 \ No newline at end of file +1.3.61 \ No newline at end of file diff --git a/app/timetracking/frontend/wizard.html b/app/timetracking/frontend/wizard.html index a7422c6..d381d40 100644 --- a/app/timetracking/frontend/wizard.html +++ b/app/timetracking/frontend/wizard.html @@ -567,8 +567,9 @@ caseLink = 'Ingen case'; } - // Get hourly rate (customer rate or default) - const hourlyRate = e.customer_rate || currentEntry.customer_rate || defaultHourlyRate; + // Get hourly rate (customer rate or default) - parse as float if string + const rateValue = e.customer_rate || currentEntry.customer_rate || defaultHourlyRate; + const hourlyRate = typeof rateValue === 'string' ? parseFloat(rateValue) : rateValue; return `
@@ -804,7 +805,9 @@ const response = await fetch(`/api/v1/timetracking/wizard/progress/${currentEntry.customer_id}`); const progress = await response.json(); - const hourlyRate = currentEntry.customer_rate || defaultHourlyRate; + // Parse hourly rate as number (may be string from DB) + const rateValue = currentEntry.customer_rate || defaultHourlyRate; + const hourlyRate = typeof rateValue === 'string' ? parseFloat(rateValue) : rateValue; document.getElementById('context-hourly-rate').textContent = hourlyRate.toFixed(2) + ' DKK'; // Vis antal registreringer (vi har ikke timer-totaler i progress endpointet) @@ -1081,7 +1084,8 @@ // Get billable hours and hourly rate from calculation const billableHours = window.entryBillableHours?.[entryId] || entry.original_hours; - const hourlyRate = window.entryHourlyRates?.[entryId] || entry.customer_rate || defaultHourlyRate; + const rateValue = window.entryHourlyRates?.[entryId] || entry.customer_rate || defaultHourlyRate; + const hourlyRate = typeof rateValue === 'string' ? parseFloat(rateValue) : rateValue; // Get travel checkbox state const travelCheckbox = document.getElementById(`travel-${entryId}`);