Class: Logistics::Core::OfferRequestsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::OfferRequestsController
- Defined in:
- app/controllers/logistics/core/offer_requests_controller.rb
Instance Method Summary collapse
- #change_sent_status ⇒ Object
- #change_status ⇒ Object
- #create ⇒ Object
- #get_request_by_security_status ⇒ Object
- #get_request_by_status ⇒ Object
- #get_requests_with_additional_service ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #set_security_status ⇒ Object
- #update ⇒ Object
- #update_demurage_detail ⇒ Object
- #update_storage_detail ⇒ Object
Instance Method Details
#change_sent_status ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 89 def change_sent_status offer_request = OfferRequest.find(params[:offer_request_id]) offer_request.is_sent = true offer_request.sent_date = Date.today offer_request.save response = Mks::Common::MethodResponse.new(true, 'Status changed to sent !',nil,nil,nil) render json: response end |
#change_status ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 77 def change_status status = params[:status] offer_request = OfferRequest.find(params[:offer_request_id]) offer_request.status = status if offer_request.save response = Mks::Common::MethodResponse.new(true, "Status changed to #{status}!", nil, nil, nil) else response = Mks::Common::MethodResponse.new(false, "Status change failure!", nil, nil, nil) end render json: response end |
#create ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 52 def create offer_request = OfferRequest.new(offer_request_params) if offer_request.valid? offer_request.status = 'draft' offer_request.user_id = session[:user_id] offer_request.request_no = ReferenceNumber.ref_num offer_request.save response = Mks::Common::MethodResponse.new(true, 'Request capture successfully!', nil, nil, nil) else errors = Mks::Common::Util. offer_request, 'Offer Request' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |
#get_request_by_security_status ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 35 def get_request_by_security_status offer_request = OfferRequest.new result = offer_request.get_requests_by_security_status(params[:security_status]) if params.key?('simple') data = Logistics::Core::ApplicationRecord.as_json(result, SimpleOfferRequestSerializer) else data = ActiveModelSerializers::SerializableResource.new(result).as_json end response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#get_request_by_status ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 15 def get_request_by_status offer_request = OfferRequest.new result = offer_request.get_bill_of_loading_by_status(params[:status]) if params.key?('simple') data = Logistics::Core::ApplicationRecord.as_json(result, SimpleOfferRequestSerializer) else data = ActiveModelSerializers::SerializableResource.new(result).as_json end response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#get_requests_with_additional_service ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 27 def get_requests_with_additional_service offer_request = OfferRequest.new result = offer_request.get_request_with_additional_service data = ActiveModelSerializers::SerializableResource.new(result).as_json response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#index ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 7 def index offer_request = OfferRequest.new result = offer_request.get_bill_of_loading_by_status_and_user(params[:status], session[:user_id]) data = ActiveModelSerializers::SerializableResource.new(result).as_json response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#new ⇒ Object
48 49 50 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 48 def new end |
#set_security_status ⇒ Object
98 99 100 101 102 103 104 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 98 def set_security_status offer_request = OfferRequest.find(params[:offer_request_id]) offer_request.security_status = params[:security_status] offer_request.save response = Mks::Common::MethodResponse.new(true, "Security status changed to #{params[:security_status]} !",nil,nil,nil) render json: response end |
#update ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 67 def update if @offer_request.update(offer_request_params) response = Mks::Common::MethodResponse.new(true, 'Request updated successfully !', nil, nil, nil) else errors = Mks::Common::Util. @offer_request, 'Offer Request' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |
#update_demurage_detail ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 116 def update_demurage_detail offer_request = OfferRequest.find(params[:offer_request_id]) offer_request.carrier_id = params[:carrier_id] offer_request.agent_id = params[:agent_id] offer_request.arrival_date = params[:arrival_date] offer_request.days_before_returning_container = params[:days_before_returning_container] offer_request.save @response = Mks::Common::MethodResponse.new(true, 'Demurage data captured successfully !',nil, nil, nil) render json: @response end |
#update_storage_detail ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'app/controllers/logistics/core/offer_requests_controller.rb', line 106 def update_storage_detail offer_request = OfferRequest.find(params[:offer_request_id]) offer_request.arrival_date = params[:arrival_date] offer_request.days_until_loaded = params[:days_until_loaded] offer_request.warehouse_id = params[:warehouse_id] offer_request.save @response = Mks::Common::MethodResponse.new(true, 'Storage data captured successfully !',nil, nil, nil) render json: @response end |