fix transi permit file upload

This commit is contained in:
marshal
2026-07-02 12:22:07 +03:00
parent 4fefe4f827
commit 56bb75c9a8
9 changed files with 271 additions and 123 deletions

View File

@@ -8,6 +8,7 @@ import {
IncidentType,
} from './entities/clearance-incident.entity';
import { ClearanceMilestoneService } from './clearance-milestone.service';
import { persistExportTransportUploads } from './phased-clearance.util';
/**
* Maps a GL post-booking document `code` to the milestone it auto-completes when
@@ -165,7 +166,7 @@ export class GlOperationsService {
*/
async uploadTransportDocument(
bookingId: string,
file: Express.Multer.File,
files: Express.Multer.File[],
): Promise<{ uploaded: boolean; milestoneCompleted: boolean }> {
const booking = await this.getBooking(bookingId);
if (booking.tradeDirection !== 'EXPORT') {
@@ -182,14 +183,11 @@ export class GlOperationsService {
);
}
if (!file) throw new BadRequestException('No transport document uploaded');
if (files.length === 0) {
throw new BadRequestException('No transit permit documents uploaded');
}
await this.filesService.upsertByCode({
resourceId: bookingId,
resource: 'bookings',
code: 'export_transport_document',
file,
});
await persistExportTransportUploads(this.filesService, bookingId, files);
if (wagonAllocated && wagonAllocated.status !== 'COMPLETED') {
await this.milestoneService.completeForBooking(bookingId, 'WAGON_ALLOCATED');