Class: NextSgad::Attendance

Inherits:
ApplicationRecord show all
Defined in:
app/models/next_sgad/attendance.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#create_number, #create_number!

Class Method Details

.all_absenceObject

get all attendances with state absence or late



26
27
28
# File 'app/models/next_sgad/attendance.rb', line 26

def self.all_absence
  where(status: [-4,-3,-2,-1,1])
end

.with_justificationObject

get attendances with justification



31
32
33
# File 'app/models/next_sgad/attendance.rb', line 31

def self.with_justification
  where(justification_status: [0,1,2])
end

.without_justificationObject



35
36
37
# File 'app/models/next_sgad/attendance.rb', line 35

def self.without_justification
  where(status: [-4,-3,-2,-1,1]).where(justification_status: -1)
end

Instance Method Details

#has_justification?Boolean

true if an attendace has justification

Returns:

  • (Boolean)


40
41
42
# File 'app/models/next_sgad/attendance.rb', line 40

def has_justification?
  pending? || approved? || disapproved? || in_progress?
end

#justificationObject



44
45
46
# File 'app/models/next_sgad/attendance.rb', line 44

def justification
  justifications.last
end