Class: Logistics::Core::TwentyFeetEquivalentUnitRatesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/logistics/core/twenty_feet_equivalent_unit_rates_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /bill_of_loading_rates POST /bill_of_loading_rates.json



21
22
23
24
25
26
# File 'app/controllers/logistics/core/twenty_feet_equivalent_unit_rates_controller.rb', line 21

def create
  effective_date = params[:effective_date]
  TwentyFootEquivalenceUnitRate.generate_rate_for_twenty_feet_equivalence_unit_services(effective_date)
  @response = Mks::Common::MethodResponse.new(true, 'Rate generated successfully', nil, nil, nil)
  render json: @response
end

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/logistics/core/twenty_feet_equivalent_unit_rates_controller.rb', line 5

def index
  @twenty_feet_equivalence_unit_rates = TwentyFootEquivalenceUnitRate.all
  twenty_feet_equivalence_unit_rates_array =[]
  @twenty_feet_equivalence_unit_rates.each { |tfeur|
    twenty_feet_equivalence_unit_rates_array.push({:id => tfeur.id, :high => tfeur.high, :low => tfeur.low, :medium => tfeur.medium,
                                      :margin => tfeur.margin,:effective_date => tfeur.effective_date,
                                      :service_delivery_unit_name => tfeur.chargeable_service_unit_of_charge.service_delivery_unit.name,
                                      :transaction_type_name => tfeur.transaction_type.name,
                                      :chargeable_service_name => tfeur.chargeable_service_unit_of_charge.chargeable_service.name})
  }
  @response = Mks::Common::MethodResponse.new(true, nil, twenty_feet_equivalence_unit_rates_array, nil, nil)
  render json: @response
end

#updateObject

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/twenty_feet_equivalent_unit_rates_controller.rb', line 30

def update
  service_rates = params[:updated_service_rates]
  service_rates.each { |service_rate|
    old_service_rate = TwentyFootEquivalenceUnitRate.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 table successfully updated !', nil, nil, nil)
  render json: @response
end