This commit is contained in:
yaschalew
2026-07-02 13:18:49 +03:00
parent e0010695be
commit 10e442deb1
2 changed files with 10 additions and 7 deletions

View File

@@ -65,6 +65,12 @@ export class FirstMileController {
return this.firstMileService.findById(id);
}
@Get('acceptitem/:id')
@ApiOperation({ summary: 'Get a first-mile accep by ID' })
acceptItem(@Param('id', ParseUUIDPipe) id: string) {
return this.firstMileService.acceptBooking(id);
}
@Post('accept/:reference')
@TrainSchedulingManage()
@ApiOperation({ summary: 'Accept a paid booking and create a first-mile leg' })

View File

@@ -43,7 +43,7 @@ export class FirstMileService {
private readonly vehiclesService: VehiclesService,
private readonly driversService: DriversService,
private readonly smsClient: SmsClientService,
) {}
) { }
/**
* Look up a booking by its human-readable reference and confirm it has been
@@ -95,7 +95,7 @@ export class FirstMileService {
if (booking.paymentStatus !== 'PAID') {
throw new BadRequestException(`Booking ${label} is not paid`);
}
console.log("-------------------", booking)
if (!this.bookingRequestsFirstMile(booking)) {
throw new BadRequestException(`Booking ${label} does not require a first mile`);
}
@@ -212,11 +212,8 @@ export class FirstMileService {
}): boolean {
// Export bookings always need a first mile (pickup → origin yard); the
// pickup address is captured at assignment time, not required upfront.
return Boolean(
booking.tradeDirection === 'EXPORT' ||
booking.firstMilePickupAddress?.trim() ||
booking.serviceType?.includesFirstMile,
);
return Boolean(booking.firstMilePickupAddress?.trim() ||
booking.serviceType?.includesFirstMile);
}
async update(id: string, dto: UpdateFirstMileDto): Promise<FirstMile> {