Class: Logistics::Core::TruckRatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::TruckRatesController
- Defined in:
- app/controllers/logistics/core/truck_rates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /truck_rates POST /truck_rates.json.
-
#index ⇒ Object
GET /truck_rates GET /truck_rates.json.
-
#update ⇒ Object
PATCH/PUT /truck_rates/1 PATCH/PUT /truck_rates/1.json.
Instance Method Details
#create ⇒ Object
POST /truck_rates POST /truck_rates.json
29 30 31 32 33 |
# File 'app/controllers/logistics/core/truck_rates_controller.rb', line 29 def create TruckRate.generate_rate_for_truck_rate(params[:effective_date]) response = Mks::Common::MethodResponse.new(true,'Truck rate generated successfully!',nil,nil,nil) render json: response end |
#index ⇒ Object
GET /truck_rates GET /truck_rates.json
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/logistics/core/truck_rates_controller.rb', line 8 def index @truck_rates = TruckRate.all truck_rates =[] @truck_rates.each { |truck_rate| truck_rates.push({:id => truck_rate.id, :service_delivery_unit_id => truck_rate.chargeable_service_unit_of_charge.service_delivery_unit_id, :service_delivery_unit_name => truck_rate.chargeable_service_unit_of_charge.service_delivery_unit.name, :chargeable_service_id => truck_rate.chargeable_service_unit_of_charge.chargeable_service_id, :chargeable_service_name => truck_rate.chargeable_service_unit_of_charge.chargeable_service.name, :transaction_type_id => truck_rate.transaction_type_id, :transaction_type_name => truck_rate.transaction_type.name, :low => truck_rate.low, :medium => truck_rate.medium, :high => truck_rate.high, :margin => truck_rate.margin,:effective_date => truck_rate.effective_date}) } @response = {:success => true, :message => '', :data =>truck_rates} render json: @response end |
#update ⇒ Object
PATCH/PUT /truck_rates/1 PATCH/PUT /truck_rates/1.json
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/logistics/core/truck_rates_controller.rb', line 37 def update service_rates = params[:updated_service_rates] service_rates.each { |service_rate| old_service_rate =TruckRate.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,'Truck rate updated successfully!',nil,nil,nil) render json: response end |