Skip to main content

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:

  1. Viewing and responding to load tenders (EDI 204)
  2. Sending load tender responses (EDI 990)
  3. Updating shipment status (EDI 214)
  4. 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:

  1. Model: Edi204 class with the Edi204Procedures concern
  2. Controller: Edi204Controller with various endpoints
  3. Helper: Edi204Helper with 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 information
  • edi_204_l11: Gets reference numbers associated with the shipment
  • edi_204_nte: Retrieves notes for the shipment
  • edi_204_n1_name_address: Gets address information for involved parties
  • edi_204_s5_oid: Retrieves stop and order information
  • counts: 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

  1. 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
  2. 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)

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:

  1. Model: Edi990LoadTenderResponses class with the Edi990LoadTenderResponsesProcedures concern
  2. Controller: Edi990LoadTenderResponsesController with 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 procedure pr_load_edi_990_tender_response that insert the data to be ready for EDI process.
  • check_if_a_response_exists: check if a response already exists
  • index: list existing responses
  • load_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

  1. 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
  2. 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_response with appropriate parameters
    • Stored procedure pr_load_edi_990_tender_response creates the response record and generates the EDI document
  1. 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:

  1. Model: Edi214StatusMessage class with the Edi214StatusMessageProcedures concern
  2. Controller: Edi214StatusMessagesController with 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

  1. 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
  2. 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_message endpoint
    • Stored procedure pr_load_edi_214_status_message creates the record and generates the EDI document
  1. Status Code Lookup
    • The system uses the get_shipment_status_codes helper 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
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:

  1. Model: EdiInvoice class with the EdiInvoiceProcedures concern
  2. Controller: EdiInvoicesController with 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 system
  • update_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 item
  • show: get invoice details
  • invoice_names: get invoice name information
  • invoice_lines: get invoice line items
  • counts: get counts of related records

Invoice Workflow

  1. 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
  2. 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 show method combines this information:
  3. 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_210 method handles updates to the main invoice fields
    • The update_edi_210_rate_charge method 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

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.