All files / src/domains/projects/controllers budget.controller.ts

0% Statements 0/16
0% Branches 0/22
0% Functions 0/4
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                                                                                   
import { Controller, Get, Post, Param, Body, Req } from '@nestjs/common';
import { ProjectBudgetService } from '../services/project-budget.service';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
 
@Controller('api/v1/budgets')
@ApiTags('Budget')
export class BudgetController {
  constructor(private readonly budgetService: ProjectBudgetService) {}
 
  @Post(':projectId/setup')
  @ApiOperation({ summary: 'Setup budget operation' })
  @ApiResponse({ status: 201, description: 'Operation successful' })
  async setupBudget(
    @Req() req: any,
    @Param('projectId') projectId: string,
    @Body() data: any,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.budgetService.setupBudget(
      tenantId,
      projectId,
      data.estimatedCost,
      data.estimatedRevenue,
    );
  }
 
  @Post(':projectId/expense')
  @ApiOperation({ summary: 'Add expense operation' })
  @ApiResponse({ status: 201, description: 'Operation successful' })
  async addExpense(
    @Req() req: any,
    @Param('projectId') projectId: string,
    @Body('amount') amount: number,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.budgetService.addExpense(tenantId, projectId, amount);
  }
 
  @Get(':projectId/snapshot')
  @ApiOperation({ summary: 'Get snapshot operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async getSnapshot(
    @Req() req: any,
    @Param('projectId') projectId: string,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.budgetService.getSnapshot(tenantId, projectId);
  }
}