Initial commit: HOA Financial Intelligence Platform MVP
Multi-tenant financial management platform for homeowner associations featuring: - NestJS backend with 16 modules (auth, accounts, transactions, budgets, units, invoices, payments, vendors, reserves, investments, capital projects, reports) - React + Mantine frontend with dashboard, CRUD pages, and financial reports - Schema-per-tenant PostgreSQL isolation with JWT-based tenant resolution - Docker Compose infrastructure (nginx, backend, frontend, postgres, redis) - Comprehensive seed data for Sunrise Valley HOA demo - 39 API endpoints with Swagger documentation - Double-entry bookkeeping with journal entries - Budget vs actual reporting and Sankey cash flow visualization Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Controller, Get, Post, Param, UseGuards, Request } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { FiscalPeriodsService } from './fiscal-periods.service';
|
||||
|
||||
@ApiTags('fiscal-periods')
|
||||
@Controller('fiscal-periods')
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class FiscalPeriodsController {
|
||||
constructor(private fpService: FiscalPeriodsService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'List all fiscal periods' })
|
||||
findAll() {
|
||||
return this.fpService.findAll();
|
||||
}
|
||||
|
||||
@Post(':id/close')
|
||||
@ApiOperation({ summary: 'Close a fiscal period' })
|
||||
close(@Param('id') id: string, @Request() req: any) {
|
||||
return this.fpService.close(id, req.user.sub);
|
||||
}
|
||||
|
||||
@Post(':id/lock')
|
||||
@ApiOperation({ summary: 'Lock a fiscal period (audit lock)' })
|
||||
lock(@Param('id') id: string, @Request() req: any) {
|
||||
return this.fpService.lock(id, req.user.sub);
|
||||
}
|
||||
}
|
||||
10
backend/src/modules/fiscal-periods/fiscal-periods.module.ts
Normal file
10
backend/src/modules/fiscal-periods/fiscal-periods.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { FiscalPeriodsController } from './fiscal-periods.controller';
|
||||
import { FiscalPeriodsService } from './fiscal-periods.service';
|
||||
|
||||
@Module({
|
||||
controllers: [FiscalPeriodsController],
|
||||
providers: [FiscalPeriodsService],
|
||||
exports: [FiscalPeriodsService],
|
||||
})
|
||||
export class FiscalPeriodsModule {}
|
||||
61
backend/src/modules/fiscal-periods/fiscal-periods.service.ts
Normal file
61
backend/src/modules/fiscal-periods/fiscal-periods.service.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
|
||||
import { TenantService } from '../../database/tenant.service';
|
||||
|
||||
@Injectable()
|
||||
export class FiscalPeriodsService {
|
||||
constructor(private tenant: TenantService) {}
|
||||
|
||||
async findAll() {
|
||||
return this.tenant.query('SELECT * FROM fiscal_periods ORDER BY year DESC, month DESC');
|
||||
}
|
||||
|
||||
async findByDate(date: string) {
|
||||
const d = new Date(date);
|
||||
const rows = await this.tenant.query(
|
||||
'SELECT * FROM fiscal_periods WHERE year = $1 AND month = $2',
|
||||
[d.getFullYear(), d.getMonth() + 1],
|
||||
);
|
||||
if (!rows.length) {
|
||||
throw new NotFoundException(`No fiscal period for ${date}`);
|
||||
}
|
||||
return rows[0];
|
||||
}
|
||||
|
||||
async findOrCreate(year: number, month: number) {
|
||||
let rows = await this.tenant.query(
|
||||
'SELECT * FROM fiscal_periods WHERE year = $1 AND month = $2',
|
||||
[year, month],
|
||||
);
|
||||
if (rows.length) return rows[0];
|
||||
|
||||
rows = await this.tenant.query(
|
||||
`INSERT INTO fiscal_periods (year, month, status) VALUES ($1, $2, 'open') RETURNING *`,
|
||||
[year, month],
|
||||
);
|
||||
return rows[0];
|
||||
}
|
||||
|
||||
async close(id: string, userId: string) {
|
||||
const rows = await this.tenant.query('SELECT * FROM fiscal_periods WHERE id = $1', [id]);
|
||||
if (!rows.length) throw new NotFoundException('Period not found');
|
||||
if (rows[0].status !== 'open') throw new BadRequestException('Period is not open');
|
||||
|
||||
const result = await this.tenant.query(
|
||||
`UPDATE fiscal_periods SET status = 'closed', closed_by = $1, closed_at = NOW() WHERE id = $2 RETURNING *`,
|
||||
[userId, id],
|
||||
);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
async lock(id: string, userId: string) {
|
||||
const rows = await this.tenant.query('SELECT * FROM fiscal_periods WHERE id = $1', [id]);
|
||||
if (!rows.length) throw new NotFoundException('Period not found');
|
||||
if (rows[0].status === 'locked') throw new BadRequestException('Period is already locked');
|
||||
|
||||
const result = await this.tenant.query(
|
||||
`UPDATE fiscal_periods SET status = 'locked', locked_by = $1, locked_at = NOW() WHERE id = $2 RETURNING *`,
|
||||
[userId, id],
|
||||
);
|
||||
return result[0];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user