EDI Document Processing Interface
This section documents the web interface components of our Transportation Management System (TMS), focusing on how users interact with the EDI documents through our application interface.
Overview
Our web portal provides interfaces for managing the full lifecycle of EDI documents:
- Viewing and responding to load tenders (EDI 204)
- Sending load tender responses (EDI 990)
- Updating shipment status (EDI 214)
- Managing invoices (EDI 210)
Each of these interfaces is supported by controllers and models that handle the business logic and data flow between the web application and the database.
EDI 204 - Load Tender Management
The Load Tender Management interface allows users to view and process EDI 204 documents that have been received from trading partners.
Code Structure
The EDI 204 functionality is implemented through several components:
- Model:
Edi204class with theEdi204Proceduresconcern - Controller:
Edi204Controllerwith various endpoints - Helper:
Edi204Helperwith utility methods
Controller Functionality
The Edi204Controller handles requests related to viewing and processing EDI 204 load tenders:
The controller provides endpoints for different aspects of the load tender:
main_form: Retrieves the main shipment informationedi_204_l11: Gets reference numbers associated with the shipmentedi_204_nte: Retrieves notes for the shipmentedi_204_n1_name_address: Gets address information for involved partiesedi_204_s5_oid: Retrieves stop and order informationcounts: Gets counts of various related records
Database Access
The model uses stored procedures to efficiently retrieve data:
Hub.dbo.pr_get_edi_204_transactions_by_page
Load Tender Workflow
-
Viewing Load Tenders
- Users access the load tender listing screen
- The system displays all load tenders for the user's company
- Users can search, sort, and filter the list
-
Examining Load Tender Details
- When a user selects a specific load tender, the system retrieves detailed information:
- Shipment information (main form)
- Reference numbers (L11 segment)
- Notes (NTE segment)
- Address information (N1 segment)
- Stop and order information (S5/OID segments)
- When a user selects a specific load tender, the system retrieves detailed information:
EDI 990 - Load Tender Response
The Load Tender Response functionality allows users to respond to EDI 204 load tenders with either acceptance or rejection messages.
Code Structure
The EDI 990 functionality is implemented through:
- Model:
Edi990LoadTenderResponsesclass with theEdi990LoadTenderResponsesProceduresconcern - Controller:
Edi990LoadTenderResponsesControllerwith endpoints for creating and viewing responses
Controller Functionality
The Edi990LoadTenderResponsesController handles the creation and management of responses to load tenders:
The controller also provides methods to:
load_edi_tender_response: calls the procedurepr_load_edi_990_tender_responsethat insert the data to be ready for EDI process.check_if_a_response_exists: check if a response already existsindex: list existing responsesload_reject_reasons: load rejection reason codes
Database Access
The model utilizes a stored procedure to create load tender responses:
Hub.dbo.pr_load_edi_990_tender_response
Response Workflow
-
Checking Response Status
- User views a load tender
- System checks if a response already exists using
check_if_a_response_exists - UI adjusts based on response status
-
Creating a Response
- User chooses to accept or reject the load tender
- If rejecting, user selects a rejection reason from predefined codes
- System calls
load_tender_responsewith appropriate parameters - Stored procedure
pr_load_edi_990_tender_responsecreates the response record and generates the EDI document
- Viewing Responses
- Users can view all responses to a specific load tender
- The system shows the response status, including whether it was successfully sent
- For rejected tenders, the system displays the rejection reason
EDI 214 - Shipment Status Updates
The Shipment Status Update functionality allows users to send status updates for shipments in transit.
Code Structure
The EDI 214 functionality is implemented through:
- Model:
Edi214StatusMessageclass with theEdi214StatusMessageProceduresconcern - Controller:
Edi214StatusMessagesControllerwith endpoints for creating and viewing status messages
Controller Functionality
The Edi214StatusMessagesController handles the creation and retrieval of shipment status updates:
The controller also provides methods to:
send_status_message: handles creating a new status update (EDI 214)index: list existing status messages
Database Access
The model uses a stored procedure to create status messages:
Hub.dbo.pr_load_edi_214_status_message
And provides a specialized method to retrieve status messages with their transmission logs:
def fetch_status_messages_with_logs(edi_204_b2_id, shipment_identification_no)
select('edi_214_status_messages.*, vw_edi_out_log.*')
.joins("LEFT JOIN vw_edi_out_log ON vw_edi_out_log.document_ref_id = edi_214_status_messages.edi_214_status_message_id AND vw_edi_out_log.document_code = '#{shipment_identification_no}'")
.where(edi_204_b2_id: edi_204_b2_id)
.map do |item|
item.as_json(methods: [:shipment_status_description, :timezone_description, :status_description])
end
end
Status Message Workflow
-
Viewing Status Messages
- User views a load tender
- System displays any existing status messages for the shipment
- Messages include status codes, timestamps, and transmission status
-
Creating a Status Message
- User selects "Send Status Message" option
- User selects a status code from predefined list (e.g., "Arrived at Pickup Location")
- User enters date, time, and timezone information
- Optionally, user can associate the status with a specific stop
- System calls
send_status_messageendpoint - Stored procedure
pr_load_edi_214_status_messagecreates the record and generates the EDI document
- Status Code Lookup
- The system uses the
get_shipment_status_codeshelper method to retrieve valid status codes - Status codes are stored in the Types Master table with the element 'SHIPMENT STATUS CODE'
- User interface presents these as a dropdown for selection
- The system uses the
def get_shipment_status_codes
TypesMaster.select(:type, :type_description, :description_french).where(
element: 'SHIPMENT STATUS CODE', active: 1
).as_json(
methods: [:type_description]
)
end
EDI 210 - Invoice Management
The Invoice Management functionality allows users to view and manage EDI 210 invoices that have been generated from QuickBooks.
Code Structure
The EDI 210 functionality is implemented through:
- Model:
EdiInvoiceclass with theEdiInvoiceProceduresconcern - Controller:
EdiInvoicesControllerwith endpoints for viewing invoices and related details
Controller Functionality
The EdiInvoicesController handles the retrieval and display of invoice information:
The controller also provides methods to:
index: retrieves paginated edi invoices loaded in our systemupdate_edi_210: updates missing fields (P.O. Number or Shipment ID) when invoice status '03'update_edi_210_rate_charge: updates the charge indicator code for a invoice line itemshow: get invoice detailsinvoice_names: get invoice name informationinvoice_lines: get invoice line itemscounts: get counts of related records
Invoice Workflow
-
Viewing Invoices
- Users access the invoice listing screen
- The system displays all invoices for the user's company
- Users can search, sort, and filter the list
-
Examining Invoice Details
- When a user selects a specific invoice, the system retrieves detailed information:
- Invoice header information
- Bill-to and ship-to information
- Line items with charges
- The
showmethod combines this information:
- When a user selects a specific invoice, the system retrieves detailed information:
-
Updating Invoice Details
- Users can update specific invoice fields under certain conditions:
- Purchase Order Number and Shipment Identification Number: Can only be updated when the invoice status is '03' (indicating missing required information)
- Charge Indicator Code: Can be updated for individual invoice line items at any time
- The
update_edi_210method handles updates to the main invoice fields - The
update_edi_210_rate_chargemethod handles updates to line item charge indicators - After any updates are made, the EDI 210 document will be automatically regenerated and resent to the trading partner
- Users can update specific invoice fields under certain conditions:
This integrated approach ensures that all EDI document interactions are managed through a single cohesive interface, providing users with a streamlined workflow for transportation management.