Class: Edi214StatusMessagesController

Inherits:
ApplicationController show all
Includes:
Edi204Helper
Defined in:
app/controllers/edi_214_status_messages_controller.rb

Instance Method Summary collapse

Methods included from Edi204Helper

#check_record_exists_for_company, #edi_204_exist_for_company, #get_edi_204_counts_data, #get_shipment_status_codes, #get_stops, #get_time_zones

Methods included from AuthentificationHelper

#accessible_company_ids_from_tenant_and_user, #application_mode_from_hostname, #current_company_id_from_accessible_company_ids, #current_tenant_from_user, #current_user_and_locale_from_token

Instance Method Details

#indexObject



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/edi_214_status_messages_controller.rb', line 12

def index
  edi_204_b2_id = params[:edi_204_b2_id]
  shipment_identification_no = params[:sio].to_s
  if check_record_exists_for_company(edi_204_b2_id)
    return render json: { error: 'EDI 204 does not exist for this company' }, status: :not_found
  end

  results = Edi214StatusMessage.fetch_status_messages_with_logs(edi_204_b2_id, shipment_identification_no)
  render json: results
end

#send_status_messageObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/edi_214_status_messages_controller.rb', line 23

def send_status_message
  edi_204_b2_id = params[:edi_204_b2_id]
  edi_204_s5_id = params[:edi_204_s5_id]
  shipment_status_code = params[:shipment_status_code]
  shipment_date = params[:shipment_date]
  shipment_time = params[:shipment_time]
  time_zone = params[:time_zone]
  user = 'Admin'
  if check_record_exists_for_company(edi_204_b2_id)
    return render json: { error: 'EDI 204 does not exist for this company' }, status: :not_found
  end

  Edi214StatusMessage.load_edi_214_status_message(
    edi_204_b2_id: edi_204_b2_id,
    edi_204_s5_id: edi_204_s5_id,
    shipment_status_code: shipment_status_code,
    shipment_date: shipment_date,
    shipment_time: shipment_time,
    time_zone: time_zone,
    user: user
  )
  render json: { message: 'Status message sent successfully' }, status: :ok
end