From 2f7690515669c74a41ae92302e34015102c084cb Mon Sep 17 00:00:00 2001 From: "Dennis (via Claude+Gemma)" Date: Sat, 23 May 2026 08:59:35 +0200 Subject: [PATCH] feat(pdf-improvements): Report-PDF-Endpoint verbessern mit besserer Formatierung [tsc:fail] --- .phase27-state.json | 5 +++-- GENERATION_LOG.md | 18 +++++++++++++++ apps/api/src/routes/reports.ts | 41 ++++++++++++++++++++++++++++------ 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/.phase27-state.json b/.phase27-state.json index d8ee978..c2f6afd 100644 --- a/.phase27-state.json +++ b/.phase27-state.json @@ -1,10 +1,11 @@ { "completed_features": [], - "current_feature": "budget-alerts-email", + "current_feature": "pdf-improvements", "started_at": "2026-05-23T08:55:38.459472", "attempted_features": [ "advanced-filters", "bulk-customer-tag", - "search-pagination" + "search-pagination", + "budget-alerts-email" ] } \ No newline at end of file diff --git a/GENERATION_LOG.md b/GENERATION_LOG.md index debd7f6..a18ea30 100644 --- a/GENERATION_LOG.md +++ b/GENERATION_LOG.md @@ -3170,3 +3170,21 @@ src/index.ts(27,25): error TS2769: No overload matches this call. Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. Type 'Promise' provides no match for the signature '(instance: FastifyInstance, +- `08:59:07` **INFO** Committed feature budget-alerts-email +- `08:59:08` **INFO** Pushed: rc=0 + +## Phase-3 Feature: pdf-improvements (2026-05-23 08:59:08) + +- `08:59:08` **INFO** Description: Report-PDF-Endpoint verbessern mit besserer Formatierung +- `08:59:08` **INFO** Generating apps/api/src/routes/reports.ts (ERWEITERT — behalte alles. Improve text/plain-output: header mit User-…) +- `08:59:33` **INFO** wrote 2809 chars in 25.2s (attempt 1) +- `08:59:33` **INFO** Running tsc --noEmit on api… +- `08:59:35` **WARN** tsc errors: +src/db/schema.ts(37,14): error TS7022: 'customers' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +src/db/schema.ts(43,59): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +src/db/schema.ts(47,14): error TS7022: 'projects' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +src/db/schema.ts(51,56): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +src/index.ts(27,25): error TS2769: No overload matches this call. + Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. + Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. + Type 'Promise' provides no match for the signature '(instance: FastifyInstance, diff --git a/apps/api/src/routes/reports.ts b/apps/api/src/routes/reports.ts index ed478fe..ab9fecd 100644 --- a/apps/api/src/routes/reports.ts +++ b/apps/api/src/routes/reports.ts @@ -37,17 +37,44 @@ export default async function reportRoutes(fastify: FastifyInstance) { const dateStr = new Date().toISOString().split('T')[0] const filename = `report-${dateStr}.pdf` - const content = [ - "EmberClone Report", - "=================", - `User: ${user.sub}`, + // Group entries by day + const grouped = entries.reduce((acc, entry) => { + const day = entry.startTime.toISOString().split('T')[0] + if (!acc[day]) acc[day] = [] + acc[day].push(entry) + return acc + }, {} as Record) + + const sortedDays = Object.keys(grouped).sort() + + const header = [ + "EMBERCLONE TIME REPORT", + "======================", + `User: ${user.name || user.sub}`, `Period: ${startDate.toISOString().split('T')[0]} to ${endDate.toISOString().split('T')[0]}`, - `Total Entries: ${entries.length}`, `Total Hours: ${totalHours.toFixed(2)}h`, - "\nDetails:", - ...entries.map(e => `[${e.startTime.toISOString().split('T')[0]}] ${e.description || 'No description'} (${e.endTime ? ((e.endTime.getTime() - e.startTime.getTime()) / (1000 * 60 * 60)).toFixed(2) : 'running'}h)`) + "======================\n" ].join("\n") + const body = sortedDays.map(day => { + const dayEntries = grouped[day] + const dayLines = dayEntries.map(e => { + const duration = e.endTime + ? ((e.endTime.getTime() - e.startTime.getTime()) / (1000 * 60 * 60)).toFixed(2) + "h" + : "running" + return ` - ${e.description || 'No description'} (${duration})` + }) + return `${day}\n${dayLines.join("\n")}` + }).join("\n\n") + + const footer = [ + "\n======================", + `Generated at: ${new Date().toISOString()}`, + "End of Report" + ].join("\n") + + const content = `${header}\n${body}\n${footer}` + reply .header("Content-Type", "application/pdf") .header("Content-Disposition", `attachment; filename="${filename}"`)