Class: Logistics::Core::OutOfGaugeBbRate

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

as_json

Class Method Details

.fetch_allObject



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
94
# File 'app/models/logistics/core/out_of_gauge_bb_rate.rb', line 68

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

Instance Method Details

#break_bulk_unit_nameObject



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

def break_bulk_unit_name
  if self.break_bulk_unit_id
    break_bulk_unit = BreakBulkUnit.find self.break_bulk_unit_id
    break_bulk_unit.name
  else
    nil
  end
end

#heightObject



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

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

#lengthObject



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

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



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

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

#weightObject



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

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

#widthObject



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

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