refactor payments module

This commit is contained in:
2025-12-22 17:52:59 +01:00
parent 0828506c21
commit c90b2166c1
28 changed files with 524 additions and 268 deletions

View File

@@ -21,35 +21,35 @@ export enum PaymentStatus {
export class PaymentDto {
@ApiProperty()
@IsString()
id: string;
id!: string;
@ApiProperty({ enum: PaymentType })
@IsEnum(PaymentType)
type: PaymentType;
type!: PaymentType;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty()
@IsNumber()
platformFee: number;
platformFee!: number;
@ApiProperty()
@IsNumber()
netAmount: number;
netAmount!: number;
@ApiProperty()
@IsString()
payerId: string;
payerId!: string;
@ApiProperty({ enum: PayerType })
@IsEnum(PayerType)
payerType: PayerType;
payerType!: PayerType;
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty({ required: false })
@IsOptional()
@@ -58,11 +58,11 @@ export class PaymentDto {
@ApiProperty({ enum: PaymentStatus })
@IsEnum(PaymentStatus)
status: PaymentStatus;
status!: PaymentStatus;
@ApiProperty()
@IsDate()
createdAt: Date;
createdAt!: Date;
@ApiProperty({ required: false })
@IsOptional()
@@ -73,23 +73,23 @@ export class PaymentDto {
export class CreatePaymentInput {
@ApiProperty({ enum: PaymentType })
@IsEnum(PaymentType)
type: PaymentType;
type!: PaymentType;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty()
@IsString()
payerId: string;
payerId!: string;
@ApiProperty({ enum: PayerType })
@IsEnum(PayerType)
payerType: PayerType;
payerType!: PayerType;
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty({ required: false })
@IsOptional()
@@ -99,22 +99,22 @@ export class CreatePaymentInput {
export class CreatePaymentOutput {
@ApiProperty({ type: PaymentDto })
payment: PaymentDto;
payment!: PaymentDto;
}
export class UpdatePaymentStatusInput {
@ApiProperty()
@IsString()
paymentId: string;
paymentId!: string;
@ApiProperty({ enum: PaymentStatus })
@IsEnum(PaymentStatus)
status: PaymentStatus;
status!: PaymentStatus;
}
export class UpdatePaymentStatusOutput {
@ApiProperty({ type: PaymentDto })
payment: PaymentDto;
payment!: PaymentDto;
}
export enum MembershipFeeType {
@@ -132,11 +132,11 @@ export enum MemberPaymentStatus {
export class MembershipFeeDto {
@ApiProperty()
@IsString()
id: string;
id!: string;
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty({ required: false })
@IsOptional()
@@ -145,57 +145,57 @@ export class MembershipFeeDto {
@ApiProperty({ enum: MembershipFeeType })
@IsEnum(MembershipFeeType)
type: MembershipFeeType;
type!: MembershipFeeType;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty()
@IsBoolean()
enabled: boolean;
enabled!: boolean;
@ApiProperty()
@IsDate()
createdAt: Date;
createdAt!: Date;
@ApiProperty()
@IsDate()
updatedAt: Date;
updatedAt!: Date;
}
export class MemberPaymentDto {
@ApiProperty()
@IsString()
id: string;
id!: string;
@ApiProperty()
@IsString()
feeId: string;
feeId!: string;
@ApiProperty()
@IsString()
driverId: string;
driverId!: string;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty()
@IsNumber()
platformFee: number;
platformFee!: number;
@ApiProperty()
@IsNumber()
netAmount: number;
netAmount!: number;
@ApiProperty({ enum: MemberPaymentStatus })
@IsEnum(MemberPaymentStatus)
status: MemberPaymentStatus;
status!: MemberPaymentStatus;
@ApiProperty()
@IsDate()
dueDate: Date;
dueDate!: Date;
@ApiProperty({ required: false })
@IsOptional()
@@ -206,7 +206,7 @@ export class MemberPaymentDto {
export class GetMembershipFeesQuery {
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty({ required: false })
@IsOptional()
@@ -216,16 +216,16 @@ export class GetMembershipFeesQuery {
export class GetMembershipFeesOutput {
@ApiProperty({ type: MembershipFeeDto, nullable: true })
fee: MembershipFeeDto | null;
fee!: MembershipFeeDto | null;
@ApiProperty({ type: [MemberPaymentDto] })
payments: MemberPaymentDto[];
payments!: MemberPaymentDto[];
}
export class UpsertMembershipFeeInput {
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty({ required: false })
@IsOptional()
@@ -234,26 +234,26 @@ export class UpsertMembershipFeeInput {
@ApiProperty({ enum: MembershipFeeType })
@IsEnum(MembershipFeeType)
type: MembershipFeeType;
type!: MembershipFeeType;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
}
export class UpsertMembershipFeeOutput {
@ApiProperty({ type: MembershipFeeDto })
fee: MembershipFeeDto;
fee!: MembershipFeeDto;
}
export class UpdateMemberPaymentInput {
@ApiProperty()
@IsString()
feeId: string;
feeId!: string;
@ApiProperty()
@IsString()
driverId: string;
driverId!: string;
@ApiProperty({ required: false, enum: MemberPaymentStatus })
@IsOptional()
@@ -268,7 +268,7 @@ export class UpdateMemberPaymentInput {
export class UpdateMemberPaymentOutput {
@ApiProperty({ type: MemberPaymentDto })
payment: MemberPaymentDto;
payment!: MemberPaymentDto;
}
export class GetPaymentsQuery {
@@ -290,7 +290,7 @@ export class GetPaymentsQuery {
export class GetPaymentsOutput {
@ApiProperty({ type: [PaymentDto] })
payments: PaymentDto[];
payments!: PaymentDto[];
}
export enum PrizeType {
@@ -302,31 +302,31 @@ export enum PrizeType {
export class PrizeDto {
@ApiProperty()
@IsString()
id: string;
id!: string;
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty()
@IsString()
seasonId: string;
seasonId!: string;
@ApiProperty()
@IsNumber()
position: number;
position!: number;
@ApiProperty()
@IsString()
name: string;
name!: string;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty({ enum: PrizeType })
@IsEnum(PrizeType)
type: PrizeType;
type!: PrizeType;
@ApiProperty({ required: false })
@IsOptional()
@@ -335,7 +335,7 @@ export class PrizeDto {
@ApiProperty()
@IsBoolean()
awarded: boolean;
awarded!: boolean;
@ApiProperty({ required: false })
@IsOptional()
@@ -349,7 +349,7 @@ export class PrizeDto {
@ApiProperty()
@IsDate()
createdAt: Date;
createdAt!: Date;
}
export class GetPrizesQuery {
@@ -365,33 +365,33 @@ export class GetPrizesQuery {
export class GetPrizesOutput {
@ApiProperty({ type: [PrizeDto] })
prizes: PrizeDto[];
prizes!: PrizeDto[];
}
export class CreatePrizeInput {
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty()
@IsString()
seasonId: string;
seasonId!: string;
@ApiProperty()
@IsNumber()
position: number;
position!: number;
@ApiProperty()
@IsString()
name: string;
name!: string;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty({ enum: PrizeType })
@IsEnum(PrizeType)
type: PrizeType;
type!: PrizeType;
@ApiProperty({ required: false })
@IsOptional()
@@ -401,34 +401,34 @@ export class CreatePrizeInput {
export class CreatePrizeOutput {
@ApiProperty({ type: PrizeDto })
prize: PrizeDto;
prize!: PrizeDto;
}
export class AwardPrizeInput {
@ApiProperty()
@IsString()
prizeId: string;
prizeId!: string;
@ApiProperty()
@IsString()
driverId: string;
driverId!: string;
}
export class AwardPrizeOutput {
@ApiProperty({ type: PrizeDto })
prize: PrizeDto;
prize!: PrizeDto;
}
export class DeletePrizeInput {
@ApiProperty()
@IsString()
prizeId: string;
prizeId!: string;
}
export class DeletePrizeOutput {
@ApiProperty()
@IsBoolean()
success: boolean;
success!: boolean;
}
export enum TransactionType {
@@ -446,57 +446,57 @@ export enum ReferenceType {
export class WalletDto {
@ApiProperty()
@IsString()
id: string;
id!: string;
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty()
@IsNumber()
balance: number;
balance!: number;
@ApiProperty()
@IsNumber()
totalRevenue: number;
totalRevenue!: number;
@ApiProperty()
@IsNumber()
totalPlatformFees: number;
totalPlatformFees!: number;
@ApiProperty()
@IsNumber()
totalWithdrawn: number;
totalWithdrawn!: number;
@ApiProperty()
@IsDate()
createdAt: Date;
createdAt!: Date;
@ApiProperty()
@IsString()
currency: string;
currency!: string;
}
export class TransactionDto {
@ApiProperty()
@IsString()
id: string;
id!: string;
@ApiProperty()
@IsString()
walletId: string;
walletId!: string;
@ApiProperty({ enum: TransactionType })
@IsEnum(TransactionType)
type: TransactionType;
type!: TransactionType;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty()
@IsString()
description: string;
description!: string;
@ApiProperty({ required: false })
@IsOptional()
@@ -510,7 +510,7 @@ export class TransactionDto {
@ApiProperty()
@IsDate()
createdAt: Date;
createdAt!: Date;
}
export class GetWalletQuery {
@@ -521,29 +521,29 @@ export class GetWalletQuery {
export class GetWalletOutput {
@ApiProperty({ type: WalletDto })
wallet: WalletDto;
wallet!: WalletDto;
@ApiProperty({ type: [TransactionDto] })
transactions: TransactionDto[];
transactions!: TransactionDto[];
}
export class ProcessWalletTransactionInput {
@ApiProperty()
@IsString()
leagueId: string;
leagueId!: string;
@ApiProperty({ enum: TransactionType })
@IsEnum(TransactionType)
type: TransactionType;
type!: TransactionType;
@ApiProperty()
@IsNumber()
amount: number;
amount!: number;
@ApiProperty()
@IsString()
@IsNotEmpty()
description: string;
description!: string;
@ApiProperty({ required: false })
@IsOptional()
@@ -558,9 +558,8 @@ export class ProcessWalletTransactionInput {
export class ProcessWalletTransactionOutput {
@ApiProperty({ type: WalletDto })
wallet: WalletDto;
wallet!: WalletDto;
@ApiProperty({ type: TransactionDto })
transaction: TransactionDto;
}
transaction!: TransactionDto;
}