Class: Logistics::Core::BreakBulkUnitRatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::BreakBulkUnitRatesController
- Defined in:
- app/controllers/logistics/core/break_bulk_unit_rates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /break_bulk_unit_rates POST /break_bulk_unit_rates.json.
-
#index ⇒ Object
GET /break_bulk_unit_rates GET /break_bulk_unit_rates.json.
-
#update ⇒ Object
PATCH/PUT /break_bulk_unit_rates/1 PATCH/PUT /break_bulk_unit_rates/1.json.
Instance Method Details
#create ⇒ Object
POST /break_bulk_unit_rates POST /break_bulk_unit_rates.json
26 27 28 29 30 |
# File 'app/controllers/logistics/core/break_bulk_unit_rates_controller.rb', line 26 def create BreakBulkUnitRate.generate_rate_for_break_bulk_units(params[:effective_date]) response = Mks::Common::MethodResponse.new(true, 'Break bulk unit rate generated successfully !', nil, nil, nil) render json: response end |
#index ⇒ Object
GET /break_bulk_unit_rates GET /break_bulk_unit_rates.json
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/logistics/core/break_bulk_unit_rates_controller.rb', line 8 def index @break_bulk_unit_rates = BreakBulkUnitRate.all break_bulk_unit_rate_array = [] @break_bulk_unit_rates.each { |bbur| break_bulk_unit_rate_array.push({:id => bbur.id, :service_delivery_unit_name => bbur.chargeable_service_unit_of_charge.service_delivery_unit.name, :chargeable_service_name => bbur.chargeable_service_unit_of_charge.chargeable_service.name, :transaction_type_name => bbur.transaction_type.name, :break_bulk_unit_name => bbur.break_bulk_unit.name, :low => bbur.low, :medium => bbur.medium, :high => bbur.high, :margin => bbur.margin, :effective_date => bbur.effective_date}) } response = Mks::Common::MethodResponse.new(true, nil, break_bulk_unit_rate_array, nil, nil) render json: response end |
#update ⇒ Object
PATCH/PUT /break_bulk_unit_rates/1 PATCH/PUT /break_bulk_unit_rates/1.json
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/logistics/core/break_bulk_unit_rates_controller.rb', line 34 def update service_rates = params[:updated_service_rates] service_rates.each { |service_rate| old_service_rate = BreakBulkUnitRate.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 = {:success => true, :message => 'Rate table updated successfully', :data => service_rates} render json: @response end |