
Understanding the Calculation Logic
The UAE Gratuity Calculator is a web-based tool designed to compute end-of-service gratuity for private-sector employees in the United Arab Emirates, adhering strictly to the provisions of the UAE Labour Law (Federal Decree-Law No. 33 of 2021). The calculator takes three inputs—First Working Day, Last Working Day, and Basic Salary (in AED)—and applies a robust backend logic to deliver accurate gratuity estimates. Below is a detailed explanation of the calculation logic used in the background.
UAE Gratuity Calculator
Note: Calculations are based on UAE Labour Law for private sector employees (Federal Decree-Law No. 33 of 2021). Total gratuity is capped at two years' basic salary. For legal advice, consult MOHRE or a labour lawyer.
Gratuity Calculation Logic
The calculator’s logic is built to ensure compliance with UAE Labour Law, handling various employment scenarios while maintaining precision. The process involves input validation, service period calculation, gratuity computation based on years of service, and applying a salary cap. Here’s a step-by-step breakdown:
1. Input Validation
Before any calculations, the tool validates the user-provided inputs to ensure they meet the necessary criteria:
- Mandatory Fields: All inputs—First Working Day, Last Working Day, and Basic Salary—must be provided.
- Positive Salary: The Basic Salary must be a positive number (greater than zero).
- Date Logic: The Last Working Day must be later than the First Working Day to represent a valid employment period.
- Minimum Service Period: The employment duration must be at least one year for gratuity eligibility, as per UAE Labour Law.
If any validation fails, the calculator displays an error message, such as:
- “Please fill in all fields.”
- “Please enter a valid basic salary.”
- “Last working day must be after first working day.”
- “Service period must be at least one year to be eligible for gratuity.”
This ensures that only valid data proceeds to the calculation phase.
2. Calculating Years of Service
To determine the duration of employment, the calculator computes the difference between the Last Working Day and First Working Day:
- The dates are processed using JavaScript’s
Date
object, which calculates the time difference in milliseconds. - This difference is converted to years by dividing by the number of milliseconds in an average year (365.25 days to account for leap years).
- Formula:
yearsOfService = (endDate - startDate) / (1000 * 60 * 60 * 24 * 365.25)
.
If the years of service are less than 1, the calculator returns an error indicating that no gratuity is payable, as employees with less than one year of service are not eligible.
3. Gratuity Computation
The gratuity is calculated based on the Basic Salary and Years of Service, following the tiered structure outlined in UAE Labour Law. The process involves the following steps:
- Daily Wage Calculation:
- The daily wage is derived by dividing the monthly basic salary by 30 (the standard number of days in a month for gratuity purposes).
- Formula:
dailyWage = basicSalary / 30
.
- Service of 1 to 5 Years:
- For employees with 1 to 5 years of service, gratuity is calculated as 21 days of the daily wage per year of service.
- Formula:
totalGratuity = dailyWage * 21 * yearsOfService
. - This applies proportionally to fractional years (e.g., 3.5 years yields 3.5 * 21 days of salary).
- Service Over 5 Years:
- For the first 5 years, employees receive 21 days of their daily wage per year.
- For each additional year beyond 5, employees receive 30 days of their daily wage.
- Formula:
totalGratuity = (dailyWage * 21 * 5) + (dailyWage * 30 * (yearsOfService - 5))
. - The calculation accounts for fractional years in the additional period.
- Two-Year Salary Cap:
- The total gratuity is capped at two years’ worth of the basic salary (equivalent to 24 months).
- Formula:
totalGratuity = Math.min(totalGratuity, basicSalary * 24)
. - This ensures that even long-serving or high-earning employees do not receive gratuity exceeding this limit.
The final gratuity amount is rounded to two decimal places for clarity and presented in AED.
4. Handling Edge Cases
The calculator is designed to handle various edge cases to ensure accurate and compliant results:
- Exact 5-Year Service: If the service period is exactly 5 years, only the 21-day rule applies, with no additional 30-day calculation.
- Fractional Years: The gratuity is calculated proportionally for fractional years (e.g., 4.7 years or 6.2 years), ensuring precision.
- High Salaries or Long Service: The two-year salary cap prevents excessive payouts, aligning with legal limits.
- Invalid Dates: If the date inputs result in a negative or zero service period, an error is displayed before any calculation.
Example Calculation
Suppose an employee provides the following inputs:
- First Working Day: 2018-01-01
- Last Working Day: 2025-01-01
- Basic Salary: AED 10,000
Step-by-Step Calculation:
- Years of Service:
- Difference: 2025-01-01 – 2018-01-01 = 7 years.
- Daily Wage:
dailyWage = 10,000 / 30 = 333.33 AED
.
- Gratuity Calculation:
- First 5 years:
333.33 * 21 * 5 = 35,000 AED
. - Additional 2 years:
333.33 * 30 * 2 = 20,000 AED
. - Total:
35,000 + 20,000 = 55,000 AED
.
- First 5 years:
- Apply Cap:
- Two-year salary:
10,000 * 24 = 240,000 AED
. - Since 55,000 < 240,000, the gratuity remains
55,000 AED
.
- Two-year salary:
- Output: The calculator displays “Estimated Gratuity: AED 55,000.00”.
Conclusion
The UAE Gratuity Calculator’s logic is a precise implementation of the UAE Labour Law’s end-of-service gratuity rules. By validating inputs, accurately calculating years of service, applying tiered gratuity rates, and enforcing the two-year salary cap, the tool ensures reliable results for employees and employers. Its robust handling of edge cases and clear error messaging make it a dependable resource for estimating gratuity payments. For legal confirmation, users are advised to consult MOHRE or a labour lawyer, but the calculator provides a solid foundation for quick and accurate estimates.