Compare commits
12 Commits
Documentin
...
master
Author | SHA1 | Date | |
---|---|---|---|
1912508766 | |||
627da598fd | |||
7533bfa812 | |||
101ecf7c3c | |||
369bfc6a46 | |||
569f6f5872 | |||
df2c3951d4 | |||
956c22f73c | |||
dcac46b1fb | |||
6e1b70305b | |||
fa8422c8b0 | |||
4a22f4d307 |
@ -43,10 +43,9 @@ To install docker compose
|
||||
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
|
||||
And finally the containers can be initialized by running
|
||||
|
||||
And finally the containers can be initialized by running
|
||||
.. code-block:: bash
|
||||
sudo docker-compose up --build -d
|
||||
sudo docker-compose up --build -d
|
||||
|
||||
Sign in
|
||||
-----------------
|
||||
|
@ -103,9 +103,11 @@
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="updateEmployee();">Update</a>
|
||||
<a href="#" class="btn btn-lg btn-primary " onclick="loadView(currentView);">Clear</a>
|
||||
<a href="#" class="btn btn-lg btn-danger " onclick="deleteEmployee();">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
@ -85,9 +85,10 @@
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="saveNewEmployee();">Create</a>
|
||||
<a href="#" class="btn btn-lg btn-primary " onclick="loadView(currentView);">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
@ -134,6 +134,7 @@
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="processSaveActionWorkDay();">Save</a>
|
||||
<a href="#" class="btn btn-lg btn-primary " onclick="loadView(currentView);">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -134,6 +134,43 @@ function loadEmployeeData(code){
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Will change the status of an employee to remove them from the
|
||||
* active employee list
|
||||
*/
|
||||
function deleteEmployee(){
|
||||
let baseUrl = getbaseUrl();
|
||||
let code = $('#editEmployeeCode').val();
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/api/employee/' + code,
|
||||
type: 'DELETE',
|
||||
dataType: 'json',
|
||||
success:function(data){
|
||||
$('#modalServerResponseSuccess').modal('show');
|
||||
document.getElementById('serverResponseSuccess').innerHTML = 'The employee ' + data['firstName'] + ' ' + data['middleName'] + ' ' + data['lastName'] + ' has been deleted.';
|
||||
},
|
||||
error:function(x,e) {
|
||||
let responseText = $.parseJSON(x["responseText"]);
|
||||
|
||||
if (x.status==0) {
|
||||
$('#modalErrorInternetConnection').modal('show');
|
||||
} else if(x.status==404) {
|
||||
$('#modalError404').modal('show');
|
||||
} else if(x.status==500) {
|
||||
$('#modalServerResponseError').modal('show');
|
||||
document.getElementById('modalResponseError').innerHTML = responseText['message'];
|
||||
} else if(e=='parsererror') {
|
||||
$('#modalErrorParsererror').modal('show');
|
||||
} else if(e=='timeout'){
|
||||
$('#modalErrorTimeout').modal('show');
|
||||
} else {
|
||||
$('#modalErrorOther').modal('show');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function updateEmployee(){
|
||||
let baseUrl = getbaseUrl();
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
// will contain the current loaded view
|
||||
let currentView;
|
||||
|
||||
/**
|
||||
* Destorys the session for the current user and redirects
|
||||
* back to the login form
|
||||
@ -59,6 +62,8 @@ function loadView(requestedView){
|
||||
url: baseUrl + '/html/' + requestedView,
|
||||
type: 'get',
|
||||
success:function(data){
|
||||
currentView = requestedView;
|
||||
|
||||
$("#newViewBody").hide().html(data).show('slow');
|
||||
},
|
||||
error:function(x,e) {
|
||||
@ -80,4 +85,12 @@ function loadView(requestedView){
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the last view that was accessed as a way of fully clearing and
|
||||
* resetting the values of the form
|
||||
*/
|
||||
function clearView(view){
|
||||
loadView(view);
|
||||
}
|
||||
|
@ -518,9 +518,19 @@ class EmployeeApplication{
|
||||
return $response;
|
||||
}
|
||||
|
||||
function disableEmployeeRecord($idEmployee){
|
||||
/**
|
||||
* @param $code string
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
function disableEmployeeRecord($code){
|
||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||
|
||||
$idEmployee = $this->getIdEmployeeByCode($code);
|
||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||
|
||||
$employeeData = $this->proxyGetEmployeeDataById($idEmployee);
|
||||
|
||||
try {
|
||||
$stmt = $this->pdo->prepare("UPDATE employees
|
||||
SET
|
||||
@ -532,8 +542,12 @@ class EmployeeApplication{
|
||||
$this->pdo->commit();
|
||||
|
||||
$stmt = null;
|
||||
|
||||
return $employeeData;
|
||||
|
||||
} catch( PDOExecption $e ) {
|
||||
$this->pdo->rollback();
|
||||
throw new Exception("The employee you tried to delete could not be found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,12 @@ $app->put('/api/employee', function ($request, $response) {
|
||||
->write(json_encode($this->employeeApplication->updateEmployeeData($requestData)));
|
||||
});
|
||||
|
||||
$app->DELETE('/api/employee/{idEmployee}', function (Request $request, Response $response, array $args) {
|
||||
$idEmployee = $args['idEmployee'];
|
||||
$app->DELETE('/api/employee/{code}', function (Request $request, Response $response, array $args) {
|
||||
$code = $args['code'];
|
||||
|
||||
return $response->withStatus(200)
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->write(json_encode($this->employeeApplication->disableEmployeeRecord($idEmployee)));
|
||||
->write(json_encode($this->employeeApplication->disableEmployeeRecord($code)));
|
||||
});
|
||||
|
||||
$app->get('/api/employee/type/{code}', function (Request $request, Response $response, array $args) {
|
||||
|
BIN
calculatingSalary.bmp
Normal file
BIN
calculatingSalary.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
99
documentation/README.rst
Normal file
99
documentation/README.rst
Normal file
@ -0,0 +1,99 @@
|
||||
================
|
||||
Documentation
|
||||
================
|
||||
|
||||
.. contents::
|
||||
|
||||
Requirements
|
||||
----------------------------------
|
||||
Funtional:
|
||||
- A user name and password auth
|
||||
- Encrypted sensitive data
|
||||
- The employee need to have their full name captured
|
||||
- The last name must tolerate being null
|
||||
- An email will be needed for the employee
|
||||
- The email format must be formated
|
||||
- Employees will need a phone number
|
||||
- Searching employees despite the encryption
|
||||
- Employees must have a unique code to reference them
|
||||
- Being able to modify the name, email and phone values of already existing employees
|
||||
- Having the values for the different payments parametrized
|
||||
- Allowing for employees to perform other roles during their work day
|
||||
- Only for the auxiliary personnel
|
||||
- Taking into account only the current month for the salary
|
||||
- Reducing the taxes for the salary
|
||||
- If it goes beyond the threshold a different percentage is paid in taxes
|
||||
- The way the extra tax is handled should be parametrized
|
||||
|
||||
|
||||
Funtional:
|
||||
- Session management
|
||||
- Data integrity
|
||||
- Data security
|
||||
- Accessible through web
|
||||
- Containerized
|
||||
|
||||
Software behaivor
|
||||
-----------------
|
||||
In:
|
||||
- Employee details
|
||||
- First name
|
||||
- Middle name
|
||||
- Last name
|
||||
- Birth date
|
||||
- Email
|
||||
- Phone number
|
||||
- Work per day
|
||||
- Number of deliveries
|
||||
- Rol performed
|
||||
Process:
|
||||
- Register a new employee
|
||||
- Modify employee
|
||||
- Search employee
|
||||
- Add new work day for employee
|
||||
- Calculate monthly payment for employee
|
||||
|
||||
Out:
|
||||
- Upon registering
|
||||
- Employee code
|
||||
- In the work days registry
|
||||
- Raw salary for the the month
|
||||
- Taxes discounted
|
||||
- Real salary for the month
|
||||
- Vouchers (if applicable)
|
||||
|
||||
Calculating the monthly salary
|
||||
--------------------------------
|
||||
.. image:: https://raw.githubusercontent.com/PootisPenserHere/payroll_manager/master/documentation/calculatingSalary.bmp
|
||||
|
||||
Tests cases
|
||||
-----------------
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| Id | Description | Input | Expected output |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| 1 | Displaying current salary for the outgoing month | Selecting an employee from the search field | On the right side of the window a break down of the employee's salary for the month will be displayed |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| 2 | Submitting incomplete form | All of the input but one of the fields | An error shown in a red modal describing the missing field |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| 3 | Altering the sent data to change the performed rol to one that can't be done by the employee | A employee other than aux performing a different rol than their own | An error displaying that the employee can't perform that task |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
|
||||
Executed tests
|
||||
---------------
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| Id | Description | Result | What went wrong? |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| 1 | Displaying current salary for the outgoing month | When the employee was selected the current salary was loaded succesfully | |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| 2 | Submitting incomplete form | Got the error "The number of deliveries cannot be empty or 0" | |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| 3 | Altering the sent data to change the performed rol to one that can't be done by the employee | Got the error "The selected rol can't be done by this type of employee" | |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
|
||||
Tools
|
||||
----------------------------------
|
||||
The following tools and software were used:
|
||||
- phpstorm
|
||||
- git
|
||||
- docker && docker-compose
|
||||
- Ubuntu 16
|
BIN
documentation/calculatingSalary.bmp
Normal file
BIN
documentation/calculatingSalary.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
Loading…
Reference in New Issue
Block a user