Class: Logistics::Core::ConvoyRatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::ConvoyRatesController
- Defined in:
- app/controllers/logistics/core/convoy_rates_controller.rb
Instance Method Summary collapse
-
#bill_of_loading_rate_params ⇒ Object
Never trust parameters from the scary internet, only allow the white list through.
-
#create ⇒ Object
POST /bill_of_loading_rates POST /bill_of_loading_rates.json.
- #index ⇒ Object
-
#update ⇒ Object
PATCH/PUT /bill_of_loading_rates/1 PATCH/PUT /bill_of_loading_rates/1.json.
Instance Method Details
#bill_of_loading_rate_params ⇒ Object
Never trust parameters from the scary internet, only allow the white list through.
46 47 48 |
# File 'app/controllers/logistics/core/convoy_rates_controller.rb', line 46 def bill_of_loading_rate_params params.require(:convoy_rate).permit(:chargeable_service_unit_of_charge_id, :transaction_type_id, :low, :medium, :high, :effective_date) end |
#create ⇒ Object
POST /bill_of_loading_rates POST /bill_of_loading_rates.json
21 22 23 24 25 26 |
# File 'app/controllers/logistics/core/convoy_rates_controller.rb', line 21 def create effective_date = params[:effective_date] ConvoyRate.generate_rate_for_convoy_services(effective_date) @response = Mks::Common::MethodResponse.new(true, 'Rate generated successfully', nil, nil, nil) render json: @response end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/logistics/core/convoy_rates_controller.rb', line 4 def index @convoy_rates = ConvoyRate.all convoy_rates_array =[] @convoy_rates.each { |cr| convoy_rates_array.push({:id => cr.id, :high => cr.high, :low => cr.low, :medium => cr.medium, :effective_date => cr.effective_date, :service_delivery_unit_name => cr.chargeable_service_unit_of_charge.service_delivery_unit.name, :transaction_type_name => cr.transaction_type.name, :margin => cr.margin, :chargeable_service_name => cr.chargeable_service_unit_of_charge.chargeable_service.name}) } @response = Mks::Common::MethodResponse.new(true, nil, convoy_rates_array, nil, nil) render json: @response end |
#update ⇒ Object
PATCH/PUT /bill_of_loading_rates/1 PATCH/PUT /bill_of_loading_rates/1.json
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/logistics/core/convoy_rates_controller.rb', line 30 def update service_rates = params[:updated_service_rates] service_rates.each { |service_rate| old_service_rate = ConvoyRate.find(service_rate['id']) old_service_rate.low = service_rate['low'] old_service_rate.medium = service_rate['medium'] old_service_rate.high = service_rate['high'] old_service_rate.margin = service_rate['margin'] old_service_rate.effective_date = service_rate['effective_date'] old_service_rate.save } @response = Mks::Common::MethodResponse.new(true, 'Rate updated successfully !'); render json: @response end |