it is not legal and it is stated clearly in qatari labor law
u can always download the law online n check it I am sure u will find it translated to english somewhere or if not u can find "someone" to translate this for u but it is stated clearly n they can not deduct it from u unless u accept to do so
the law states clearly that ur end of contract compensation should be paid in full n without any delay
always check the law