Sha256: 2a67270e96bdf1aee8b0f55733108e93ed33f36a543cfe94ddbca303ef2a2618

Contents?: true

Size: 726 Bytes

Versions: 17

Compression:

Stored size: 726 Bytes

Contents

module Ecom
  module Core
    class WorkOrder < ApplicationRecord
      before_save :add_reference_number

      NEW = 'New'.freeze
      IN_PROGRESS = 'In Progress'.freeze
      COMPLETED = 'Completed'.freeze

      STATUSES = [NEW, IN_PROGRESS, COMPLETED].freeze

      validates :name, :assigned_to_id, :generated_by_id, :status,
                :start_date, :end_date, presence: true

      validates :status, presence: true, inclusion: STATUSES

      belongs_to :assigned_to, class_name: 'Ecom::Core::Crew'
      belongs_to :generated_by, class_name: 'Ecom::Core::User'
      has_many :tasks

      def add_reference_number
        self.reference_number = "WO-#{(Time.now.to_f * 1000).to_i}"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ecom_core-1.3.11 app/models/ecom/core/work_order.rb
ecom_core-1.3.10 app/models/ecom/core/work_order.rb
ecom_core-1.3.9 app/models/ecom/core/work_order.rb
ecom_core-1.3.8 app/models/ecom/core/work_order.rb
ecom_core-1.3.7 app/models/ecom/core/work_order.rb
ecom_core-1.3.6 app/models/ecom/core/work_order.rb
ecom_core-1.3.5 app/models/ecom/core/work_order.rb
ecom_core-1.3.4 app/models/ecom/core/work_order.rb
ecom_core-1.3.3 app/models/ecom/core/work_order.rb
ecom_core-1.3.2 app/models/ecom/core/work_order.rb
ecom_core-1.3.1 app/models/ecom/core/work_order.rb
ecom_core-1.3.0 app/models/ecom/core/work_order.rb
ecom_core-1.2.36 app/models/ecom/core/work_order.rb
ecom_core-1.2.35 app/models/ecom/core/work_order.rb
ecom_core-1.2.34 app/models/ecom/core/work_order.rb
ecom_core-1.2.33 app/models/ecom/core/work_order.rb
ecom_core-1.2.32 app/models/ecom/core/work_order.rb