feat(pdf-improvements): Report-PDF-Endpoint verbessern mit besserer Formatierung [tsc:fail]

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 08:59:35 +02:00
parent 43f2e030b1
commit 2f76905156
3 changed files with 55 additions and 9 deletions

View File

@ -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"
]
}

View File

@ -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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,
- `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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,

View File

@ -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<string, typeof entries>)
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}"`)