End of Service Benefits (ESB) Calculation Saudi Arabia - Kvcodes
X

Congrats, You are Subscribed to Receive Updates.

End of Service Benefits (ESB) Calculation Saudi Arabia


Introduction

End of Service Benefits (ESB) Calculation Saudi Arabia. Saudi ESB  calculation has some formula to calculate it. ESB calculator is available from the Saudi Govt website itself. There you can use and calculate the ESB for an employee.  From their formula, I just created an image for your better understanding. I hope this helps better to understand it.

From their website I have understand their formula for the calculation, which I am going to write below in it. If you are looking to create ESB for your software you can change it to any language and apply it to be there.

Let me start with PHP and also I will provide it on JavaScript as well.

 

PHP ESB Calculation

Let’s write the program for ESB. You have to provide the following parameters to calculate ESB for an employee.

<?php 
$status_text = 'Terminated';
$years = 6;
$months = 4;
$days = 28;
$yearsonly =  $years + ($months/12) + ($days/365);
$last_paid_salary = 5000;

if($status_text == 'Resigned'){	
	if ($yearsonly < 2) {
               $result = 'Not eligible end of service benefits';
        }elseif ($yearsonly <= 5) {
               $result = (1 / 6) * $last_paid_salary * $yearsonly;
        }elseif ($yearsonly <= 10) { 
               $result = ((1 / 3) * $last_paid_salary * 5) + ((2 / 3) * $last_paid_salary * ($yearsonly - 5)); 
        } else { 
               $result = (0.5 * $last_paid_salary * 5) + ($last_paid_salary * ($yearsonly - 5)); 
        }
    }elseif($status_text == 'Terminated' || $status_text == 'Decesed'){ 
         $firstPeriod = $secondPeriod = 0; // set periods 
         if ($yearsonly > 5) {
               $firstPeriod = 5;
               $secondPeriod = $yearsonly - 5;
         }   else {
               $firstPeriod = $yearsonly;
         }                    	
         $result = ($firstPeriod * $last_paid_salary * 0.5) + ($secondPeriod * $last_paid_salary); // calculate
    } 
echo $result; ?>

That’s it for the PHP function, Let’s write the  JS program to calculate it.

JavaScript

Once you understand the concept, you can even write it in Javascript.

var status_text = 'Terminated';
var years = 6;
var months = 4;
var days = 28;
var yearsonly =  years + (months/12) + (days/365);
var salary = 5000;

if(status_text == 'Resigned'){	
	if (yearsonly < 2) {
               result = 'Not eligible end of service benefits';
        }elseif (yearsonly <= 5) {
               result = (1 / 6) * salary * yearsonly;
        }elseif (yearsonly <= 10) { 
            result = ((1 / 3) * salary * 5) + ((2 / 3) * salary * (yearsonly - 5)); 
        } else { 
            result = (0.5 * salary * 5) + (salary * (yearsonly - 5)); 
        } 
}elseif(status_text == 'Terminated' || status_text == 'Decesed'){ 
        firstPeriod = secondPeriod = 0; // set periods 
        if (yearsonly > 5) {
               firstPeriod = 5;
               secondPeriod = yearsonly - 5;
         }   else {
               firstPeriod = yearsonly;
         }                    	
         result = (firstPeriod * salary * 0.5) + (secondPeriod * salary); // calculate
    } 
alert( result);

That’s enough I guess, if you have any suggestion, or clarification, or any further improvement, please comment on next tab, I will respond you as early as possible.

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, OpenCart Theme Development, PHP, HTML, CSS, jQuery, Bootstrap development and content SEO.

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar

Subscribe E-mail Updates

Congrats, You are Subscribed to Receive Updates.

Advertisement

Category Posts