mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
refactor(nestjs): validation schema dtos
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
IPaymentsReceivedFilter,
|
||||
PaymentReceiveMailOptsDTO,
|
||||
} from './types/PaymentReceived.types';
|
||||
import { CreatePaymentReceivedDto, EditPaymentReceivedDto } from './dtos/PaymentReceived.dto';
|
||||
|
||||
@Controller('payments-received')
|
||||
@ApiTags('payments-received')
|
||||
@@ -57,7 +58,7 @@ export class PaymentReceivesController {
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new payment received.' })
|
||||
public createPaymentReceived(
|
||||
@Body() paymentReceiveDTO: IPaymentReceivedCreateDTO,
|
||||
@Body() paymentReceiveDTO: CreatePaymentReceivedDto,
|
||||
) {
|
||||
return this.paymentReceivesApplication.createPaymentReceived(
|
||||
paymentReceiveDTO,
|
||||
@@ -68,7 +69,7 @@ export class PaymentReceivesController {
|
||||
@ApiOperation({ summary: 'Edit the given payment received.' })
|
||||
public editPaymentReceive(
|
||||
@Param('id', ParseIntPipe) paymentReceiveId: number,
|
||||
@Body() paymentReceiveDTO: IPaymentReceivedEditDTO,
|
||||
@Body() paymentReceiveDTO: EditPaymentReceivedDto,
|
||||
) {
|
||||
return this.paymentReceivesApplication.editPaymentReceive(
|
||||
paymentReceiveId,
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsArray, IsNotEmpty, ValidateNested } from 'class-validator';
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsDateString, IsNumber, IsOptional } from 'class-validator';
|
||||
import { IsInt } from 'class-validator';
|
||||
import {
|
||||
IsString,
|
||||
IsDateString,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsArray,
|
||||
IsNotEmpty,
|
||||
IsInt,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { ToNumber } from '@/common/decorators/Validators';
|
||||
import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto';
|
||||
|
||||
export class PaymentReceivedEntryDto {
|
||||
@ToNumber()
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id?: number;
|
||||
|
||||
@ToNumber()
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
index?: number;
|
||||
@@ -20,13 +29,16 @@ export class PaymentReceivedEntryDto {
|
||||
paymentReceiveId?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
invoiceId: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
paymentAmount: number;
|
||||
}
|
||||
|
||||
export class CommandPaymentReceivedDto {
|
||||
@ToNumber()
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ description: 'The id of the customer', example: 1 })
|
||||
@@ -40,6 +52,7 @@ export class CommandPaymentReceivedDto {
|
||||
paymentDate: Date | string;
|
||||
|
||||
@IsOptional()
|
||||
@ToNumber()
|
||||
@IsNumber()
|
||||
@ApiProperty({
|
||||
description: 'The amount of the payment received',
|
||||
@@ -48,6 +61,7 @@ export class CommandPaymentReceivedDto {
|
||||
amount?: number;
|
||||
|
||||
@IsOptional()
|
||||
@ToNumber()
|
||||
@IsNumber()
|
||||
@ApiProperty({
|
||||
description: 'The exchange rate of the payment received',
|
||||
@@ -63,6 +77,7 @@ export class CommandPaymentReceivedDto {
|
||||
})
|
||||
referenceNo?: string;
|
||||
|
||||
@ToNumber()
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({
|
||||
@@ -72,6 +87,7 @@ export class CommandPaymentReceivedDto {
|
||||
depositAccountId: number;
|
||||
|
||||
@IsOptional()
|
||||
@ToNumber()
|
||||
@IsString()
|
||||
@ApiProperty({
|
||||
description: 'The payment receive number of the payment received',
|
||||
@@ -97,6 +113,7 @@ export class CommandPaymentReceivedDto {
|
||||
entries: PaymentReceivedEntryDto[];
|
||||
|
||||
@IsOptional()
|
||||
@ToNumber()
|
||||
@IsInt()
|
||||
@ApiProperty({
|
||||
description: 'The id of the branch',
|
||||
|
||||
Reference in New Issue
Block a user