This commit is contained in:
2025-12-16 10:50:15 +01:00
parent 775d41e055
commit 8ed6ba1fd1
144 changed files with 5763 additions and 1985 deletions

View File

@@ -0,0 +1,21 @@
/**
* Domain Entity: MemberPayment
*/
export enum MemberPaymentStatus {
PENDING = 'pending',
PAID = 'paid',
OVERDUE = 'overdue',
}
export interface MemberPayment {
id: string;
feeId: string;
driverId: string;
amount: number;
platformFee: number;
netAmount: number;
status: MemberPaymentStatus;
dueDate: Date;
paidAt?: Date;
}

View File

@@ -0,0 +1,20 @@
/**
* Domain Entity: MembershipFee
*/
export enum MembershipFeeType {
SEASON = 'season',
MONTHLY = 'monthly',
PER_RACE = 'per_race',
}
export interface MembershipFee {
id: string;
leagueId: string;
seasonId?: string;
type: MembershipFeeType;
amount: number;
enabled: boolean;
createdAt: Date;
updatedAt: Date;
}

View File

@@ -0,0 +1,35 @@
/**
* Domain Entity: Payment
*/
export enum PaymentType {
SPONSORSHIP = 'sponsorship',
MEMBERSHIP_FEE = 'membership_fee',
}
export enum PayerType {
SPONSOR = 'sponsor',
DRIVER = 'driver',
}
export enum PaymentStatus {
PENDING = 'pending',
COMPLETED = 'completed',
FAILED = 'failed',
REFUNDED = 'refunded',
}
export interface Payment {
id: string;
type: PaymentType;
amount: number;
platformFee: number;
netAmount: number;
payerId: string;
payerType: PayerType;
leagueId: string;
seasonId?: string;
status: PaymentStatus;
createdAt: Date;
completedAt?: Date;
}

View File

@@ -0,0 +1,24 @@
/**
* Domain Entity: Prize
*/
export enum PrizeType {
CASH = 'cash',
MERCHANDISE = 'merchandise',
OTHER = 'other',
}
export interface Prize {
id: string;
leagueId: string;
seasonId: string;
position: number;
name: string;
amount: number;
type: PrizeType;
description?: string;
awarded: boolean;
awardedTo?: string;
awardedAt?: Date;
createdAt: Date;
}

View File

@@ -0,0 +1,37 @@
/**
* Domain Entity: Wallet
*/
export interface Wallet {
id: string;
leagueId: string;
balance: number;
totalRevenue: number;
totalPlatformFees: number;
totalWithdrawn: number;
currency: string;
createdAt: Date;
}
export enum TransactionType {
DEPOSIT = 'deposit',
WITHDRAWAL = 'withdrawal',
PLATFORM_FEE = 'platform_fee',
}
export enum ReferenceType {
SPONSORSHIP = 'sponsorship',
MEMBERSHIP_FEE = 'membership_fee',
PRIZE = 'prize',
}
export interface Transaction {
id: string;
walletId: string;
type: TransactionType;
amount: number;
description: string;
referenceId?: string;
referenceType?: ReferenceType;
createdAt: Date;
}

View File

@@ -0,0 +1,5 @@
export * from './Payment';
export * from './MembershipFee';
export * from './MemberPayment';
export * from './Prize';
export * from './Wallet';

View File

@@ -0,0 +1,2 @@
export * from './entities';
export * from './repositories';

View File

@@ -0,0 +1,21 @@
/**
* Repository Interface: IMembershipFeeRepository
*/
import type { MembershipFee } from '../entities/MembershipFee';
import type { MemberPayment } from '../entities/MemberPayment';
export interface IMembershipFeeRepository {
findById(id: string): Promise<MembershipFee | null>;
findByLeagueId(leagueId: string): Promise<MembershipFee | null>;
create(fee: MembershipFee): Promise<MembershipFee>;
update(fee: MembershipFee): Promise<MembershipFee>;
}
export interface IMemberPaymentRepository {
findById(id: string): Promise<MemberPayment | null>;
findByFeeIdAndDriverId(feeId: string, driverId: string): Promise<MemberPayment | null>;
findByLeagueIdAndDriverId(leagueId: string, driverId: string, membershipFeeRepo: IMembershipFeeRepository): Promise<MemberPayment[]>;
create(payment: MemberPayment): Promise<MemberPayment>;
update(payment: MemberPayment): Promise<MemberPayment>;
}

View File

@@ -0,0 +1,15 @@
/**
* Repository Interface: IPaymentRepository
*/
import type { Payment, PaymentType } from '../entities/Payment';
export interface IPaymentRepository {
findById(id: string): Promise<Payment | null>;
findByLeagueId(leagueId: string): Promise<Payment[]>;
findByPayerId(payerId: string): Promise<Payment[]>;
findByType(type: PaymentType): Promise<Payment[]>;
findByFilters(filters: { leagueId?: string; payerId?: string; type?: PaymentType }): Promise<Payment[]>;
create(payment: Payment): Promise<Payment>;
update(payment: Payment): Promise<Payment>;
}

View File

@@ -0,0 +1,15 @@
/**
* Repository Interface: IPrizeRepository
*/
import type { Prize } from '../entities/Prize';
export interface IPrizeRepository {
findById(id: string): Promise<Prize | null>;
findByLeagueId(leagueId: string): Promise<Prize[]>;
findByLeagueIdAndSeasonId(leagueId: string, seasonId: string): Promise<Prize[]>;
findByPosition(leagueId: string, seasonId: string, position: number): Promise<Prize | null>;
create(prize: Prize): Promise<Prize>;
update(prize: Prize): Promise<Prize>;
delete(id: string): Promise<void>;
}

View File

@@ -0,0 +1,18 @@
/**
* Repository Interface: IWalletRepository
*/
import type { Wallet, Transaction } from '../entities/Wallet';
export interface IWalletRepository {
findById(id: string): Promise<Wallet | null>;
findByLeagueId(leagueId: string): Promise<Wallet | null>;
create(wallet: Wallet): Promise<Wallet>;
update(wallet: Wallet): Promise<Wallet>;
}
export interface ITransactionRepository {
findById(id: string): Promise<Transaction | null>;
findByWalletId(walletId: string): Promise<Transaction[]>;
create(transaction: Transaction): Promise<Transaction>;
}

View File

@@ -0,0 +1,4 @@
export * from './IPaymentRepository';
export * from './IMembershipFeeRepository';
export * from './IPrizeRepository';
export * from './IWalletRepository';