mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 14:38:12 +00:00
enhance contract clearance and train scheduling logic; add filters for clearance documents and improve booking validation
This commit is contained in:
@@ -848,8 +848,10 @@ export class ContractClearanceService {
|
||||
}
|
||||
|
||||
/**
|
||||
* GL ET clearance hub: every customs (Path B) contract in phased clearance,
|
||||
* including after booking is created.
|
||||
* GL ET clearance hub, Contracts tab: ONE_TIME customs (Path B) contracts in
|
||||
* phased clearance that already carry at least one uploaded clearance
|
||||
* document — a contract still waiting for its first document has nothing to
|
||||
* review, and GENERAL contracts clear per booking, not at contract level.
|
||||
*/
|
||||
async queue(filter: FilterContractDto): Promise<PaginatedContracts> {
|
||||
return this.contractsRepository.findAllPaginated({
|
||||
@@ -857,6 +859,8 @@ export class ContractClearanceService {
|
||||
pageSize: filter.pageSize ?? 100,
|
||||
statuses: [...PHASED_CUSTOMS_CONTRACT_QUEUE_STATUSES],
|
||||
customsClearingEnabled: true,
|
||||
contractKind: 'ONE_TIME',
|
||||
hasClearanceDocuments: true,
|
||||
sortBy: filter.sortBy,
|
||||
sortOrder: filter.sortOrder,
|
||||
});
|
||||
|
||||
@@ -26,6 +26,8 @@ export interface ContractListFilterOptions {
|
||||
tradeDirection?: string;
|
||||
paymentCurrency?: string;
|
||||
customsClearingEnabled?: boolean;
|
||||
/** true → only contracts with at least one uploaded clearance document. */
|
||||
hasClearanceDocuments?: boolean;
|
||||
createdFrom?: string;
|
||||
createdTo?: string;
|
||||
}
|
||||
@@ -284,6 +286,12 @@ export class ContractsRepository extends BaseRepository<Contract> {
|
||||
customsClearingEnabled: options.customsClearingEnabled,
|
||||
});
|
||||
}
|
||||
if (options.hasClearanceDocuments) {
|
||||
qb.andWhere(
|
||||
'EXISTS (SELECT 1 FROM freight.contract_document_review cdr ' +
|
||||
'WHERE cdr.contract_id = contract.id AND cdr.deleted_at IS NULL)',
|
||||
);
|
||||
}
|
||||
if (options.serviceTypeId) {
|
||||
qb.andWhere('contract.service_type_id = :serviceTypeId', {
|
||||
serviceTypeId: options.serviceTypeId,
|
||||
|
||||
Reference in New Issue
Block a user