Guest User

Untitled

a guest
Jun 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # entitlement.rb
  2.  
  3. class Entitlement < ActiveRecord::Base
  4. belongs_to :employment, :validate => true
  5.  
  6. attr_accessor :all_leaves
  7.  
  8. def leaves
  9. @all_leaves ||= employment.leaves.find_all_by_leave_contract_period(self.contract_period, :order => "leaves.from DESC, leaves.to DESC, work_month DESC")
  10. end
  11.  
  12. def annual_leaves(work_month)
  13. leaves.find_all {|leave| leave.subject == "AL" && leave.work_month == work_month if work_month}
  14. end
  15.  
  16. def medical_leaves
  17. leaves.find_all {|leave| leave.subject == "ML" }
  18. end
  19.  
  20. def hosp_leaves
  21. leaves.find_all {|leave| leave.subject == "HOSL" }
  22. end
  23.  
  24. def oil_leaves
  25. leaves.find_all {|leave| leave.subject == "OIL" }
  26. end
  27.  
  28. def mtnl_leaves
  29. leaves.find_all {|leave| leave.subject == "MTNL" }
  30. end
  31.  
  32. def ccl_leaves
  33. leaves.find_all {|leave| leave.subject == "CCL" }
  34. end
  35.  
  36. def icl_leaves
  37. leaves.find_all {|leave| leave.subject == "ICL" }
  38. end
  39. end
Add Comment
Please, Sign In to add comment