👨💻 Technical ACs (Gherkin)
Context: EDI 358 processing is initiated
GIVEN
EDI 358 processing is initiated
Applied to: 1:Validate Processing Mode
WHEN
the processing mode is checked
THEN
processing continues only if mode is FOREGROUND or BACKGROUND, otherwise sets wrong mode indicator
Context: a valid processing mode is confirmed
GIVEN
a valid processing mode is confirmed
Applied to: 2:Generate Transmission Number
WHEN
generating transmission number
THEN
use prefix 106 for FOREGROUND mode or prefix 110 for BACKGROUND mode, combined with machine time
Context: a transmission number is generated
GIVEN
a transmission number is generated
Applied to: 3:Insert EDI Root Segment
WHEN
attempting to insert EDI root segment
THEN
if transmission number already exists, increment by 1 and retry until unique number is found
Context: train equipment list is available
GIVEN
train equipment list is available
Applied to: 4:Count Bill of Lading Records
WHEN
counting bill of lading records
THEN
increment count for each equipment item where US-CCN-KEY is not spaces
Context: bill of lading count is calculated
GIVEN
bill of lading count is calculated
Applied to: 5:Process M10 Manifest Header
WHEN
creating M10 manifest header
THEN
set SCAC to 'CPRS', transport type to 'R', country to 'CA', vessel name to customer train ID, voyage number to train creation date, quantity to BOL count, manifest type to 'S', condition response to 'Y', record type to 'TRAIN', and record number to customer train ID
Context: port and timing information is available
GIVEN
port and timing information is available
Applied to: 6:Process P4 Port Information
WHEN
creating P4 port information
THEN
set location to origin service center, quantity to BOL count, time to ETA, ID code to FIRMS code, and for ETA date: if year less than 70 use century 20, if year 70 or greater use century 19, if date is spaces or zeros use century 0
Context: train equipment list contains multiple items
GIVEN
train equipment list contains multiple items
Applied to: More Equipment to Process?
WHEN
processing equipment items
THEN
continue processing while equipment index is less than or equal to total equipment quantity
Context: equipment items are being processed sequentially
GIVEN
equipment items are being processed sequentially
Applied to: Equipment ID Changed?
WHEN
checking current equipment ID
THEN
if current equipment ID is different from last processed equipment ID, process VID record and update last equipment ID
Context: equipment record is being created
GIVEN
equipment record is being created
Applied to: 7:Process Equipment Records
WHEN
assigning equipment number
THEN
if US-CCN-KEY starts with 'CPRS' or car number is spaces, use equipment number from train list, otherwise use car number from cargo record
Context: equipment load/empty status and cargo information is available
GIVEN
equipment load/empty status and cargo information is available
Applied to: 8:Determine Equipment Load Status
WHEN
determining final load status
THEN
if status is 'H' change to 'E', if status is 'E' and CCN key exists and cargo weight greater than 1 change to 'L', otherwise keep original status
Context: equipment has US-CCN-KEY that is not spaces
GIVEN
equipment has US-CCN-KEY that is not spaces
Applied to: 9:Lookup Foreign Carrier Information
WHEN
processing equipment records
THEN
lookup cargo information using the CCN key to retrieve additional equipment details
Context: equipment information is processed and validated
GIVEN
equipment information is processed and validated
Applied to: 10:Create VID Equipment Segment
WHEN
creating VID equipment segment
THEN
populate VID segment with equipment type, initial, processed equipment number, and determined load status
Context: equipment item is being processed
GIVEN
equipment item is being processed
Applied to: Equipment Has Bill of Lading?
WHEN
checking for bill of lading information
THEN
if US-CCN-KEY is not spaces, process MBL bill of lading record
Context: equipment has bill of lading information
GIVEN
equipment has bill of lading information
Applied to: 11:Process Bill of Lading Records
WHEN
processing bill of lading records
THEN
extract SCAC and BOL/Waybill information from equipment data for MBL segment creation
Context: SCAC and port information is available
GIVEN
SCAC and port information is available
Applied to: 12:Determine Automated Carrier Status
WHEN
determining automated carrier status
THEN
if SCAC is 'CPRS' set response to 'Y', otherwise lookup SCAC in table and if automated carrier flag is 'Y' set response to 'Y', else set to 'N'
Context: equipment and bill of lading information is processed
GIVEN
equipment and bill of lading information is processed
Applied to: 13:Apply Special ER Processing Rules
WHEN
applying special ER processing rules
THEN
if equipment status is 'E' and CCN key exists and BOL type is 23, override response code to 'Y'
Context: bill of lading information and automated carrier status is determined
GIVEN
bill of lading information and automated carrier status is determined
Applied to: 14:Create MBL Bill Segment
WHEN
creating MBL bill segment
THEN
populate MBL segment with SCAC, BOL/Waybill number, and determined response code
Context: all EDI segments are created successfully
GIVEN
all EDI segments are created successfully
Applied to: 15:Start EDI Send Function
WHEN
starting EDI send function
THEN
invoke EDI send function with transmission number and high-values security setting
Context: EDI processing is completed
GIVEN
EDI processing is completed
Applied to: 16:Start Log Update Function
WHEN
starting log update function
THEN
if FOREGROUND mode use foreground action code and transaction name, if BACKGROUND mode use background action code and transaction name, include user ID, current date and time
Context: An EDI 358 processing request is initiated
GIVEN
An EDI 358 processing request is initiated
Applied to: Valid Processing Mode?
WHEN
The system checks the processing mode flags
THEN
If none of the valid processing modes (foreground, background, or foreground-02) are set, the system sets wrong FB indicator and exits processing
Context: An ST header segment needs to be created for EDI transmission
GIVEN
An ST header segment needs to be created for EDI transmission
Applied to: Build ST Header Segment
WHEN
The system evaluates the post-emanifest flag in the train list
THEN
If post-emanifest is true, set destination to 'CACUSTOMS2-ST-O', otherwise set destination to 'CACUSTOMS-ST-O'
Context: A manifest transaction is being processed
GIVEN
A manifest transaction is being processed
Applied to: Set Transaction Purpose Code
WHEN
The operation type is ADD
THEN
Set the transaction purpose code to '00'
Applied to: Set Transaction Purpose Code
WHEN
The operation type is DELETE
THEN
Set the transaction purpose code to '03'
Context: A manifest transaction is being processed with operation type CHANGE
GIVEN
A manifest transaction is being processed with operation type CHANGE
Applied to: Set Transaction Purpose Code
WHEN
The system evaluates arrival date and post-emanifest flag
THEN
If arrival date is empty, set purpose code to '04' and mark as not amendment. If arrival date exists and post-emanifest is true, set purpose code to 'CO' and mark as amendment. If arrival date exists and post-emanifest is false, set purpose code to '04' and mark as not amendment
Context: Equipment processing needs to be performed for the manifest
GIVEN
Equipment processing needs to be performed for the manifest
Applied to: Determine EDI Version Processing
WHEN
The system evaluates the post-emanifest flag
THEN
If post-emanifest is true, use 5040 version processing (B231-LOAD-VID-MBL-5040), otherwise use 4040RAIL version processing (B230-LOAD-VID-MBL)
Context: Equipment is being processed in standard 4040RAIL version
GIVEN
Equipment is being processed in standard 4040RAIL version
Applied to: Set Equipment Load Status
WHEN
The system evaluates equipment load status and cargo key
THEN
If equipment is loaded, set status to 'L'. If equipment is empty, set status to 'E'. If equipment is loaded but has no cargo key, override status to 'E'
Context: Equipment is being processed in 5040 post-emanifest version
GIVEN
Equipment is being processed in 5040 post-emanifest version
Applied to: Set Equipment Load Status
WHEN
The system evaluates equipment load status and cargo key
THEN
If equipment is loaded OR (equipment is empty AND has cargo key), set status to 'L'. Otherwise set status to 'E'. If equipment is loaded but has no cargo key, override status to 'E'
Context: Equipment processing is being performed
GIVEN
Equipment processing is being performed
Applied to: Set Equipment Load Status
WHEN
The cargo CCN key starts with '6105I'
THEN
Override the equipment load status to 'E' (empty) regardless of other load status determinations
Context: Equipment has associated cargo information
GIVEN
Equipment has associated cargo information
Applied to: Set Location ID for Equipment
WHEN
The system evaluates the cargo in-transit status
THEN
If in-transit status is 'R', set location ID to '0000'. If in-transit status is 'T', set location ID to the manifest-to-trans-code. For any other status, set location ID to spaces
Context: Equipment is a possible flatcar type in post-emanifest processing
GIVEN
Equipment is a possible flatcar type in post-emanifest processing
Applied to: Handle Flat Car Processing
WHEN
The system checks subsequent equipment for container types
THEN
If any subsequent container equipment is loaded OR (empty with cargo key), set the flatcar status to 'L' (loaded)
Context: A Master Bill of Lading segment is being created
GIVEN
A Master Bill of Lading segment is being created
Applied to: Handle Special SCAC Assignment
WHEN
The system evaluates the CCN key prefix
THEN
If CCN key starts with '2156', set SCAC to 'CFFO', otherwise set SCAC to 'CPRS'
Context: Cargo information indicates in-transit status of 'R' (revenue)
GIVEN
Cargo information indicates in-transit status of 'R' (revenue)
Applied to: Handle Revenue Transit Status
WHEN
The system processes the Master Bill of Lading segment
THEN
Set BOL/Waybill to 'NA', set response code to 'N', and if post-emanifest, set exception code to '08'
Context: Cargo information indicates haulage rights exist
GIVEN
Cargo information indicates haulage rights exist
Applied to: Process Haulage Rights
WHEN
The system processes the Master Bill of Lading segment
THEN
Set SCAC to the haulage rights SCAC code and set response code to 'N'
Context: Processing is for the first equipment in an amendment scenario
GIVEN
Processing is for the first equipment in an amendment scenario
Applied to: Build Dummy MBL Segment
WHEN
No cargo key exists for the equipment but amendment processing is required
THEN
Create a dummy MBL segment with SCAC 'CPRS', BOL/Waybill 'NA', and exception code '06'
Context: Amendment processing is required for the first equipment or dummy MBL scenario
GIVEN
Amendment processing is required for the first equipment or dummy MBL scenario
Applied to: Build M13 Amendment Segment
WHEN
The system needs to document the amendment
THEN
Create M13 segment with SCAC 'CPRS', location ID from station code, BOL/WB number from train key, and amendment code '60'
Context: Processing is post-emanifest version and this is the first equipment
GIVEN
Processing is post-emanifest version and this is the first equipment
Applied to: Build N9 Reference Segment
WHEN
The system creates reference information
THEN
Create N9 segment with reference qualifier '76', reference number 'EDT', date from EDA with machine century, time from ETA with '00' seconds, and time code 'ES'
Context: A transmission number needs to be generated for EDI processing
GIVEN
A transmission number needs to be generated for EDI processing
Applied to: Generate Transmission Number
WHEN
The system evaluates the processing mode
THEN
If foreground mode, use prefix 147. If foreground-02 mode, use prefix 2. If background mode, use prefix 146. Append machine time to create unique transmission number
Context: Station information is required for manifest processing
GIVEN
Station information is required for manifest processing
Applied to: Retrieve Station Information
WHEN
The system looks up the station code in the station table
THEN
If station code is not found or returns '0000', generate error message indicating station not found. Otherwise, use the retrieved station information
Context: Equipment has a non-empty cargo CCN key
GIVEN
Equipment has a non-empty cargo CCN key
Applied to: Retrieve Cargo Information
WHEN
The system attempts to retrieve cargo information
THEN
If cargo root is not found, generate error message indicating cargo not found for CCN. Otherwise, set cargo flag to true and use retrieved cargo information
Context: A train processing request is initiated
GIVEN
A train processing request is initiated
Applied to: 1:Validate Foreground/Background Indicator
WHEN
The system checks the processing mode indicator
THEN
Processing continues if mode is foreground or background, otherwise sets wrong indicator error
Context: A train has an origin station code
GIVEN
A train has an origin station code
Applied to: 2:Check Station Code Validity
WHEN
The system looks up the station code in the SE table
THEN
Sets valid port flag to true if found, false if not found
Context: A train has equipment with US CCN keys
GIVEN
A train has equipment with US CCN keys
Applied to: 3:Count Bills of Lading
WHEN
The system evaluates each equipment's cargo type
THEN
Increments BOL count if in-bond type is 'TR' or if cargo is export type and port is valid
Context: A train has a valid port and train ID
GIVEN
A train has a valid port and train ID
Applied to: 4:Determine Train Type
WHEN
The system examines position 23 of the train ID
THEN
Sets train type to export if position 23 is 'T', otherwise sets to transit
Context: A train has been validated for processing mode and station code
GIVEN
A train has been validated for processing mode and station code
Applied to: Valid Bills or Valid Port?
WHEN
The system checks if BOL quantity is greater than 0 or if port is valid
THEN
Proceeds with EDI processing if either condition is true, otherwise skips to logging
Context: EDI processing is required
GIVEN
EDI processing is required
Applied to: 5:Generate Transmission Number
WHEN
The system generates a transmission number
THEN
Uses prefix 106 for foreground or 003 for background, combined with machine time
Context: A unique transmission number has been generated
GIVEN
A unique transmission number has been generated
Applied to: 6:Create EDI Root Segment
WHEN
The system creates the root segment
THEN
Inserts transmission record with transaction set '358' and generated transmission number
Context: EDI root segment has been created and train type determined
GIVEN
EDI root segment has been created and train type determined
Applied to: 7:Build M10 Manifest Header
WHEN
The system builds the M10 segment
THEN
Sets SCAC to 'CPRS', transport type to 'R', country to 'CA', manifest type to 'K' for export trains with valid port or 'S' for others, and application type '28' for export trains with valid port
Context: M10 segment has been created
GIVEN
M10 segment has been created
Applied to: 8:Build P4 Port Information
WHEN
The system builds the P4 segment
THEN
Includes origin station code, estimated arrival date with century calculation, BOL quantity, arrival time, and FIRMS code
Context: P4 segment has been created and equipment list exists
GIVEN
P4 segment has been created and equipment list exists
Applied to: 9:Process Equipment VID Segments
WHEN
The system processes each unique equipment ID
THEN
Creates VID segment with equipment type, initial, number (using cargo car number if available), and load/empty status (E if train shows H, L if train shows E but cargo weight > 1, otherwise train value)
Context: Equipment has associated cargo (US CCN key not spaces)
GIVEN
Equipment has associated cargo (US CCN key not spaces)
Applied to: 10:Process Bill of Lading MBL Segments
WHEN
The system creates MBL segment
THEN
Uses cargo-derived SCAC and BOL for valid ports, otherwise uses train list values, and sets automated response based on SCAC table lookup or special handling for empty cars with BOL type '23'
Context: Equipment has cargo with transport export type
GIVEN
Equipment has cargo with transport export type
Applied to: 11:Process N9 Reference Segments
WHEN
The system processes N9 segment
THEN
Creates N9 segment with reference qualifier 'IB' and entry number from cargo record
Context: Train has valid cargo (BOL quantity > 0) or valid port
GIVEN
Train has valid cargo (BOL quantity > 0) or valid port
Applied to: 12:Update Train Status to SENT
WHEN
The system updates train status
THEN
Sets train status to SENT, enables EDI sending flag, and updates both train database and train list
Context: Train has no valid cargo (BOL quantity = 0) and no valid port
GIVEN
Train has no valid cargo (BOL quantity = 0) and no valid port
Applied to: 13:Update Train Status to ACK
WHEN
The system updates train status
THEN
Sets train status to ACK and determines EDI action based on previous EDI send flag
Context: Train status has been set to ACK
GIVEN
Train status has been set to ACK
Applied to: Delete Required?
WHEN
The system checks previous EDI send flag
THEN
Sets delete required flag if previously marked to send EDI, otherwise sets do not send EDI flag
Context: EDI segments have been created successfully
GIVEN
EDI segments have been created successfully
Applied to: 15:Start EDI Send Function
WHEN
The system starts EDI send function
THEN
Calls EDI send function with high-value security and generated transmission number
Context: Train processing has completed
GIVEN
Train processing has completed
Applied to: 16:Log Transaction Activity
WHEN
The system logs the transaction
THEN
Uses foreground or background action codes, includes user ID, date, time, and appropriate message based on cargo validity
Context: Train is in background mode, has ACK status, AEI send is enabled, EDI is not being sent, and train ID position 23 is 'T'
GIVEN
Train is in background mode, has ACK status, AEI send is enabled, EDI is not being sent, and train ID position 23 is 'T'
Applied to: 17:Process AEI Train Send
WHEN
The system processes AEI train send
THEN
Initiates customs transaction with train information for AEI processing
Context: AEI train send is being processed
GIVEN
AEI train send is being processed
Applied to: 18:Load Car Information for CDN Send
WHEN
The system loads car information
THEN
Includes only non-container equipment with car initial, load/empty status, car number, and car kind classification
Context: Train has been marked as delete required
GIVEN
Train has been marked as delete required
Applied to: 19:Spawn Delete Transaction
WHEN
The system spawns delete transaction
THEN
Calls GCT1121E transaction with train ID and delete action code 'TD'
Context: MBL segment is being processed with a SCAC code
GIVEN
MBL segment is being processed with a SCAC code
Applied to: 21:Check Automated Carrier Status
WHEN
The system checks automated carrier status
THEN
Sets response to 'Y' if SCAC is 'CPRS' or if SCAC table indicates automated carrier, otherwise sets to 'N', with special 'Y' setting for empty cars with BOL type '23'
Context: Train processing has completed and EDI is not being sent
GIVEN
Train processing has completed and EDI is not being sent
Applied to: AEI Train Send Check?
WHEN
The system checks AEI train send eligibility
THEN
Proceeds with AEI processing if train is in background mode and meets AEI criteria
Context: EDI processing and logging have completed
GIVEN
EDI processing and logging have completed
Applied to: Has Valid Cargo?
WHEN
The system determines final status
THEN
Updates to SENT status if BOL quantity > 0 or port is valid, otherwise updates to ACK status