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:
24
backend/src/modules/investments/investments.controller.ts
Normal file
24
backend/src/modules/investments/investments.controller.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Controller, Get, Post, Put, Body, Param, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { InvestmentsService } from './investments.service';
|
||||
|
||||
@ApiTags('investments')
|
||||
@Controller('investment-accounts')
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class InvestmentsController {
|
||||
constructor(private service: InvestmentsService) {}
|
||||
|
||||
@Get()
|
||||
findAll() { return this.service.findAll(); }
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) { return this.service.findOne(id); }
|
||||
|
||||
@Post()
|
||||
create(@Body() dto: any) { return this.service.create(dto); }
|
||||
|
||||
@Put(':id')
|
||||
update(@Param('id') id: string, @Body() dto: any) { return this.service.update(id, dto); }
|
||||
}
|
||||
10
backend/src/modules/investments/investments.module.ts
Normal file
10
backend/src/modules/investments/investments.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { InvestmentsController } from './investments.controller';
|
||||
import { InvestmentsService } from './investments.service';
|
||||
|
||||
@Module({
|
||||
controllers: [InvestmentsController],
|
||||
providers: [InvestmentsService],
|
||||
exports: [InvestmentsService],
|
||||
})
|
||||
export class InvestmentsModule {}
|
||||
46
backend/src/modules/investments/investments.service.ts
Normal file
46
backend/src/modules/investments/investments.service.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { TenantService } from '../../database/tenant.service';
|
||||
|
||||
@Injectable()
|
||||
export class InvestmentsService {
|
||||
constructor(private tenant: TenantService) {}
|
||||
|
||||
async findAll() {
|
||||
return this.tenant.query('SELECT * FROM investment_accounts WHERE is_active = true ORDER BY name');
|
||||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
const rows = await this.tenant.query('SELECT * FROM investment_accounts WHERE id = $1', [id]);
|
||||
if (!rows.length) throw new NotFoundException('Investment account not found');
|
||||
return rows[0];
|
||||
}
|
||||
|
||||
async create(dto: any) {
|
||||
const rows = await this.tenant.query(
|
||||
`INSERT INTO investment_accounts (name, institution, account_number_last4, investment_type,
|
||||
fund_type, principal, interest_rate, maturity_date, purchase_date, current_value, notes)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *`,
|
||||
[dto.name, dto.institution, dto.account_number_last4, dto.investment_type || 'cd',
|
||||
dto.fund_type || 'reserve', dto.principal, dto.interest_rate || 0,
|
||||
dto.maturity_date || null, dto.purchase_date || null, dto.current_value || dto.principal, dto.notes],
|
||||
);
|
||||
return rows[0];
|
||||
}
|
||||
|
||||
async update(id: string, dto: any) {
|
||||
await this.findOne(id);
|
||||
const rows = await this.tenant.query(
|
||||
`UPDATE investment_accounts SET name = COALESCE($2, name), institution = COALESCE($3, institution),
|
||||
account_number_last4 = COALESCE($4, account_number_last4), investment_type = COALESCE($5, investment_type),
|
||||
fund_type = COALESCE($6, fund_type), principal = COALESCE($7, principal),
|
||||
interest_rate = COALESCE($8, interest_rate), maturity_date = COALESCE($9, maturity_date),
|
||||
purchase_date = COALESCE($10, purchase_date), current_value = COALESCE($11, current_value),
|
||||
notes = COALESCE($12, notes), updated_at = NOW()
|
||||
WHERE id = $1 RETURNING *`,
|
||||
[id, dto.name, dto.institution, dto.account_number_last4, dto.investment_type,
|
||||
dto.fund_type, dto.principal, dto.interest_rate, dto.maturity_date, dto.purchase_date,
|
||||
dto.current_value, dto.notes],
|
||||
);
|
||||
return rows[0];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user