You should calculate the number of days per year, under the Qatar Law, gratuity is 21 days per year.

21 days divided by the total days/per month

21/30 =0.7

0.7x5000= 3500QR/year

3500x5 = 17500 QR (your gratuity for 5 years of service)