Sha256: ed91dbad42affbf7c4db3198852e0630485ffea2bf52cb097724d70a9e049d9b
Contents?: true
Size: 1.74 KB
Versions: 9
Compression:
Stored size: 1.74 KB
Contents
module Logistics module Core class TruckTypeBbWeightRange < ApplicationRecord validates :break_bulk_truck_assignment_id, uniqueness: {scope: [:break_bulk_truck_assignment_id, :weight_range_id]} belongs_to :weight_range belongs_to :break_bulk_truck_assignment def weight_from if self.weight_range_id weight_range = WeightRange.find self.weight_range_id weight_range.weight_from else nil end end def weight_to if self.weight_range_id weight_range = WeightRange.find self.weight_range_id weight_range.weight_to else nil end end def truck_type if self.break_bulk_truck_assignment_id break_bulk_truck_assignment = BreakBulkTruckAssignment.find self.break_bulk_truck_assignment_id break_bulk_truck_assignment.truck_type end end def self.fetch_all break_bulk_truck_assignment_id result = [] truck_type_bb_weight_ranges = TruckTypeBbWeightRange.where("break_bulk_truck_assignment_id" => break_bulk_truck_assignment_id) truck_type_bb_weight_ranges.each do |truck_type_bb_weight_range| result.push({id: truck_type_bb_weight_range.id, weight_from: truck_type_bb_weight_range.weight_from, weight_to: truck_type_bb_weight_range.weight_to, weight_range_id: truck_type_bb_weight_range.weight_range_id, break_bulk_truck_assignment_id: truck_type_bb_weight_range.break_bulk_truck_assignment_id, truck_type: truck_type_bb_weight_range.truck_type }) end return result end end end end
Version data entries
9 entries across 9 versions & 1 rubygems