integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped

This commit is contained in:
2026-01-23 11:44:59 +01:00
parent a0f41f242f
commit 6df38a462a
125 changed files with 4712 additions and 19184 deletions

View File

@@ -4,6 +4,7 @@ import { Result } from '@core/shared/domain/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import { PaymentStatus, PaymentType } from '../../domain/entities/Payment';
import type { PaymentRepository } from '../../domain/repositories/PaymentRepository';
import type { SponsorRepository } from '@core/racing/domain/repositories/SponsorRepository';
export interface SponsorBillingStats {
totalSpent: number;
@@ -55,7 +56,7 @@ export interface GetSponsorBillingResult {
stats: SponsorBillingStats;
}
export type GetSponsorBillingErrorCode = never;
export type GetSponsorBillingErrorCode = 'SPONSOR_NOT_FOUND';
export class GetSponsorBillingUseCase
implements UseCase<GetSponsorBillingInput, GetSponsorBillingResult, GetSponsorBillingErrorCode>
@@ -63,11 +64,20 @@ export class GetSponsorBillingUseCase
constructor(
private readonly paymentRepository: PaymentRepository,
private readonly seasonSponsorshipRepository: SeasonSponsorshipRepository,
private readonly sponsorRepository: SponsorRepository,
) {}
async execute(input: GetSponsorBillingInput): Promise<Result<GetSponsorBillingResult, ApplicationErrorCode<GetSponsorBillingErrorCode>>> {
const { sponsorId } = input;
const sponsor = await this.sponsorRepository.findById(sponsorId);
if (!sponsor) {
return Result.err({
code: 'SPONSOR_NOT_FOUND',
details: { message: 'Sponsor not found' },
});
}
// In this in-memory implementation we derive billing data from payments
// where the sponsor is the payer.
const payments = await this.paymentRepository.findByFilters({