Class: Logistics::Core::OutOfGaugeBbRatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::OutOfGaugeBbRatesController
- Defined in:
- app/controllers/logistics/core/out_of_gauge_bb_rates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /out_of_gauge_bb_rates POST /out_of_gauge_bb_rates.json.
-
#index ⇒ Object
GET /out_of_gauge_bb_rates GET /out_of_gauge_bb_rates.json.
- #search_route ⇒ Object
-
#update ⇒ Object
PATCH/PUT /out_of_gauge_bb_rates/1 PATCH/PUT /out_of_gauge_bb_rates/1.json.
Instance Method Details
#create ⇒ Object
POST /out_of_gauge_bb_rates POST /out_of_gauge_bb_rates.json
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/logistics/core/out_of_gauge_bb_rates_controller.rb', line 26 def create out_of_gauge_bb_rate = OutOfGaugeBbRate.new(out_of_gauge_bb_rate_params) margin = out_of_gauge_bb_rate_params[:margin] rate = out_of_gauge_bb_rate_params[:rate] new_rate = rate + (rate * margin/100) out_of_gauge_bb_rate.rate = new_rate if out_of_gauge_bb_rate.save response = Mks::Common::MethodResponse.new(true, "Break Bulk Out of Gauge rate information saved successfully!", out_of_gauge_bb_rate, nil, nil) else errors = Mks::Common::Util. out_of_gauge_bb_rate,"Break Bulk Out of Gauge Rate" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |
#index ⇒ Object
GET /out_of_gauge_bb_rates GET /out_of_gauge_bb_rates.json
11 12 13 14 15 |
# File 'app/controllers/logistics/core/out_of_gauge_bb_rates_controller.rb', line 11 def index out_of_gauge_bb_rates = OutOfGaugeBbRate.fetch_all response = Mks::Common::MethodResponse.new(true, nil, out_of_gauge_bb_rates, nil, nil) render json: response end |
#search_route ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/logistics/core/out_of_gauge_bb_rates_controller.rb', line 17 def search_route route_id = params[:route][:id] route = Route.find(route_id) response = Mks::Common::MethodResponse.new(true, nil, route.margin, nil, nil) render json: response end |
#update ⇒ Object
PATCH/PUT /out_of_gauge_bb_rates/1 PATCH/PUT /out_of_gauge_bb_rates/1.json
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/logistics/core/out_of_gauge_bb_rates_controller.rb', line 44 def update out_of_gauge_bb_rate = OutOfGaugeBbRate.find(params[:id]) margin = out_of_gauge_bb_rate_params[:margin] if margin > out_of_gauge_bb_rate.margin rate = out_of_gauge_bb_rate_params[:rate] margin = margin - out_of_gauge_bb_rate.margin new_rate = rate + (rate * margin/100) params[:out_of_gauge_bb_rate][:rate] = new_rate end if out_of_gauge_bb_rate.update(out_of_gauge_bb_rate_params) response = Mks::Common::MethodResponse.new(true, "Break Bulk Out of Gauge rate information updated successfully!", out_of_gauge_bb_rate, nil, nil) else errors = Mks::Common::Util. out_of_gauge_bb_rate,"Break Bulk Out of Gauge Rate" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |