module Sis module Core class Application < ApplicationRecord include AASM # Gender types MALE = 'Male'.freeze FEMALE = 'Female'.freeze aasm column: :status do state :draft, initial: true state :submitted, :under_review, :accepted, :rejected, :selected_for_exam, :selected_for_admission event :submit do transitions from: :draft, to: :submitted end event :review do transitions from: %i[submitted rejected accepted], to: :under_review end event :accept do transitions from: :under_review, to: :accepted end event :reject do transitions from: :under_review, to: :rejected end event :select_for_exam do transitions from: :accepted, to: :selected_for_exam end event :select_for_admission do transitions from: :selected_for_exam, to: :selected_for_admission end end validates :status, presence: true validates :payment_information, presence: true, if: :payment_made belongs_to :applicant belongs_to :academic_programme belongs_to :application_setup end end end