👨💻 Technical ACs (Gherkin)
Context: A cargo shipment requires email warning notification
GIVEN
A cargo shipment requires email warning notification
Applied to: Retrieve Cargo Segment Data
WHEN
The system processes cargo segment data retrieval
THEN
The system searches through cargo secondary segments to find freight forwarder (N101 type) and consignee (N101 type) information, and identifies segment 07 data
Context: Cargo segment data is being processed for email notifications
GIVEN
Cargo segment data is being processed for email notifications
Applied to: Freight Forwarder Found?
WHEN
The system examines segment type 03 records
THEN
If GCUS-N101 field indicates forwarder type, set freight forwarder found flag to true
Context: Cargo segment data contains consignee information
GIVEN
Cargo segment data contains consignee information
Applied to: Retrieve Cargo Segment Data
WHEN
The system processes segment type 03 records with N101 consignee type
THEN
The system captures the consignee name from GCUS-N102-NAME field and sets consignee found flag
Context: A freight forwarder name is available from cargo segments
GIVEN
A freight forwarder name is available from cargo segments
Applied to: Get Freight Forwarder Broker Short Name
WHEN
The system constructs a lookup key with 'FW=' prefix and freight forwarder name
THEN
The system retrieves broker short name from GCST2RT table, or initializes empty broker name segment if not found
Context: Freight forwarder broker lookup has been performed
GIVEN
Freight forwarder broker lookup has been performed
Applied to: Broker Short Name Available?
WHEN
The system evaluates the retrieved broker information
THEN
If GCT2-BROKER-NAME-SHORT is not spaces, proceed to get detailed broker contact information
Context: Broker short name is available and location ID exists
GIVEN
Broker short name is available and location ID exists
Applied to: Get Freight Forwarder Broker Contact Information
WHEN
The system constructs lookup keys using broker short name with either M1203 location ID or P401 location ID
THEN
The system retrieves broker segment (BK) and internet address segment (B1) from table, and if broker uses internet, sets email recipient to internet address
Context: Cargo information is available for email warning
GIVEN
Cargo information is available for email warning
Applied to: Retrieve Shipment Root Data
WHEN
The system needs shipment details for email content
THEN
The system calls FWCWBIO to retrieve SHIPROOT segment using the waybill key from cargo data
Context: Email warning notification needs to be sent
GIVEN
Email warning notification needs to be sent
Applied to: Format Email Subject Line
WHEN
The system prepares the email subject
THEN
The system sets the email subject to the predefined warning email subject format
Context: Shipment data is available for email warning
GIVEN
Shipment data is available for email warning
Applied to: Format Email Content with Shipment Details
WHEN
The system constructs email content
THEN
The system formats email with header lines, equipment details, waybill information, CCN data, load/empty indicator, content description, origin/destination stations, consignee info, CBP warning message, timestamp, and footer text
Context: Cargo equipment information is available
GIVEN
Cargo equipment information is available
Applied to: Add Equipment Information
WHEN
The system formats email content
THEN
The system adds equipment ID number from GCUSRT-RT071-CAR-ID-NUM-INDEX to the email text
Context: Waybill information is available from cargo data
GIVEN
Waybill information is available from cargo data
Applied to: Add Waybill Information
WHEN
The system formats email content
THEN
The system concatenates road index, station index, and waybill index from GCUSRT-RT072 fields into waybill line data
Context: CCN data is available from message processing
GIVEN
CCN data is available from message processing
Applied to: Add CCN Information
WHEN
The system formats email content
THEN
The system adds the CCN (Container Control Number) from WORK-M10-12-DATA to the email text
Context: Load/empty indicator is available from cargo data
GIVEN
Load/empty indicator is available from cargo data
Applied to: Add Load/Empty Indicator
WHEN
The system formats email content
THEN
The system adds the load/empty code from GCUSRT-VID10-LOAD-EMPTY-CDE to the email text
Context: Content description is available from cargo data
GIVEN
Content description is available from cargo data
Applied to: Add Content Description
WHEN
The system formats email content
THEN
The system adds the long description from GCUS-N1002-LONG-DESC to the email text
Context: Origin station information is available from shipment data
GIVEN
Origin station information is available from shipment data
Applied to: Add Origin Station Information
WHEN
The system formats email content
THEN
The system concatenates origin station name and province/state code into origin station data for the email
Context: Destination station information is available from shipment data
GIVEN
Destination station information is available from shipment data
Applied to: Add Destination Station Information
WHEN
The system formats email content
THEN
The system concatenates destination station name and province/state code into destination station data for the email
Context: Consignee information was found in cargo segments
GIVEN
Consignee information was found in cargo segments
Applied to: Add Consignee Information
WHEN
The system formats email content
THEN
The system adds the consignee name to the email text
Context: K1 segment contains a CBP warning message
GIVEN
K1 segment contains a CBP warning message
Applied to: Add CBP Warning Message
WHEN
The system formats email content
THEN
The system adds the free-form message from K1-02-FREE-FORM-MESSAGE as the CBP warning message data
Context: K3 segment contains date and time information
GIVEN
K3 segment contains date and time information
Applied to: Add Date and Time Information
WHEN
The system formats email content
THEN
The system formats date from machine century, K3-01-DATE, and time from K3-01-TIME into a readable timestamp and adds it to the email
Context: Email content is being finalized
GIVEN
Email content is being finalized
Applied to: Add Footer Text
WHEN
The system completes email formatting
THEN
The system adds predefined footer text to the email content
Context: Broker contact information has been retrieved
GIVEN
Broker contact information has been retrieved
Applied to: Send to Freight Forwarder?
WHEN
The system determines email recipient
THEN
If broker uses internet (GCSTBRT-BK-USE-INTERNET = 'Y'), set email recipient to freight forwarder internet address, otherwise use default system address
Context: Freight forwarder uses internet communication and has valid internet address
GIVEN
Freight forwarder uses internet communication and has valid internet address
Applied to: Set Email Recipient to Freight Forwarder Internet Address
WHEN
The system sets email recipient
THEN
The system sets email destination to 'EXTMAIL' and includes freight forwarder internet address in email header, and sets freight forwarder email flag
Context: Freight forwarder does not use internet communication or internet address is not available
GIVEN
Freight forwarder does not use internet communication or internet address is not available
Applied to: Set Email Recipient to Default System Address
WHEN
The system sets email recipient
THEN
The system sets email recipient to default system Merlin ID
Context: Email content is formatted and recipient is determined
GIVEN
Email content is formatted and recipient is determined
Applied to: Send Email Message
WHEN
The system sends the email warning
THEN
The system calls Merlin email service to send the message and sets do-not-send-warning flag to prevent duplicate sends