If this is true, the practice of your company is against Qatar Laws. Nobody can deduct gratuity or leave salary from employees salaries. This kind of things should be brought into attention of Labour department before you leave Qatar.