Sha256: 6631a4ca24a3b95e7d1b3f86031eae19e6577ece58a4ed697fac7381863ca043

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module Ecom
  module Core
    class Task < ApplicationRecord
      include AASM

      belongs_to :work_product
      belongs_to :task_template
      belongs_to :work_package, optional: true
      belongs_to :performer, class_name: 'Ecom::Core::User', optional: true
      belongs_to :approver, class_name: 'Ecom::Core::User', optional: true
      belongs_to :supervisor, class_name: 'Ecom::Core::User', optional: true
      belongs_to :quality_controller, class_name: 'Ecom::Core::User', optional: true

      validates :code, :name, :status, :percent_completed, presence: true
      validates_numericality_of :percent_completed,
                                only_integer: true,
                                greater_than_or_equal_to: 0,
                                less_than_or_equal_to: 100

      aasm column: 'status' do
        state :new, initial: true
        state :in_progress
        state :submitted
        state :under_review
        state :completed

        event :start do
          transitions from: :new, to: :in_progress
        end

        event :submit do
          transitions from: :in_progress, to: :submitted
        end

        event :review do
          transitions from: :submitted, to: :under_review
        end

        event :complete do
          transitions from: %i[submitted under_review], to: :completed
        end

        event :rework do
          transitions from: :under_review, to: :in_progress
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecom_core-1.2.15 app/models/ecom/core/task.rb