src/billing/billing.controller.ts
billing
Methods |
|
| Async generateInvoice | ||||||
generateInvoice(body: literal type)
|
||||||
Decorators :
@Post('generate-invoice')
|
||||||
|
Defined in src/billing/billing.controller.ts:15
|
||||||
|
Parameters :
Returns :
Promise<any>
|
| Async getBillingSummary |
getBillingSummary(orgId: string, periodStart: string, periodEnd: string)
|
Decorators :
@Get('summary')
|
|
Defined in src/billing/billing.controller.ts:26
|
|
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);
}
}