Ask A Question

Notifications

You’re not receiving notifications from this thread.

calculate leaves on yearly basis

Ahmed.zain asked in Rails

Employee is allowed 15 leaves in year for example. My function is calculating the total leaves of allover . But I want to calculate the since joining date and when year is complete since joining date the allowed leaves is update to 15.The method which is calculating total leaves of employee
def calculate_availed_leave
taken_leaves = self.employee.leaves.where(status: "Approved").count
availed_leaves = self.employee.allowed_leaves - taken_leaves
self.employee.update(availed_leaves: availed_leaves)
end
but i want to calcule on yearly basis

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.