managarten/apps-archived/finance/apps/backend/src/report/report.controller.ts
Till-JS ace7fa8f7f chore: archive finance, mail, moodlit apps and rename voxel-lava
- Move finance, mail, moodlit to apps-archived for later development
- Rename games/voxel-lava to games/voxelava

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 13:13:15 +01:00

50 lines
1.6 KiB
TypeScript

import { Controller, Get, Query, UseGuards, ParseIntPipe, DefaultValuePipe } from '@nestjs/common';
import { JwtAuthGuard, CurrentUser, type CurrentUserData } from '@manacore/shared-nestjs-auth';
import { ReportService } from './report.service';
@Controller('reports')
@UseGuards(JwtAuthGuard)
export class ReportController {
constructor(private readonly reportService: ReportService) {}
@Get('dashboard')
getDashboard(@CurrentUser() user: CurrentUserData) {
return this.reportService.getDashboard(user.userId);
}
@Get('monthly-summary')
getMonthlySummary(
@CurrentUser() user: CurrentUserData,
@Query('year', new DefaultValuePipe(new Date().getFullYear()), ParseIntPipe) year: number,
@Query('month', new DefaultValuePipe(new Date().getMonth() + 1), ParseIntPipe) month: number
) {
return this.reportService.getMonthlySummary(user.userId, year, month);
}
@Get('category-breakdown')
getCategoryBreakdown(
@CurrentUser() user: CurrentUserData,
@Query('startDate') startDate: string,
@Query('endDate') endDate: string,
@Query('type') type?: 'income' | 'expense'
) {
return this.reportService.getCategoryBreakdown(user.userId, startDate, endDate, type);
}
@Get('trends')
getTrends(
@CurrentUser() user: CurrentUserData,
@Query('months', new DefaultValuePipe(6), ParseIntPipe) months: number
) {
return this.reportService.getTrends(user.userId, months);
}
@Get('cash-flow')
getCashFlow(
@CurrentUser() user: CurrentUserData,
@Query('startDate') startDate: string,
@Query('endDate') endDate: string
) {
return this.reportService.getCashFlow(user.userId, startDate, endDate);
}
}