Project Initialization

This commit is contained in:
Muluhabt
2026-05-12 15:17:16 +03:00
parent 33fa742e8a
commit 3b8b6979db
259 changed files with 15962 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { BaseEntity } from '@edr/api-common';
import { Passenger } from '@edr/types';
import { Column, Entity } from 'typeorm';
@Entity({ name: 'payments' })
export class Payment extends BaseEntity {
@Column({ name: 'ticket_id', type: 'uuid' })
ticketId!: string;
@Column({ name: 'amount', type: 'numeric', precision: 10, scale: 2 })
amount!: number;
@Column({ name: 'currency', type: 'varchar', length: 8, default: 'ETB' })
currency!: string;
@Column({
name: 'status',
type: 'enum',
enum: Passenger.PaymentStatus,
default: Passenger.PaymentStatus.Pending,
})
status!: Passenger.PaymentStatus;
@Column({ name: 'provider', type: 'varchar', length: 64 })
provider!: string;
@Column({ name: 'provider_transaction_id', type: 'varchar', length: 256, nullable: true })
providerTransactionId?: string | null;
@Column({ name: 'paid_at', type: 'timestamptz', nullable: true })
paidAt?: Date | null;
}

View File

@@ -0,0 +1,17 @@
import { Controller, Get, Param, ParseUUIDPipe } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { PaymentsService } from './payments.service';
@ApiTags('payments')
// @UseGuards(JwtAuthGuard) — TODO: integrate @edr/auth
@Controller('payments')
export class PaymentsController {
constructor(private readonly paymentsService: PaymentsService) {}
@Get('ticket/:ticketId')
@ApiOperation({ summary: 'List payments for a ticket' })
findByTicket(@Param('ticketId', ParseUUIDPipe) ticketId: string) {
return this.paymentsService.findByTicket(ticketId);
}
}

View File

@@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Payment } from './entities/payment.entity';
import { PaymentsController } from './payments.controller';
import { PaymentsService } from './payments.service';
@Module({
imports: [TypeOrmModule.forFeature([Payment])],
controllers: [PaymentsController],
providers: [PaymentsService],
exports: [PaymentsService],
})
export class PaymentsModule {}

View File

@@ -0,0 +1,21 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Payment } from './entities/payment.entity';
@Injectable()
export class PaymentsService {
constructor(
@InjectRepository(Payment)
private readonly paymentsRepository: Repository<Payment>,
) {}
/** List payments associated with a ticket. */
findByTicket(ticketId: string): Promise<Payment[]> {
return this.paymentsRepository.find({
where: { ticketId },
order: { createdAt: 'DESC' },
});
}
}