Under the Payment of Gratuity Act, you are entitled to gratuity if you have served continously for five years or more. If you have served for 4 years and 240 days in the fifth year, then also you are entitled to gratuity.
There are no provisions under the Payment of Gratuity Act to deduct any amount of salary for the purpose of gratuity unlike dueduction made under ESI/PF. Any deduction made towards gratuity is illegal.
Now if you leave the orginalization before the qualifying period for payment of gratuity, you may demand the deducted amount towards gratuity but NOT as gratuity but as illegal deduction of salary.
In my view, even if you qualify for the payment of gratuity under the Act, you may demand gratuity as well as the amount deducted towards gratuity separately.