File

src/billing/billing.controller.ts

Prefix

billing

Index

Methods

Methods

Async generateInvoice
generateInvoice(body: literal type)
Decorators :
@Post('generate-invoice')
Parameters :
Name Type Optional
body literal type No
Returns : Promise<any>
Async getBillingSummary
getBillingSummary(orgId: string, periodStart: string, periodEnd: string)
Decorators :
@Get('summary')
Parameters :
Name Type Optional
orgId string No
periodStart string No
periodEnd string No
Returns : unknown
import { Controller, Post, Get, Body, Query, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { BillingService } from './billing.service';
import { CombinedAuthGuard } from '../auth/guards/combined-auth.guard';
import { CurrentUser } from '../auth/decorators/current-user.decorator';

@ApiTags('Billing')
@ApiBearerAuth()
@UseGuards(CombinedAuthGuard)
@Controller('billing')
export class BillingController {
  constructor(private billingService: BillingService) {}

  @Post('generate-invoice')
  async generateInvoice(
    @Body() body: { clientId: string; periodStart: string; periodEnd: string },
  ): Promise<any> {
    return this.billingService.generateInvoice(
      body.clientId,
      new Date(body.periodStart),
      new Date(body.periodEnd),
    );
  }

  @Get('summary')
  async getBillingSummary(
    @CurrentUser('organizationId') orgId: string,
    @Query('periodStart') periodStart: string,
    @Query('periodEnd') periodEnd: string,
  ) {
    const start = periodStart ? new Date(periodStart) : new Date(new Date().getFullYear(), new Date().getMonth(), 1);
    const end = periodEnd ? new Date(periodEnd) : new Date();
    return this.billingService.getBillingSummary(orgId, start, end);
  }
}

results matching ""

    No results matching ""