Class: Logistics::Core::OutOfGaugeCntRate

Inherits:
ApplicationRecord show all
Defined in:
app/models/logistics/core/out_of_gauge_cnt_rate.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

as_json

Class Method Details

.fetch_allObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/models/logistics/core/out_of_gauge_cnt_rate.rb', line 67

def self.fetch_all
  result = []
  OutOfGaugeCntRate.all.each do |out_of_gauge_cnt_rate|
    result.push({id: out_of_gauge_cnt_rate.id,
                 container_size_id: out_of_gauge_cnt_rate.container_size_id,
                 container_size_name: out_of_gauge_cnt_rate.container_size_name,
                 length: out_of_gauge_cnt_rate.length,
                 length_from: out_of_gauge_cnt_rate.length_from,
                 length_to: out_of_gauge_cnt_rate.length_to,
                 height: out_of_gauge_cnt_rate.height,
                 height_from: out_of_gauge_cnt_rate.height_from,
                 height_to: out_of_gauge_cnt_rate.height_to,
                 width: out_of_gauge_cnt_rate.width,
                 width_from: out_of_gauge_cnt_rate.width_from,
                 width_to: out_of_gauge_cnt_rate.width_to,
                 weight: out_of_gauge_cnt_rate.weight,
                 weight_from: out_of_gauge_cnt_rate.weight_from,
                 weight_to: out_of_gauge_cnt_rate.weight_to,
                 rate: out_of_gauge_cnt_rate.rate,
                 route_id: out_of_gauge_cnt_rate.route_id,
                 route_name: out_of_gauge_cnt_rate.route_name,
                 margin: out_of_gauge_cnt_rate.margin,
                 effective_date: out_of_gauge_cnt_rate.effective_date,
                 valid_until: out_of_gauge_cnt_rate.valid_until })
  end
  return result
end

Instance Method Details

#container_size_nameObject



17
18
19
20
21
22
23
24
# File 'app/models/logistics/core/out_of_gauge_cnt_rate.rb', line 17

def container_size_name
  if self.container_size_id
    container_size = ContainerSize.find self.container_size_id
    container_size.name
  else
    nil
  end
end

#heightObject



51
52
53
54
55
56
57
# File 'app/models/logistics/core/out_of_gauge_cnt_rate.rb', line 51

def height
  if self.height_from && self.height_to
    self.height_from.to_s + ' - ' + self.height_to.to_s
  else
    nil
  end
end

#lengthObject



35
36
37
38
39
40
41
# File 'app/models/logistics/core/out_of_gauge_cnt_rate.rb', line 35

def length
  if self.length_from && self.length_to
    self.length_from.to_s + ' - ' + self.length_to.to_s
  else
    nil
  end
end

#route_nameObject



26
27
28
29
30
31
32
33
# File 'app/models/logistics/core/out_of_gauge_cnt_rate.rb', line 26

def route_name
  if self.route_id
    route = Route.find self.route_id
    route.route_name
  else
    nil
  end
end

#weightObject



59
60
61
62
63
64
65
# File 'app/models/logistics/core/out_of_gauge_cnt_rate.rb', line 59

def weight
  if self.weight_from && self.weight_to
    self.weight_from.to_s + ' - ' + self.weight_to.to_s
  else
    nil
  end
end

#widthObject



43
44
45
46
47
48
49
# File 'app/models/logistics/core/out_of_gauge_cnt_rate.rb', line 43

def width
  if self.width_from && self.width_to
    self.width_from.to_s + ' - ' + self.width_to.to_s
  else
    nil
  end
end