All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
An amount of money that is deducted from basic salary and retained for a fixed time, is subject to Zakaah every lunar year provided that such a sum is controlled by someone who can pay at anytime. In other words, such an amount of money is considered as a delayed debt.
As for the gratuity given by some companies, if you are sure that that amount will be retained on your behalf and given to you at death, retirement or resignation, then it also becomes subject to Zakaah.
With regard to paying Zakaah in these two or similar cases, one can pay Zakaah at a fixed time every year or delay payment until he/she receives that sum of money and then pays for the entire period.
But, if an employee will not receive such a gratuity, or must meet some conditions, then there is no Zakaah.
For more benefit on Zakaah, please refer to Fataawa 165375, 401332, and 379973.
Allah knows best.