👨💻 Technical ACs (Gherkin)
Context: A train export request is received with a specific request type
GIVEN
A train export request is received with a specific request type
Applied to: 46:AEI Request Type Classification
WHEN
The request type equals the AEI request type constant
THEN
Set AEI train send flag to YES, otherwise set AEI train send flag to NO
Context: A user attempts to process a train request with their ACF2 user ID
GIVEN
A user attempts to process a train request with their ACF2 user ID
Applied to: 2:User Security Validation
WHEN
The user's SCAC access is invalid AND the request is not an AEI train send request
THEN
Generate error message 14 (access denied) and set user access flag to NO
Context: A user requests to send a train manifest
GIVEN
A user requests to send a train manifest
Applied to: 2:User Security Validation
WHEN
The user's UTF authorization is not 'U' or 'S' AND the request is not an AEI train send request
THEN
Generate error message 13 (insufficient authorization) and set user access flag to NO
Context: A user requests to send a train manifest that requires special manifest processing
GIVEN
A user requests to send a train manifest that requires special manifest processing
Applied to: 2:User Security Validation
WHEN
The user's special manifest authorization is not 'S' AND the request is not an AEI train send request
THEN
Set user not authorized for special manifest flag to TRUE
Context: A train request is being processed
GIVEN
A train request is being processed
Applied to: 3:Train Origin Validation
WHEN
The train origin field is blank or spaces
THEN
Generate error message 2 (missing train origin) and exit validation
Context: A train origin is provided
GIVEN
A train origin is provided
Applied to: 3:Train Origin Validation
WHEN
The origin is not found in station code table OR the US station code is blank
THEN
Generate error message 2 (invalid train origin)
Context: A train request includes an ETA date
GIVEN
A train request includes an ETA date
Applied to: 4:Estimated Time of Arrival Validation
WHEN
The ETA date equals '000000'
THEN
Generate error message 3 (invalid ETA date) and exit validation
Context: An ETA date and time are provided
GIVEN
An ETA date and time are provided
Applied to: 4:Estimated Time of Arrival Validation
WHEN
The date conversion fails OR ETA time is not numeric OR hour is not 00-23 OR minute is not 00-59
THEN
Generate error message 3 (invalid ETA format)
Context: A valid ETA date is provided and user authorization level is determined
GIVEN
A valid ETA date is provided and user authorization level is determined
Applied to: 4:Estimated Time of Arrival Validation
WHEN
For 'S' authorization: ETA is not within 30 days before to 5 days after current date, OR For other users: ETA is not within 2 days before to 2 days after current date
THEN
Generate error message 4 (for 'S' users) or message 21 (for other users)
Context: Train details including SCAC, train ID, origin, consist number, and creation date
GIVEN
Train details including SCAC, train ID, origin, consist number, and creation date
Applied to: 5:US Customs Train ID Generation
WHEN
A train record with the same US customs train ID already exists AND is not marked as deleted
THEN
Generate error message 6 (duplicate train ID)
Context: A train record with the same US customs train ID exists
GIVEN
A train record with the same US customs train ID exists
Applied to: 5:US Customs Train ID Generation
WHEN
The existing train record is marked as deleted
THEN
Delete the existing train record to allow creation of new record
Context: Train origin station is validated
GIVEN
Train origin station is validated
Applied to: 6:MERLIN Customs ID Validation
WHEN
The station's public MERLIN ID is blank OR the MERLIN ID is not found in MERLIN database
THEN
Generate error message 7 (missing MERLIN ID) or message 8 (MERLIN ID not found)
Context: A train request contains an equipment list
GIVEN
A train request contains an equipment list
Applied to: 47:Equipment Limit Validation
WHEN
The first equipment item is marked as 'no more equipment' OR the 500th equipment item is not marked as 'no more equipment'
THEN
Generate error message 5 (invalid equipment list size)
Context: Equipment is identified as a container
GIVEN
Equipment is identified as a container
Applied to: 8:Container Waybill Retrieval
WHEN
Container is found in container inquiry system
THEN
Retrieve waybill information using container inquiry data, otherwise use container database lookup
Context: Equipment is identified as a car with init and number
GIVEN
Equipment is identified as a car with init and number
Applied to: 9:Car Waybill Retrieval
WHEN
Car waybill lookup is performed
THEN
Retrieve latest waybill excluding temporary, corrector, and incomplete EDI waybills, and if car is loaded empty, treat as waybill not found
Context: A waybill is found for equipment
GIVEN
A waybill is found for equipment
Applied to: 10:Cargo Record Retrieval
WHEN
Cargo lookup is performed using waybill number and equipment ID
THEN
Retrieve first cargo record and set cargo found flag, otherwise set no cargo found flag
Context: Cargo is found for equipment and request action is SEND with no errors
GIVEN
Cargo is found for equipment and request action is SEND with no errors
Applied to: 11:Cargo Attachment to Train
WHEN
Cargo is immediate transport OR already created for IT OR US-Canada-US with release status OR default with release status OR empty equipment OR special manifest at Woburn PQ station OR export at non-Laredo stations
THEN
Skip cargo attachment to train
Context: Equipment information is available
GIVEN
Equipment information is available
Applied to: 12:Equipment Detail Line Building
WHEN
Building equipment detail line
THEN
Include equipment ID, load/empty indicator, equipment type, and format according to container or car type
Context: Equipment ID is provided
GIVEN
Equipment ID is provided
Applied to: 13:Equipment Type Validation
WHEN
Equipment type lookup fails
THEN
Generate error message 35 (for containers) or message 36 (for cars) and set equipment error flag
Context: Equipment type is 'SK' and waybill is found
GIVEN
Equipment type is 'SK' and waybill is found
Applied to: 13:Equipment Type Validation
WHEN
Double stack traffic type is determined
THEN
Add double stack count to appropriate traffic counter (CPRS, CSXT, NS, or HAUL)
Context: Cargo is found for equipment
GIVEN
Cargo is found for equipment
Applied to: 14:Cargo Information Processing
WHEN
Processing cargo information
THEN
Extract US CCN key, load/empty code, bond numbers, and set appropriate bond found flags based on cargo type
Context: Cargo with bond type information is processed
GIVEN
Cargo with bond type information is processed
Applied to: 15:Bond Type Classification
WHEN
Bond type is US-Canada-US and not created for IT and not special TR
THEN
Set TR bond found flag, and when bond type is transport export and not created for IT, set TE bond found flag
Context: Cargo is being processed
GIVEN
Cargo is being processed
Applied to: 16:Special Manifest Processing
WHEN
Cargo has special manifest origin flag
THEN
Set special manifest IT found flag, and when cargo is transport export with special manifest flag, set special manifest TE found flag
Context: Cargo is export type with US-Mexico country codes
GIVEN
Cargo is export type with US-Mexico country codes
Applied to: 16:Special Manifest Processing
WHEN
Cargo has special 88 flag
THEN
Set US-Mexico 88 found flag, and when cargo is US-Canada-US with special TR flag, set special TR found flag
Context: Cargo is found and being validated
GIVEN
Cargo is found and being validated
Applied to: 17:Cargo Status Validation
WHEN
Cargo status is pending, deleted, or error
THEN
Generate error message 16 (cargo status invalid)
Context: Cargo with specific bill type is processed
GIVEN
Cargo with specific bill type is processed
Applied to: 18:Bill Type Validation
THEN
Format as 'PPR 7512 15 US-CA-US', when bond type is IT or IE, format as 'AMS [bond_type] [bond_number]', when bond type is TE, TR, or MT, format as 'AMS 7512 [bond_type] [bond_number]'
Context: Equipment with cargo is being processed
GIVEN
Equipment with cargo is being processed
Applied to: 19:Equipment Load Status Validation
WHEN
Cargo is empty equipment or empty residue type
THEN
Set equipment as empty, update counters from loaded to empty, and format info as 'EMPTY'
Context: Cargo is processed at Laredo TX station
GIVEN
Cargo is processed at Laredo TX station
Applied to: 20:Mexico Customs Documentation Check
WHEN
FEN reference number is not found
THEN
Generate error message 46, when KCM reference number is not found, generate error message 47, when cargo has hold border status, generate message 48, when cargo has DSP hold flag, generate message 49, when both hold border and DSP hold exist, generate message 52
Context: Cargo and waybill conditions are evaluated
GIVEN
Cargo and waybill conditions are evaluated
Applied to: 21:Detour Processing Coordination
WHEN
Specific detour conditions are met for TE bond, TR bond, border clearance, US-US movement, or US-Mexico export
THEN
Invoke appropriate detour processing routine (B551, B552, B553, B554, or B555)
Context: Transport export cargo not created for IT with location mismatch
GIVEN
Transport export cargo not created for IT with location mismatch
Applied to: 22:TE Bond Port Change Processing
WHEN
Request action is REPORT
THEN
Generate message 19 with station code, when request action is SEND and user is authorized for special manifest, generate message 20 and spawn port change manifest, when user is not authorized, generate message 43
Context: Transit cargo not created for IT with release status
GIVEN
Transit cargo not created for IT with release status
Applied to: 23:TR Bond Diversion Processing
WHEN
Request action is REPORT
THEN
Generate message 18, when request action is SEND and user is authorized for special manifest, generate message 23 and spawn detour manifest, when user is not authorized, generate message 43
Context: Default cargo type not created for IT
GIVEN
Default cargo type not created for IT
Applied to: 24:Border Clearance Detour Processing
WHEN
Cargo has release status and request action is REPORT
THEN
Generate message 18, when request action is SEND and user is authorized for special manifest, generate message 23 and spawn detour manifest, when user is not authorized, generate message 43, when cargo does not have release status, generate message 31
Context: Waybill found with no cargo for US domestic movement
GIVEN
Waybill found with no cargo for US domestic movement
Applied to: 25:US-US Movement Detour Processing
WHEN
Request action is REPORT
THEN
Generate message 18, when request action is SEND and user is authorized for special manifest, generate message 23 and spawn US-US detour manifest, when user is not authorized, generate message 43
Context: Export cargo with US-Mexico country codes without special manifest
GIVEN
Export cargo with US-Mexico country codes without special manifest
Applied to: 26:US-Mexico Export Detour Processing
WHEN
Request action is REPORT
THEN
Generate message 50, when request action is SEND and user is authorized for special manifest, generate message 23 and spawn 88-TR detour manifest, when user is not authorized, generate message 43, when cargo is not export type, generate message 31
Context: Waybill contains routing information
GIVEN
Waybill contains routing information
Applied to: 27:Geographic Route Validation
WHEN
Route contains hazmat code 'HM'
THEN
Set routing indicator to 2, when route has CSXT or NS to CPRS via DET, set indicator to 3 (CSXT) or 4 (NS), otherwise set indicator to 1
Context: Equipment is identified as container or waybill indicates conveying car with loaded status
GIVEN
Equipment is identified as container or waybill indicates conveying car with loaded status
Applied to: 28:Container on Flat Car Processing
WHEN
Container is not found in primary database
THEN
Search container database, if still not found, search inquiry system for container cross-reference, generate error message 11 if no container found
Context: Train processing is complete
GIVEN
Train processing is complete
Applied to: 29:Report Header and Summary Building
WHEN
Building final report
THEN
Include train ID, origin station, user ID, processing date/time, action type (SEND/REPORT), result status, error/warning counts, equipment totals, and ETA information
Context: Train processing completed successfully with SEND action
GIVEN
Train processing completed successfully with SEND action
Applied to: 30:Train Database Record Creation
WHEN
Creating train database record
THEN
Store train header with ID, origin, destination, ETA, AEI flag, and up to maximum equipment items with their cargo details, generate error if equipment limit exceeded
Context: Train record is successfully created in database
GIVEN
Train record is successfully created in database
Applied to: 32:EDI Train List Transmission
WHEN
Transmitting to customs system
THEN
Call EDI transmission module with train list data, generate error if transmission fails
Context: AEI train processing is completed
GIVEN
AEI train processing is completed
Applied to: 37:AEI Activity Logging
WHEN
Logging AEI activity
THEN
Create log entry with train ID, user ID, date/time, action code 'ZZZ', and AEI send message
Context: Train processing is completed successfully
GIVEN
Train processing is completed successfully
Applied to: 33:Report Transmission to Customs
WHEN
Sending report to customs
THEN
Send email to OM01247 with train details, equipment list, and status information, handle large reports with continuation logic
Context: Report exceeds 699 lines
GIVEN
Report exceeds 699 lines
Applied to: 34:Large Report Email Pagination
WHEN
Sending large report
THEN
Send first portion, create continuation message with headers, and send remaining portions with continuation indicators
Context: Train processing is completed
GIVEN
Train processing is completed
Applied to: 35:Report Distribution to Originator
WHEN
Distributing results to originator
THEN
Send appropriate report type (error, sent, or report) to originator terminal or alternate terminal if specified
Context: Request is AEI train send type
GIVEN
Request is AEI train send type
Applied to: 38:AEI Report Processing
WHEN
Processing AEI report
THEN
Retrieve email addresses from AEI work table for train origin, send report to configured addresses, use default addresses if none configured, handle email failures by sending to support
Context: Train processing completed successfully for non-Laredo stations
GIVEN
Train processing completed successfully for non-Laredo stations
Applied to: 39:Canadian Export Report Generation
WHEN
Generating export report
THEN
Spawn GCX141 message for export report generation
Context: Train processing completed successfully at Laredo TX station
GIVEN
Train processing completed successfully at Laredo TX station
Applied to: 40:Enhanced Report Generation
WHEN
Generating enhanced report
THEN
Create detailed report with car/container counts, locomotive counts, port information, ETA details, and equipment details with BOL information
Context: Report data is prepared
GIVEN
Report data is prepared
Applied to: 41:PDF Report Generation
WHEN
Generating PDF reports
THEN
Call GCX904 module to create PDF reports for both pre-exit report (80 character width) and export train report (132 character width)
Context: Error or warning message is generated
GIVEN
Error or warning message is generated
Applied to: 42:Error Message Processing
THEN
Increment appropriate counter (error, warning, info), track special message types (DSP holds), and handle spawn message indicators
Context: Report contains equipment entries
GIVEN
Report contains equipment entries
Applied to: 43:Duplicate Equipment Removal
WHEN
Scanning for duplicates
THEN
Remove duplicate car IDs while preserving first occurrence, skip error/warning/info message lines
Context: Cargo is successfully added to train
GIVEN
Cargo is successfully added to train
Applied to: 44:Activity Audit Logging
WHEN
Logging cargo activity
THEN
Create audit log entry with cargo CCN, user ID, date/time, action code 'ZZZ', and cargo added message
Context: Processing errors occur that require rollback
GIVEN
Processing errors occur that require rollback
Applied to: 45:Database Rollback Processing
THEN
Execute database rollback operation to undo all changes made during current transaction