refactor
This commit is contained in:
31
apps/api/src/domain/payments/dtos/CreatePaymentInputDTO.ts
Normal file
31
apps/api/src/domain/payments/dtos/CreatePaymentInputDTO.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsEnum, IsNumber, IsString, IsOptional } from 'class-validator';
|
||||
import { PaymentType } from './PaymentType';
|
||||
import { PayerType } from './PayerType';
|
||||
|
||||
export class CreatePaymentInputDTO {
|
||||
@ApiProperty({ enum: PaymentType })
|
||||
@IsEnum(PaymentType)
|
||||
type: PaymentType;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
amount: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
payerId: string;
|
||||
|
||||
@ApiProperty({ enum: PayerType })
|
||||
@IsEnum(PayerType)
|
||||
payerType: PayerType;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
leagueId: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
seasonId?: string;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { PaymentDTO } from './PaymentDTO';
|
||||
|
||||
export class CreatePaymentOutputDTO {
|
||||
@ApiProperty({ type: PaymentDTO })
|
||||
payment: PaymentDTO;
|
||||
}
|
||||
5
apps/api/src/domain/payments/dtos/MemberPaymentStatus.ts
Normal file
5
apps/api/src/domain/payments/dtos/MemberPaymentStatus.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum MemberPaymentStatus {
|
||||
PENDING = 'pending',
|
||||
PAID = 'paid',
|
||||
OVERDUE = 'overdue',
|
||||
}
|
||||
5
apps/api/src/domain/payments/dtos/MembershipFeeType.ts
Normal file
5
apps/api/src/domain/payments/dtos/MembershipFeeType.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum MembershipFeeType {
|
||||
SEASON = 'season',
|
||||
MONTHLY = 'monthly',
|
||||
PER_RACE = 'per_race',
|
||||
}
|
||||
4
apps/api/src/domain/payments/dtos/PayerType.ts
Normal file
4
apps/api/src/domain/payments/dtos/PayerType.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export enum PayerType {
|
||||
SPONSOR = 'sponsor',
|
||||
DRIVER = 'driver',
|
||||
}
|
||||
57
apps/api/src/domain/payments/dtos/PaymentDTO.ts
Normal file
57
apps/api/src/domain/payments/dtos/PaymentDTO.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString, IsNumber, IsEnum, IsOptional, IsDate } from 'class-validator';
|
||||
import { PaymentType } from './PaymentType';
|
||||
import { PayerType } from './PayerType';
|
||||
import { PaymentStatus } from './PaymentStatus';
|
||||
|
||||
export class PaymentDTO {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
id: string;
|
||||
|
||||
@ApiProperty({ enum: PaymentType })
|
||||
@IsEnum(PaymentType)
|
||||
type: PaymentType;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
amount: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
platformFee: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
netAmount: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
payerId: string;
|
||||
|
||||
@ApiProperty({ enum: PayerType })
|
||||
@IsEnum(PayerType)
|
||||
payerType: PayerType;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
leagueId: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
seasonId?: string;
|
||||
|
||||
@ApiProperty({ enum: PaymentStatus })
|
||||
@IsEnum(PaymentStatus)
|
||||
status: PaymentStatus;
|
||||
|
||||
@ApiProperty()
|
||||
@IsDate()
|
||||
createdAt: Date;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsDate()
|
||||
completedAt?: Date;
|
||||
}
|
||||
6
apps/api/src/domain/payments/dtos/PaymentStatus.ts
Normal file
6
apps/api/src/domain/payments/dtos/PaymentStatus.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export enum PaymentStatus {
|
||||
PENDING = 'pending',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
REFUNDED = 'refunded',
|
||||
}
|
||||
4
apps/api/src/domain/payments/dtos/PaymentType.ts
Normal file
4
apps/api/src/domain/payments/dtos/PaymentType.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export enum PaymentType {
|
||||
SPONSORSHIP = 'sponsorship',
|
||||
MEMBERSHIP_FEE = 'membership_fee',
|
||||
}
|
||||
5
apps/api/src/domain/payments/dtos/PrizeType.ts
Normal file
5
apps/api/src/domain/payments/dtos/PrizeType.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum PrizeType {
|
||||
CASH = 'cash',
|
||||
MERCHANDISE = 'merchandise',
|
||||
OTHER = 'other',
|
||||
}
|
||||
5
apps/api/src/domain/payments/dtos/ReferenceType.ts
Normal file
5
apps/api/src/domain/payments/dtos/ReferenceType.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum ReferenceType {
|
||||
SPONSORSHIP = 'sponsorship',
|
||||
MEMBERSHIP_FEE = 'membership_fee',
|
||||
PRIZE = 'prize',
|
||||
}
|
||||
5
apps/api/src/domain/payments/dtos/TransactionType.ts
Normal file
5
apps/api/src/domain/payments/dtos/TransactionType.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum TransactionType {
|
||||
DEPOSIT = 'deposit',
|
||||
WITHDRAWAL = 'withdrawal',
|
||||
PLATFORM_FEE = 'platform_fee',
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString, IsEnum } from 'class-validator';
|
||||
import { PaymentStatus } from './PaymentStatus';
|
||||
|
||||
export class UpdatePaymentStatusInputDTO {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
paymentId: string;
|
||||
|
||||
@ApiProperty({ enum: PaymentStatus })
|
||||
@IsEnum(PaymentStatus)
|
||||
status: PaymentStatus;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { PaymentDTO } from './PaymentDTO';
|
||||
|
||||
export class UpdatePaymentStatusOutputDTO {
|
||||
@ApiProperty({ type: PaymentDTO })
|
||||
payment: PaymentDTO;
|
||||
}
|
||||
Reference in New Issue
Block a user