import { Body, Controller, Get, Param, Patch, Post, Query } from "@nestjs/common"; import { CurrentUser } from "../common/decorators/current-user.decorator"; import { ok } from "../common/response"; import { CreateHouseholdBudgetDto, CreateInvestmentHoldingDto, CreateNetWorthSnapshotDto, CreatePersonalGoalDto, UpdateHouseholdBudgetDto, UpdatePersonalGoalDto, } from "./dto"; import { PlanningService } from "./planning.service"; @Controller("planning") export class PlanningController { constructor(private readonly planningService: PlanningService) {} @Get("budgets") async budgets(@CurrentUser() userId: string, @Query("householdId") householdId?: string) { return ok(await this.planningService.listBudgets(userId, householdId)); } @Post("budgets") async createBudget(@CurrentUser() userId: string, @Body() body: CreateHouseholdBudgetDto) { return ok(await this.planningService.createBudget(userId, body)); } @Patch("budgets/:id") async updateBudget(@CurrentUser() userId: string, @Param("id") id: string, @Body() body: UpdateHouseholdBudgetDto) { return ok(await this.planningService.updateBudget(userId, id, body)); } @Get("goals") async goals(@CurrentUser() userId: string) { return ok(await this.planningService.listPersonalGoals(userId)); } @Post("goals") async createGoal(@CurrentUser() userId: string, @Body() body: CreatePersonalGoalDto) { return ok(await this.planningService.createPersonalGoal(userId, body)); } @Patch("goals/:id") async updateGoal(@CurrentUser() userId: string, @Param("id") id: string, @Body() body: UpdatePersonalGoalDto) { return ok(await this.planningService.updatePersonalGoal(userId, id, body)); } @Get("investments") async investments(@CurrentUser() userId: string) { return ok(await this.planningService.listInvestments(userId)); } @Post("investments") async createInvestment(@CurrentUser() userId: string, @Body() body: CreateInvestmentHoldingDto) { return ok(await this.planningService.createInvestment(userId, body)); } @Get("net-worth") async netWorth(@CurrentUser() userId: string) { return ok(await this.planningService.netWorthSummary(userId)); } @Post("net-worth/snapshots") async createNetWorthSnapshot(@CurrentUser() userId: string, @Body() body: CreateNetWorthSnapshotDto) { return ok(await this.planningService.createNetWorthSnapshot(userId, body)); } @Get("recurring") async recurring(@CurrentUser() userId: string) { return ok(await this.planningService.listRecurring(userId)); } @Post("recurring/detect") async detectRecurring(@CurrentUser() userId: string) { return ok(await this.planningService.detectRecurring(userId)); } }