Files
HOA_Financial_Platform/backend/src/modules/units/units.controller.ts
olsch01 45a267d787 Quality-of-life enhancements: CSV import/export, opening balances, interest rates, mobile UX
- CSV import/export for Units, Projects, and Vendors with match-on-name/number upsert
- Cash Flow report toggle for Cash Only vs Cash + Investments
- Per-account and bulk opening balance setting with as-of date
- Interest rate field on normal accounts with estimated monthly/annual interest display
- Mobile sidebar auto-close on navigation
- Shared CSV parsing/export utility extracted to frontend/src/utils/csv.ts

DB migration needed for existing tenants:
  ALTER TABLE accounts ADD COLUMN IF NOT EXISTS interest_rate DECIMAL(6,4);

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 09:13:51 -05:00

39 lines
1.2 KiB
TypeScript

import { Controller, Get, Post, Put, Delete, Body, Param, Res, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { Response } from 'express';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { UnitsService } from './units.service';
@ApiTags('units')
@Controller('units')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
export class UnitsController {
constructor(private unitsService: UnitsService) {}
@Get()
findAll() { return this.unitsService.findAll(); }
@Get('export')
async exportCSV(@Res() res: Response) {
const csv = await this.unitsService.exportCSV();
res.set({ 'Content-Type': 'text/csv', 'Content-Disposition': 'attachment; filename="units.csv"' });
res.send(csv);
}
@Get(':id')
findOne(@Param('id') id: string) { return this.unitsService.findOne(id); }
@Post('import')
importCSV(@Body() rows: any[]) { return this.unitsService.importCSV(rows); }
@Post()
create(@Body() dto: any) { return this.unitsService.create(dto); }
@Put(':id')
update(@Param('id') id: string, @Body() dto: any) { return this.unitsService.update(id, dto); }
@Delete(':id')
delete(@Param('id') id: string) { return this.unitsService.delete(id); }
}