Class: Logistics::Core::ContractContainerRatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::ContractContainerRatesController
- Defined in:
- app/controllers/logistics/core/contract_container_rates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /service_rates POST /service_rates.json.
-
#index ⇒ Object
GET /service_rates GET /service_rates.json.
-
#update ⇒ Object
PATCH/PUT /service_rates/1 PATCH/PUT /service_rates/1.json.
Instance Method Details
#create ⇒ Object
POST /service_rates POST /service_rates.json
30 31 32 33 34 |
# File 'app/controllers/logistics/core/contract_container_rates_controller.rb', line 30 def create ContractContainerRate.generate_rate_for_containerized_chargeable_service(params[:client_contract_id]) @response = {:success => true, :message => 'Rate table generated successfully', :data => []} render json: @response end |
#index ⇒ Object
GET /service_rates GET /service_rates.json
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/logistics/core/contract_container_rates_controller.rb', line 6 def index contract_container_rate_array = [] @contract_container_rates = ContractContainerRate.where(contract_id: params[:client_contract_id]) @contract_container_rates.each { |contract_container_service_rate| contract_container_rate_array.push({:id => contract_container_service_rate.id, :chargeable_service_name => contract_container_service_rate.chargeable_service_unit_of_charge.chargeable_service.name, :rate => contract_container_service_rate.rate, :margin => contract_container_service_rate.margin, :container_size_id => contract_container_service_rate.container_size_id, :container_size_name => contract_container_service_rate.container_size.name, :transaction_type_id => contract_container_service_rate.transaction_type_id, :transaction_type_name => contract_container_service_rate.transaction_type.name, :service_delivery_unit_id => contract_container_service_rate.chargeable_service_unit_of_charge.service_delivery_unit_id, :service_delivery_unit_name => contract_container_service_rate.chargeable_service_unit_of_charge.service_delivery_unit.name, :in_contract => contract_container_service_rate.in_contract, :contract_id => contract_container_service_rate.contract_id }) } @response = {:success => true, :message => '', :data => contract_container_rate_array} render json: @response end |
#update ⇒ Object
PATCH/PUT /service_rates/1 PATCH/PUT /service_rates/1.json
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/logistics/core/contract_container_rates_controller.rb', line 38 def update service_rates = params[:updated_service_rates] service_rates.each { |service_rate| old_service_rate = ContractContainerRate.find(service_rate['id']) old_service_rate.rate = service_rate['rate'] old_service_rate.in_contract = service_rate['in_contract'] old_service_rate.margin = service_rate['margin'] old_service_rate.save } @response = {:success => true, :message => 'Rate table updated successfully', :data => service_rates} render json: @response end |