This commit is contained in:
marshal
2026-07-01 20:55:17 +03:00
parent 612df8daff
commit 9c18d086d7
112 changed files with 5654 additions and 1370 deletions

View File

@@ -0,0 +1,54 @@
/** Phased customs uploads stored by raw file `code` on contract/booking resources. */
export type ClearanceWorkflowFileOwner = "customer" | "gl_et" | "gl_dj";
export type ClearanceWorkflowFileCategory =
| "declaration"
| "duty"
| "transit"
| "djibouti";
export interface ClearanceWorkflowFileCatalogEntry {
code: string;
label: string;
uploadedBy: ClearanceWorkflowFileOwner;
category: ClearanceWorkflowFileCategory;
/** Omit when the file applies to both directions. */
tradeDirection?: "IMPORT" | "EXPORT";
}
export const CLEARANCE_WORKFLOW_FILE_CATALOG: ClearanceWorkflowFileCatalogEntry[] = [
{ code: "im4", label: "IM4 Declaration", uploadedBy: "gl_et", category: "declaration", tradeDirection: "IMPORT" },
{ code: "im5", label: "IM5 Declaration", uploadedBy: "gl_et", category: "declaration", tradeDirection: "IMPORT" },
{ code: "ex3", label: "EX3 Declaration", uploadedBy: "gl_et", category: "declaration", tradeDirection: "EXPORT" },
{ code: "ex8", label: "EX8 Declaration", uploadedBy: "gl_et", category: "declaration", tradeDirection: "EXPORT" },
{ code: "duty_tax_notice", label: "Duty / Tax Notice", uploadedBy: "gl_et", category: "duty" },
{ code: "duty_tax_receipt", label: "Duty / Tax Payment Slip", uploadedBy: "customer", category: "duty" },
{ code: "transit_permitted", label: "Transit Permit", uploadedBy: "gl_et", category: "transit" },
{ code: "delivery_order", label: "Delivery Order", uploadedBy: "gl_dj", category: "djibouti", tradeDirection: "IMPORT" },
{ code: "release_order", label: "Release Order", uploadedBy: "gl_dj", category: "djibouti", tradeDirection: "EXPORT" },
];
export interface ClearanceWorkflowFile {
code: string;
label: string;
uploadedBy: ClearanceWorkflowFileOwner;
category: ClearanceWorkflowFileCategory;
file: { id: string; name: string; url: string } | null;
}
const CATALOG_BY_CODE = new Map(
CLEARANCE_WORKFLOW_FILE_CATALOG.map((e) => [e.code, e]),
);
export function clearanceWorkflowFileLabel(code: string | null | undefined): string | null {
if (!code) return null;
return CATALOG_BY_CODE.get(code)?.label ?? null;
}
export function catalogEntriesForTradeDirection(
tradeDirection: string,
): ClearanceWorkflowFileCatalogEntry[] {
return CLEARANCE_WORKFLOW_FILE_CATALOG.filter(
(e) => !e.tradeDirection || e.tradeDirection === tradeDirection,
);
}

View File

@@ -271,6 +271,15 @@ export interface ContractClearanceView {
vesselDepartureDate?: string | null;
roAmendmentRequestedAt?: string | null;
bookingReady?: boolean;
preClearanceFinalized?: boolean;
dutyAdvice?: {
amount: number;
currency: string;
declarationSerial?: string | null;
noticeFile?: { id: string; name: string; url: string } | null;
} | null;
/** Phased customs uploads (IM4, DO, transit permit, etc.) with friendly labels. */
workflowFiles?: import("./clearance-files.catalog").ClearanceWorkflowFile[];
}
export type ClearanceActorRole = "CUSTOMER" | "GL_ET" | "GL_DJ" | "OPERATIONS";

View File

@@ -5,6 +5,7 @@ export * from "./file_upload_settings";
export * from "./overview";
export * from "./etrade";
export * from "./contracts";
export * from "./clearance-files.catalog";
export enum TradeDirection {
IMPORT = "IMPORT",
@@ -526,6 +527,26 @@ export interface ClearanceView {
documents: ClearanceDocument[];
/** True once every required customer document is APPROVED (the 100% gate). */
allApproved: boolean;
/** Phased clearance (GENERAL + customs per-booking). */
phase?: ContractDocPhase | null;
milestones?: IClearanceMilestone[];
nextAction?: ClearanceNextAction | null;
dutyRequired?: boolean | null;
roHold?: boolean;
roHoldReason?: string | null;
vesselDepartureDate?: string | null;
roAmendmentRequestedAt?: string | null;
/** Boundary milestone complete — customer may proceed to operations. */
operationReady?: boolean;
preClearanceFinalized?: boolean;
dutyAdvice?: {
amount: number;
currency: string;
declarationSerial?: string | null;
noticeFile?: { id: string; name: string; url: string } | null;
} | null;
/** Phased customs uploads (IM4, DO, transit permit, etc.) with friendly labels. */
workflowFiles?: import("./clearance-files.catalog").ClearanceWorkflowFile[];
}
/** Company an invoice is billed to (minimal projection). */
@@ -631,7 +652,6 @@ export interface BookingReferenceCargoTypeChild {
id: string;
name: string;
code: string;
show_free_text_box: boolean;
/** How this cargo is measured (PER_TON / PER_ITEM); null when unset. */
unit_of_measure?: CargoUnitOfMeasure | null;
}