Spaces:
Sleeping
Sleeping
File size: 15,139 Bytes
122c1d2 16359d2 122c1d2 16359d2 122c1d2 16359d2 122c1d2 16359d2 122c1d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | /**
* Mirrors the backend contract: the `dto.py` and `schemas.py` of each module
* under `cbh/api`.
*
* Every enum there is an `IntEnum`, so pydantic serialises it as a number and
* these numeric enums are the same values, not a parallel vocabulary.
*/
export enum TradeDirection {
IMPORT = 1,
EXPORT = 2,
BOTH = 3,
WAREHOUSE = 4,
}
/** The customs procedure the declaration is filed under. */
export enum CustomsProcedure {
RELEASE_FOR_FREE_CIRCULATION = 1,
EXTERNAL_TRANSIT_T1 = 2,
INTERNAL_TRANSIT_T2 = 3,
CUSTOMS_WAREHOUSE = 4,
}
export enum LineStatus {
OK = 1,
AMBIGUOUS = 2,
INVALID = 3,
EXPIRING = 4,
}
export enum ResolutionMethod {
EXACT_10 = 1,
/** The single declarable code is a real subdivision the tool picked. */
EXPANDED_FROM_PREFIX = 2,
NOT_RESOLVED = 3,
/** Only zeros were added: `6203 42 31` β `6203 42 31 00`. Normalisation. */
PADDED = 4,
}
/** How the code going out relates to the code that came in. */
export enum CodeChange {
UNCHANGED = 1,
/** Only zeros added to reach ten digits β shown plainly, never struck through. */
PADDED = 2,
/** Different digits: a subdivision, a replacement, a pin or a correction. */
CHANGED = 3,
}
export enum WarningSeverity {
INFO = 1,
WARNING = 2,
BLOCKING = 3,
}
export enum WarningType {
ANTIDUMPING = 1,
COUNTERVAILING = 2,
SAFEGUARD = 3,
PHYTOSANITARY = 4,
VETERINARY_CHED = 5,
CITES = 6,
DUAL_USE_OUT_OF_SCOPE = 7,
CODE_EXPIRING_SOON = 8,
CODE_NOT_VALID_AT_DATE = 9,
CODE_REPLACED = 10,
CODE_AMBIGUOUS = 11,
CODE_UNKNOWN = 12,
CODE_NOT_DECLARABLE = 13,
PROHIBITION = 14,
RESTRICTION = 15,
QUOTA = 16,
SURVEILLANCE = 17,
EXCISE = 18,
NO_MEASURES_FOUND = 19,
REFERENCE_DATA_MISSING = 20,
COUNTRY_UNKNOWN = 21,
CHAPTER_OUT_OF_SCOPE = 22,
ADDITIONAL_CODE_REQUIRED = 23,
NVWA_CHAPTER_EXCLUDED = 24,
DESTINATION_UNKNOWN = 25,
RULE_APPLIED = 26,
TRANSIT_DUTY_SUSPENDED = 27,
NATIONAL_MEASURE = 28,
CBAM = 29,
/** On an ambiguous line: a measure that binds only some of the candidates. */
CANDIDATE_MEASURE = 30,
}
export enum DocumentRequirementType {
REQUIRED = 1,
ALTERNATIVE = 2,
EXEMPTION = 3,
SUSPENDED = 4,
/** Only claims a benefit β a preference, a suspension. Never needed to pass. */
OPTIONAL = 5,
/** Owed only for some consignments of the code, e.g. low-value parcels. */
CONDITIONAL = 6,
}
/** What one condition group of a measure asks of the declaration. */
export enum ObligationKind {
/** Without one of the documents the goods are stopped. */
MANDATORY = 1,
/** Without them the goods still pass; they only claim a benefit. */
BENEFIT = 2,
/** Depends on the consignment, not on the code. */
CONDITIONAL = 3,
}
export enum DocumentCodeType {
CERTIFICATE = 1,
NATIONAL = 2,
EXEMPTION = 3,
SPECIAL = 4,
UNKNOWN = 99,
}
export enum ConfidenceLevel {
RED = 1,
AMBER = 2,
GREEN = 3,
}
export enum ReferenceSource {
TARIC = 1,
CODEBOEK = 2,
MANUAL = 3,
NONE = 99,
}
export enum MeasureCategory {
TARIFF_DUTY = 1,
ANTIDUMPING = 2,
COUNTERVAILING = 3,
SAFEGUARD = 4,
PROHIBITION = 5,
RESTRICTION = 6,
VETERINARY_CONTROL = 7,
PHYTOSANITARY_CONTROL = 8,
CITES = 9,
DUAL_USE = 10,
QUOTA = 11,
SURVEILLANCE = 12,
EXCISE = 13,
VAT = 14,
CBAM = 15,
OTHER = 99,
}
export enum RuleAction {
PIN_CODE = 1,
ADD_DOCUMENTS = 2,
REMOVE_DOCUMENTS = 3,
NOTE = 4,
}
export interface LineCheckRequest {
code: string;
originCountry?: string | null;
destinationCountry?: string | null;
direction: TradeDirection;
date?: string | null;
additionalCodes?: string[];
description?: string | null;
clientProfileId?: string | null;
}
export interface CodeCandidate {
code: string;
formattedCode: string;
description?: string | null;
descriptionEn?: string | null;
/** Descriptions from just under the typed prefix down to this code. */
path?: string[];
pathNl?: string[];
/** `path` joined, ready for an option label. */
label?: string | null;
validFrom?: string | null;
validTo?: string | null;
}
export interface DocumentRequirement {
code: string;
documentType: DocumentCodeType;
requirementType: DocumentRequirementType;
description?: string | null;
source: ReferenceSource;
validFrom?: string | null;
validTo?: string | null;
measureSid?: string | null;
measureTypeId?: string | null;
measureTypeDescription?: string | null;
conditionCode?: string | null;
alternativeGroup?: string | null;
/** Where the obligation comes from: the legal act and the publication. */
regulationId?: string | null;
sourceFile?: string | null;
sourcePublishedAt?: string | null;
}
export interface DocumentObligation {
measureSid: string;
measureTypeId: string;
measureTypeDescription?: string | null;
conditionCode: string;
kind: ObligationKind;
/** Documents that meet the obligation: a certificate, a licence. */
satisfiedBy: string[];
/** Codes stating the goods are not concerned. */
exemptedBy: string[];
note?: string | null;
suspended: boolean;
regulationId?: string | null;
}
export interface LineWarning {
type: WarningType;
severity: WarningSeverity;
message: string;
measureSid?: string | null;
measureTypeId?: string | null;
documentCode?: string | null;
relatedCodes: string[];
}
export interface AppliedRule {
ruleId: string;
name: string;
action: RuleAction;
conditions: Record<string, string>;
note?: string | null;
}
export interface AppliedMeasure {
measureSid: string;
goodsCode: string;
measureTypeId: string;
measureTypeDescription?: string | null;
category: MeasureCategory;
geoAreaCode: string;
validFrom?: string | null;
validTo?: string | null;
national?: boolean;
suspended?: boolean;
dutyExpression?: string | null;
quotaOrderNumber?: string | null;
regulationId?: string | null;
sourceFile?: string | null;
sourcePublishedAt?: string | null;
}
/**
* The tariff preference an import line can declare (D/E 4/17): 100 the
* third-country duty, 300 a preference, 320 a preference within a quota.
* The claim the measures allow β the proof of origin is what backs it.
*/
export interface LinePreference {
preferenceCode: string;
preferentialRate?: string | null;
thirdCountryRate?: string | null;
/** Only when the code draws on a quota. */
quotaOrderNumber?: string | null;
agreementArea?: string | null;
agreementDescription?: string | null;
measureSid?: string | null;
regulationId?: string | null;
/** One of these is declared to claim the preference. */
originProofs: DocumentRequirement[];
/** TARIC when read from the measure, MANUAL when from the agreement. */
originProofSource: ReferenceSource;
/** A quota open for the code that the proposed code does not draw on. */
availableQuotaOrderNumber?: string | null;
availableQuotaRate?: string | null;
note?: string | null;
}
export interface LineCheckResponse {
inputCode: string;
originCountry?: string | null;
destinationCountry?: string | null;
measureCountry?: string | null;
direction: TradeDirection;
checkedOn: string;
resolvedCode?: string | null;
formattedCode?: string | null;
codeDescription?: string | null;
resolutionMethod: ResolutionMethod;
candidates: CodeCandidate[];
replacementCodes: string[];
codeChange?: CodeChange;
documentsRequired: DocumentRequirement[];
documentsAlternatives: DocumentRequirement[][];
documentsExemption: DocumentRequirement[];
/** Owed, but deferred by the procedure to the office of destination. */
documentsSuspended: DocumentRequirement[];
documentsOptional: DocumentRequirement[];
documentsConditional: DocumentRequirement[];
obligations: DocumentObligation[];
noneRequired: boolean;
warnings: LineWarning[];
status: LineStatus;
expiringOn?: string | null;
codeConfidence: ConfidenceLevel;
codeConfidenceReason: string;
documentConfidence: ConfidenceLevel;
documentConfidenceReason: string;
source: ReferenceSource;
appliedMeasures: AppliedMeasure[];
appliedRules: AppliedRule[];
preference?: LinePreference | null;
referenceAsOf?: string | null;
}
export interface ReferenceDataStatus {
counts: Record<string, number>;
referenceAsOf?: string | null;
}
export interface GeoArea {
code: string;
name?: string | null;
memberCodes: string[];
}
export interface Paging {
pageSize: number;
pageIndex: number;
totalCount: number;
}
export interface AllObjectsResponse<T> {
paging: Paging;
data: T[];
}
export interface ClientProfile {
id: string;
name: string;
description?: string | null;
/** Canonical field β the client's own column header. */
columnMapping: Record<string, string>;
/** Which sheet row holds the headers. A Softpak pack has metadata above it. */
headerRow: number;
sheetName?: string | null;
missingRequiredFields: string[];
}
// ---------------------------------------------------------------------------
// Shipments: upload, the review table, the export.
// ---------------------------------------------------------------------------
export enum BatchStatus {
UPLOADED = 1,
MAPPING_REQUIRED = 2,
PROCESSING = 3,
COMPLETED = 4,
FAILED = 5,
}
export enum ReviewStage {
NOT_STARTED = 1,
IN_REVIEW = 2,
REVIEWED = 3,
}
export enum BatchSource {
UPLOAD = 1,
MANUAL = 2,
}
export enum ExportFormat {
REVIEW = 1,
SOURCE = 2,
SOFTPAK = 3,
SCOPE = 4,
FITON = 5,
}
export enum RowDecision {
PENDING = 1,
ACCEPTED = 2,
CORRECTED = 3,
}
export enum RuleScope {
CLIENT = 1,
TENANT = 2,
}
export interface ClientProfileRef {
id: string;
name: string;
}
export interface BatchMetrics {
totalLines: number;
uniqueLookups: number;
machineSeconds: number;
reviewSeconds?: number | null;
statusCounts: Record<string, number>;
extractionScore: number;
documentScore: number;
codeConfidenceCounts: Record<string, number>;
documentConfidenceCounts: Record<string, number>;
/** Null when the pack does not state the figure β not the same as zero. */
totalPackages: number | null;
totalGrossWeight: number | null;
totalNetWeight: number | null;
totalValue: number | null;
}
export interface BatchResponse {
id: string;
name: string;
clientProfile: ClientProfileRef;
status: BatchStatus;
source: BatchSource;
sourceFileName?: string | null;
resultFileName?: string | null;
checkDate?: string | null;
defaultDirection: TradeDirection;
destinationCountry?: string | null;
shipmentReference?: string | null;
currency: string;
metrics: BatchMetrics;
errors: string[];
reviewStage: ReviewStage;
reviewStartedAt?: string | null;
reviewFinishedAt?: string | null;
referenceAsOf?: string | null;
datetimeInserted: string;
}
export interface ReviewDocuments {
required: DocumentRequirement[];
alternatives: DocumentRequirement[][];
exemption: DocumentRequirement[];
suspended: DocumentRequirement[];
/** Owed only for some consignments of the code. */
conditional?: DocumentRequirement[];
/** Only claim a benefit; not needed for the goods to pass. */
optional?: DocumentRequirement[];
noneRequired: boolean;
label: string;
}
export interface ReviewRow {
rowIndex: number;
description?: string | null;
inputCode?: string | null;
proposedCode?: string | null;
formattedCode?: string | null;
codeDescription?: string | null;
candidates: string[];
/** The same candidates with their description path, for the picker. */
candidateOptions?: CodeCandidate[];
replacementCodes: string[];
/** Strike the input through only on CHANGED. */
codeChange?: CodeChange;
originCountry?: string | null;
destinationCountry?: string | null;
measureCountry?: string | null;
direction?: TradeDirection | null;
procedure?: CustomsProcedure | null;
codeConfidence: ConfidenceLevel;
codeConfidenceReason: string;
documentConfidence: ConfidenceLevel;
documentConfidenceReason: string;
source: ReferenceSource;
documents: ReviewDocuments;
/** Null on export lines and on rows checked before preferences were read. */
preference?: LinePreference | null;
warnings: LineWarning[];
appliedRules: AppliedRule[];
packages?: number | null;
grossWeight?: number | null;
netWeight?: number | null;
value?: number | null;
decision: RowDecision;
correctedCode?: string | null;
cbamPermitNumber?: string | null;
eudrReference?: string | null;
licenceNumbers: string[];
reviewNote?: string | null;
status: string;
needsReview: boolean;
}
export interface ShipmentTotals {
/** Null when the pack does not state the figure β not the same as zero. */
packages: number | null;
grossWeight: number | null;
netWeight: number | null;
value: number | null;
currency: string;
}
export interface ReviewHeader {
batchId: string;
shipmentReference?: string | null;
name: string;
clientProfile: ClientProfileRef;
status: BatchStatus;
source: BatchSource;
direction: TradeDirection;
procedure: CustomsProcedure;
originCountries: string[];
destinationCountry?: string | null;
checkDate?: string | null;
referenceAsOf?: string | null;
totals: ShipmentTotals;
totalLines: number;
extractionScore: number;
documentScore: number;
codeConfidenceCounts: Record<string, number>;
documentConfidenceCounts: Record<string, number>;
linesNeedingReview: number;
}
export interface ReviewTableResponse {
header: ReviewHeader;
paging: Paging;
rows: ReviewRow[];
}
export interface RowReviewRequest {
correctedCode?: string | null;
decision?: RowDecision | null;
cbamPermitNumber?: string | null;
eudrReference?: string | null;
licenceNumbers?: string[] | null;
reviewNote?: string | null;
}
export interface MakeRuleRequest {
name: string;
description?: string | null;
scope: RuleScope;
action: RuleAction;
pinnedCode?: string | null;
documentCodes: string[];
note?: string | null;
useCodePrefix: boolean;
codePrefixLength: number;
useOriginCountry: boolean;
useDestinationCountry: boolean;
useDirection: boolean;
descriptionContains?: string | null;
createdBy?: string | null;
}
export interface RuleResponse {
id: string;
name: string;
description?: string | null;
action: RuleAction;
conditions: Record<string, string>;
active: boolean;
hitCount: number;
}
export interface ExportFormatResponse {
format: ExportFormat;
name: string;
description: string;
available: boolean;
unavailableReason?: string | null;
isProfileDefault: boolean;
}
export interface ColumnMappingSuggestion {
headers: string[];
suggestedMapping: Record<string, string>;
unmappedHeaders: string[];
missingRequiredFields: string[];
}
export interface UploadOptions {
clientProfileId: string;
file: File;
name?: string;
checkDate?: string;
destinationCountry?: string;
direction?: TradeDirection;
shipmentReference?: string;
}
export interface ReviewQuery {
needsReviewOnly?: boolean;
confidence?: ConfidenceLevel;
pageSize?: number;
pageIndex?: number;
}
|