mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
change contrat creation
This commit is contained in:
@@ -5635,9 +5635,12 @@ export class TrainSchedulingService {
|
||||
// --- validate additions: AVAILABLE, loose, standing in the train's yard ---
|
||||
const added: Wagon[] = [];
|
||||
for (const wagonId of addWagonIds) {
|
||||
// No `relations` on this query: Postgres refuses FOR UPDATE through the
|
||||
// nullable side of the wagonType LEFT JOIN ("FOR UPDATE cannot be
|
||||
// applied to the nullable side of an outer join"). Lock the row alone,
|
||||
// then attach its type with a separate unlocked lookup.
|
||||
const wagon = await manager.getRepository(Wagon).findOne({
|
||||
where: { id: wagonId },
|
||||
relations: { wagonType: true },
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (!wagon) throw new NotFoundException(`Wagon ${wagonId} not found`);
|
||||
@@ -5654,6 +5657,10 @@ export class TrainSchedulingService {
|
||||
`Wagon ${wagon.wagonNumber} is not in the train's yard — only wagons in the same yard can be coupled`,
|
||||
);
|
||||
}
|
||||
wagon.wagonType =
|
||||
(await manager
|
||||
.getRepository(WagonType)
|
||||
.findOne({ where: { id: wagon.wagonTypeId } })) ?? undefined;
|
||||
added.push(wagon);
|
||||
}
|
||||
|
||||
|
||||
@@ -582,6 +582,19 @@ const INTERCITY_DOCUMENT_SETTINGS: OnboardingDocumentSetting[] = [
|
||||
},
|
||||
];
|
||||
|
||||
// ── Hazardous cargo documents ───────────────────────────────────────────────
|
||||
// Asked for in the contract wizard the moment the customer flags the cargo as
|
||||
// hazardous (ONE_TIME contracts only). Fields start empty and are configured in
|
||||
// the backoffice file-settings editor.
|
||||
const HAZARDOUS_DOCUMENT_SETTINGS: OnboardingDocumentSetting[] = [
|
||||
{
|
||||
code: "hazardous_documents",
|
||||
label: "Hazardous cargo documents",
|
||||
entity: CONTRACT_INTAKE_ENTITY,
|
||||
fields: [],
|
||||
},
|
||||
];
|
||||
|
||||
@Injectable()
|
||||
export class FileUploadSettingsSeeder {
|
||||
private readonly logger = new Logger(FileUploadSettingsSeeder.name);
|
||||
@@ -633,6 +646,11 @@ export class FileUploadSettingsSeeder {
|
||||
description:
|
||||
"Documents uploaded against a driver profile (license, ID, contracts, etc.).",
|
||||
})),
|
||||
...HAZARDOUS_DOCUMENT_SETTINGS.map((s) => ({
|
||||
...s,
|
||||
description:
|
||||
"Documents required when a one-time contract's cargo is flagged hazardous.",
|
||||
})),
|
||||
...INTERCITY_DOCUMENT_SETTINGS.map((s) => ({
|
||||
...s,
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user