Class: TimeOffPolicy
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- TimeOffPolicy
- Includes:
- Models::Auditable
- Defined in:
- app/models/time_off_policy.rb
Overview
== Schema Information
Table name: time_off_policies
Database name: primary
id :bigint not null, primary key
accrual_frequency :string
accrual_interval :decimal(, )
accrual_rate :decimal(, )
accrual_rollover :decimal(, )
annual_accrual_timing :string
custom_accrual_date :date
effective_date :date
expiry_date :date
hours_per_week :integer
max_rollover(Maximum amount of time that can roll over) :decimal(10, 2) default(0.0)
max_tenure(Maximum tenure (in years) for this policy to apply (null = no upper limit)) :decimal(5, 2)
min_tenure(Minimum tenure (in years) for this policy to apply) :decimal(5, 2)
monthly_accrual_day :integer
name :string
notes :text
unlimited(Whether the policy offers unlimited accrual) :boolean default(FALSE), not null
weekly_accrual_day :integer
created_at :datetime not null
updated_at :datetime not null
parent_policy_id(References the preceding policy in the sequence) :integer
time_off_type_id :integer
Indexes
index_time_off_policies_on_time_off_type_id (time_off_type_id)
Foreign Keys
fk_rails_... (parent_policy_id => time_off_policies.id)
fk_rails_... (time_off_type_id => time_off_types.id)
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Instance Attribute Summary collapse
- #annual_accrual_timing ⇒ Object readonly
- #hours_per_week ⇒ Object readonly
- #monthly_accrual_day ⇒ Object readonly
- #weekly_accrual_day ⇒ Object readonly
Belongs to collapse
Methods included from Models::Auditable
Has many collapse
- #child_policies ⇒ ActiveRecord::Relation<TimeOffPolicy>
- #employees ⇒ ActiveRecord::Relation<Employee>
- #time_off_policy_assignments ⇒ ActiveRecord::Relation<TimeOffPolicyAssignment>
Class Method Summary collapse
- .accrual_period_list ⇒ Object
-
.for_manager_policies_tab ⇒ ActiveRecord::Relation<TimeOffPolicy>
A relation of TimeOffPolicies that are for manager policies tab.
- .policy_list ⇒ Object
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Instance Attribute Details
#annual_accrual_timing ⇒ Object (readonly)
52 |
# File 'app/models/time_off_policy.rb', line 52 validates :annual_accrual_timing, inclusion: { in: %w[beginning_of_year end_of_year], message: "must be 'beginning_of_year' or 'end_of_year'" }, allow_blank: true |
#hours_per_week ⇒ Object (readonly)
53 |
# File 'app/models/time_off_policy.rb', line 53 validates :hours_per_week, presence: true, numericality: { only_integer: true, greater_than: 0 } |
#monthly_accrual_day ⇒ Object (readonly)
51 |
# File 'app/models/time_off_policy.rb', line 51 validates :monthly_accrual_day, inclusion: { in: 1..31, message: "must be between 1 and 31" }, allow_nil: true |
#weekly_accrual_day ⇒ Object (readonly)
50 |
# File 'app/models/time_off_policy.rb', line 50 validates :weekly_accrual_day, inclusion: { in: 0..6, message: "must be between 0 (Sunday) and 6 (Saturday)" }, allow_nil: true |
Class Method Details
.accrual_period_list ⇒ Object
55 56 57 |
# File 'app/models/time_off_policy.rb', line 55 def self.accrual_period_list ['weekly', 'annual'] end |
.for_manager_policies_tab ⇒ ActiveRecord::Relation<TimeOffPolicy>
A relation of TimeOffPolicies that are for manager policies tab. Active Record Scope
42 |
# File 'app/models/time_off_policy.rb', line 42 scope :for_manager_policies_tab, -> { includes(:time_off_type, :time_off_policy_assignments) } |
.policy_list ⇒ Object
59 60 61 |
# File 'app/models/time_off_policy.rb', line 59 def self.policy_list all.select{|a| [a.id, a.name]} end |
Instance Method Details
#child_policies ⇒ ActiveRecord::Relation<TimeOffPolicy>
46 |
# File 'app/models/time_off_policy.rb', line 46 has_many :child_policies, class_name: 'TimeOffPolicy', foreign_key: 'parent_policy_id' |
#employees ⇒ ActiveRecord::Relation<Employee>
48 |
# File 'app/models/time_off_policy.rb', line 48 has_many :employees, through: :time_off_policy_assignments |
#parent_policy ⇒ TimeOffPolicy
45 |
# File 'app/models/time_off_policy.rb', line 45 belongs_to :parent_policy, class_name: 'TimeOffPolicy', optional: true |
#time_off_policy_assignments ⇒ ActiveRecord::Relation<TimeOffPolicyAssignment>
47 |
# File 'app/models/time_off_policy.rb', line 47 has_many :time_off_policy_assignments |
#time_off_type ⇒ TimeOffType
44 |
# File 'app/models/time_off_policy.rb', line 44 belongs_to :time_off_type |