module cleanup

This commit is contained in:
2025-12-19 01:22:45 +01:00
parent d617654928
commit d0fac9e6c1
135 changed files with 5104 additions and 1315 deletions

View File

@@ -5,16 +5,15 @@
*/
import type { IPaymentRepository } from '../../domain/repositories/IPaymentRepository';
import type { PaymentType, PayerType, PaymentStatus, Payment } from '../../domain/entities/Payment';
import type { Payment, PaymentType, PayerType, PaymentStatus } from '../../domain/entities/Payment';
import type {
ICreatePaymentPresenter,
CreatePaymentResultDTO,
CreatePaymentViewModel,
PaymentDto,
} from '../presenters/ICreatePaymentPresenter';
import type { UseCase } from '@core/shared/application/UseCase';
const PLATFORM_FEE_RATE = 0.10;
export interface CreatePaymentInput {
type: PaymentType;
amount: number;
@@ -37,7 +36,8 @@ export class CreatePaymentUseCase
const { type, amount, payerId, payerType, leagueId, seasonId } = input;
const platformFee = amount * PLATFORM_FEE_RATE;
// Calculate platform fee (assume 5% for now)
const platformFee = Math.round(amount * 0.05 * 100) / 100;
const netAmount = amount - platformFee;
const id = `payment-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
@@ -51,29 +51,31 @@ export class CreatePaymentUseCase
payerType,
leagueId,
seasonId,
status: 'pending' as PaymentStatus,
status: PaymentStatus.PENDING,
createdAt: new Date(),
};
const createdPayment = await this.paymentRepository.create(payment);
const dto: CreatePaymentResultDTO = {
payment: {
id: createdPayment.id,
type: createdPayment.type,
amount: createdPayment.amount,
platformFee: createdPayment.platformFee,
netAmount: createdPayment.netAmount,
payerId: createdPayment.payerId,
payerType: createdPayment.payerType,
leagueId: createdPayment.leagueId,
seasonId: createdPayment.seasonId,
status: createdPayment.status,
createdAt: createdPayment.createdAt,
completedAt: createdPayment.completedAt,
},
const dto: PaymentDto = {
id: createdPayment.id,
type: createdPayment.type,
amount: createdPayment.amount,
platformFee: createdPayment.platformFee,
netAmount: createdPayment.netAmount,
payerId: createdPayment.payerId,
payerType: createdPayment.payerType,
leagueId: createdPayment.leagueId,
seasonId: createdPayment.seasonId,
status: createdPayment.status,
createdAt: createdPayment.createdAt,
completedAt: createdPayment.completedAt,
};
presenter.present(dto);
const result: CreatePaymentResultDTO = {
payment: dto,
};
presenter.present(result);
}
}