mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 23:40:56 +00:00
- Create migration for booking_requests table with necessary fields and indexes. - Implement BookingRequestRepository for database operations related to booking requests. - Develop BookingRequestService to handle business logic for submitting, accepting, rejecting, and canceling booking requests. - Create DTOs for creating booking requests and reviewing them. - Define BookingRequest entity to map to the booking_requests table. - Add UI components for managing shipment requests, including detail and list pages. - Implement OperationDatePicker component for selecting available shipment days.
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { BaseRepository } from '@edr/api-common';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
|
|
import { BookingRequest } from './entities/booking-request.entity';
|
|
|
|
@Injectable()
|
|
export class BookingRequestRepository extends BaseRepository<BookingRequest> {
|
|
constructor(
|
|
@InjectRepository(BookingRequest)
|
|
repository: Repository<BookingRequest>,
|
|
) {
|
|
super(repository);
|
|
}
|
|
|
|
/** All requests on a contract, newest first. */
|
|
async findForContract(contractId: string): Promise<BookingRequest[]> {
|
|
return this.repository.find({
|
|
where: { contractId },
|
|
order: { createdAt: 'DESC' },
|
|
});
|
|
}
|
|
|
|
/** GL queue: pending requests across all contracts, oldest first. */
|
|
async findPending(): Promise<BookingRequest[]> {
|
|
return this.repository.find({
|
|
where: { status: 'PENDING' },
|
|
order: { createdAt: 'ASC' },
|
|
relations: { contract: true },
|
|
});
|
|
}
|
|
|
|
async findById(id: string): Promise<BookingRequest | null> {
|
|
return this.repository.findOne({
|
|
where: { id },
|
|
relations: { contract: true },
|
|
});
|
|
}
|
|
|
|
/** Total rows — used to mint the next sequential reference. */
|
|
async count(): Promise<number> {
|
|
return this.repository.count();
|
|
}
|
|
}
|