mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 21:15:41 +00:00
feat: enhance booking and audit log functionalities
- Implemented read-only locking for customer-requested container sizes and billing currency in the GlCreateBookingForm component. - Added functionality to lock partner quantities based on shipment requests in the ConsolidationPartnerPanel. - Introduced a new Leave action in the LogPassYardWorkModal to unassign bookings from trains. - Enhanced the AuditLogsPage to support filtering by action and added a Go button for direct navigation to entity detail pages. - Updated WagonCancellationsPage to handle odd-20ft credits requiring partner selection during rebooking. - Improved TrainScheduleV2DetailPage to allow manual loading of cargo and display warnings for unassigned bookings. - Added a new reference field to the audit logs for better searchability and tracking of actions. - Created a migration to add the reference column to the audit logs table and established an index for efficient querying. - Defined a registry for audit reference sources to streamline the retrieval of human identifiers for various entities.
This commit is contained in:
@@ -227,3 +227,85 @@ describe('ContractBookingService — quantity-cap completion', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* The customer's shipment request is the order: GL may not change its container
|
||||
* sizes/quantities or billing currency at completion — only per-unit details.
|
||||
*/
|
||||
describe('ContractBookingService — shipment-request lock at completion', () => {
|
||||
type WithAssert = {
|
||||
assertMatchesShipmentRequest(
|
||||
bookingId: string,
|
||||
dto: {
|
||||
paymentCurrency?: string;
|
||||
containers?: Array<{ containerSize: string; quantity: number }>;
|
||||
bulkLines?: Array<{ cargoWeightTons?: number }>;
|
||||
},
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
const serviceWithRequest = (request: unknown): WithAssert => {
|
||||
const svc = Object.create(ContractBookingService.prototype) as WithAssert & {
|
||||
dataSource: unknown;
|
||||
};
|
||||
svc.dataSource = {
|
||||
getRepository: () => ({ findOne: async () => request }),
|
||||
};
|
||||
return svc;
|
||||
};
|
||||
|
||||
const request = {
|
||||
paymentCurrency: 'USD',
|
||||
requestedLines: {
|
||||
containers: [
|
||||
{ containerSize: '20ft', quantity: 2 },
|
||||
{ containerSize: '40ft', quantity: 1 },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
it('accepts the exact requested quantities and currency', async () => {
|
||||
await expect(
|
||||
serviceWithRequest(request).assertMatchesShipmentRequest('b1', {
|
||||
paymentCurrency: 'USD',
|
||||
containers: [
|
||||
{ containerSize: '40ft', quantity: 1 },
|
||||
{ containerSize: '20ft', quantity: 2 },
|
||||
],
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('rejects changed quantities', async () => {
|
||||
await expect(
|
||||
serviceWithRequest(request).assertMatchesShipmentRequest('b1', {
|
||||
paymentCurrency: 'USD',
|
||||
containers: [
|
||||
{ containerSize: '20ft', quantity: 4 },
|
||||
{ containerSize: '40ft', quantity: 1 },
|
||||
],
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BadRequestException);
|
||||
});
|
||||
|
||||
it('rejects a changed billing currency', async () => {
|
||||
await expect(
|
||||
serviceWithRequest(request).assertMatchesShipmentRequest('b1', {
|
||||
paymentCurrency: 'ETB',
|
||||
containers: [
|
||||
{ containerSize: '20ft', quantity: 2 },
|
||||
{ containerSize: '40ft', quantity: 1 },
|
||||
],
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BadRequestException);
|
||||
});
|
||||
|
||||
it('is a no-op without a linked request', async () => {
|
||||
await expect(
|
||||
serviceWithRequest(null).assertMatchesShipmentRequest('b1', {
|
||||
paymentCurrency: 'ETB',
|
||||
containers: [{ containerSize: '20ft', quantity: 9 }],
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user