Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # entitlement.rb
- class Entitlement < ActiveRecord::Base
- belongs_to :employment, :validate => true
- attr_accessor :all_leaves
- def leaves
- @all_leaves ||= employment.leaves.find_all_by_leave_contract_period(self.contract_period, :order => "leaves.from DESC, leaves.to DESC, work_month DESC")
- end
- def annual_leaves(work_month)
- leaves.find_all {|leave| leave.subject == "AL" && leave.work_month == work_month if work_month}
- end
- def medical_leaves
- leaves.find_all {|leave| leave.subject == "ML" }
- end
- def hosp_leaves
- leaves.find_all {|leave| leave.subject == "HOSL" }
- end
- def oil_leaves
- leaves.find_all {|leave| leave.subject == "OIL" }
- end
- def mtnl_leaves
- leaves.find_all {|leave| leave.subject == "MTNL" }
- end
- def ccl_leaves
- leaves.find_all {|leave| leave.subject == "CCL" }
- end
- def icl_leaves
- leaves.find_all {|leave| leave.subject == "ICL" }
- end
- end
Add Comment
Please, Sign In to add comment