Gratuity is termed as EOS (End of Service) benefits and can only be availed when one leaves the organization (termination/resignation)

As per QLL, for the first 5 years gratuity is calculated on the basis of 21 days per year (some companies give it @ of 30 days irrespective of the no of years)and if one exceeds 5 years then gratuity is calculated @ 30 days per year.

Some companies even allow their employees to take their gratuities yearly (if the employees so wish)to reduce their liabilities.
Hope this helps