initial: standalone repo from monorepo split
This commit is contained in:
58
src/invoice/invoice.controller.ts
Normal file
58
src/invoice/invoice.controller.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Patch,
|
||||
Param,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { InvoiceService } from './invoice.service';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { TenantGuard } from '../common/guards/tenant.guard';
|
||||
import { CurrentUser, CurrentUserPayload } from '../common/decorators/current-user.decorator';
|
||||
|
||||
@Controller('invoices')
|
||||
@UseGuards(AuthGuard('jwt'), TenantGuard, RolesGuard)
|
||||
export class InvoiceController {
|
||||
constructor(private readonly invoiceService: InvoiceService) {}
|
||||
|
||||
@Get()
|
||||
@Roles('technician')
|
||||
async findAll(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Query('clientId') clientId?: string,
|
||||
@Query('status') status?: string,
|
||||
) {
|
||||
return this.invoiceService.findAll(user.tenantId, { clientId, status });
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@Roles('technician')
|
||||
async findById(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return this.invoiceService.findById(user.tenantId, id);
|
||||
}
|
||||
|
||||
@Post('generate/:clientId')
|
||||
@Roles('manager')
|
||||
async generate(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('clientId') clientId: string,
|
||||
) {
|
||||
return this.invoiceService.generateForClient(user.tenantId, clientId);
|
||||
}
|
||||
|
||||
@Patch(':id/void')
|
||||
@Roles('tenant_admin')
|
||||
async voidInvoice(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return this.invoiceService.voidInvoice(user.tenantId, id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user