initial: standalone repo from monorepo split
This commit is contained in:
81
src/payment/payment.controller.ts
Normal file
81
src/payment/payment.controller.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Patch,
|
||||
Param,
|
||||
Body,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { PaymentService } from './payment.service';
|
||||
import { RecordPaymentDto } from './dto/record-payment.dto';
|
||||
import { CreateRemittanceDto } from './dto/create-remittance.dto';
|
||||
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('payments')
|
||||
@UseGuards(AuthGuard('jwt'), TenantGuard, RolesGuard)
|
||||
export class PaymentController {
|
||||
constructor(private readonly paymentService: PaymentService) {}
|
||||
|
||||
@Get()
|
||||
@Roles('technician')
|
||||
async findAll(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Query('clientId') clientId?: string,
|
||||
) {
|
||||
return this.paymentService.findAll(user.tenantId, { clientId });
|
||||
}
|
||||
|
||||
@Post()
|
||||
@Roles('technician')
|
||||
async record(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Body() dto: RecordPaymentDto,
|
||||
) {
|
||||
return this.paymentService.recordPayment(user.tenantId, user.sub, dto);
|
||||
}
|
||||
|
||||
@Get('unremitted')
|
||||
@Roles('technician')
|
||||
async getUnremitted(@CurrentUser() user: CurrentUserPayload, @Query('collectorId') collectorId?: string) {
|
||||
return this.paymentService.getUnremittedPayments(user.tenantId, collectorId || user.sub);
|
||||
}
|
||||
|
||||
@Get('remittances')
|
||||
@Roles('technician')
|
||||
async findRemittances(@CurrentUser() user: CurrentUserPayload) {
|
||||
return this.paymentService.findRemittances(user.tenantId);
|
||||
}
|
||||
|
||||
@Post('remittances')
|
||||
@Roles('technician')
|
||||
async submitRemittance(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Body() dto: CreateRemittanceDto,
|
||||
) {
|
||||
return this.paymentService.submitRemittance(user.tenantId, user.sub, dto);
|
||||
}
|
||||
|
||||
@Patch('remittances/:id/confirm')
|
||||
@Roles('manager')
|
||||
async confirmRemittance(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return this.paymentService.confirmRemittance(user.tenantId, id, user.sub);
|
||||
}
|
||||
|
||||
@Patch('remittances/:id/reject')
|
||||
@Roles('manager')
|
||||
async rejectRemittance(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return this.paymentService.rejectRemittance(user.tenantId, id, user.sub);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user