Income and deduction

Initial page
pull/8/head
paulcortez 8 months ago
parent 9269bb5503
commit 1d116b17bb

@ -44,6 +44,9 @@ $routes->post('payroll/addpaytype', 'PayrollController::addPayrollType');
$routes->get('payroll/emppayinfo', 'PayrollController::employeePayrollInfo');
$routes->post('payroll/addemppayinfo', 'PayrollController::addEmployeePayrollInfo');
$routes->get('payroll/compben', 'PayrollController::employeeCompensationBenefits');
$routes->post('payroll/addcompben', 'PayrollController::addEmployeeCompensationBenefits');
// Administrator Routes
$routes->get('adminuser', 'AdministratorController::index');
$routes->get('adminuser/newuser', 'AdministratorController::newUserView');

@ -11,6 +11,7 @@ use App\Models\IncomeDeductionModel;
use App\Models\PayrollTypeModel;
use App\Models\EmployeePayrollInfoModel;
use App\Models\EmployeeModel;
use App\Models\EmpPayIncomeDeductionModel;
// Entities
@ -19,6 +20,7 @@ use App\Entities\IncomeDeduction;
use App\Entities\PayrollType;
use App\Entities\EmployeePayrollInfo;
use App\Entities\Employee;
use App\Entities\EmpPayIncomeDeduction;
// Class Library
use App\ClassLib\MiscLib;
@ -238,4 +240,60 @@ class PayrollController extends BaseController
else
return redirect()->to('/payroll/emppayinfo')->with('message', 'Employee Payroll Type Added');
}
public function employeeCompensationBenefits()
{
$empPayInfoModel = new EmployeePayrollInfoModel();
$incomeDeductionModel = new IncomeDeductionModel();
$empPayInDedModel = new EmpPayIncomeDeductionModel();
$data['incomeList'] = $incomeDeductionModel->where("is_income", 1)->findAll();
$data['deductionList'] = $incomeDeductionModel->where("is_income", 0)->findAll();
$data['empPayInfos'] = $empPayInfoModel->getAllEmpPayInfoJoinedEmpPayType();
$data['empLoaded'] = false;
if($this->request->getGet('empid') != null)
{
$data['empLoaded'] = true;
$data['selectedEmployee'] = $empPayInfoModel->getEmpPayInfoJoinedEmpPayTypeByEmpID($this->request->getGet('empid'));
$data['empPayIncomeList'] = $empPayInDedModel->getEmpPayInDedByEmpPayId($data['selectedEmployee']->emppay_id, true);
$data['empPayDeductionList'] = $empPayInDedModel->getEmpPayInDedByEmpPayId($data['selectedEmployee']->emppay_id, false);
}
return view('payroll/compensationbenefitsview', $data);
}
public function addEmployeeCompensationBenefits()
{
$empPayInDed = new EmpPayIncomeDeduction();
$empPayInDedModel = new EmpPayIncomeDeductionModel();
$rawData = $this->request->getPost();
// Initialize all payroll type fields to 0
$rawData['is_fixed_amt'] = 0;
$rawData['is_percent_amt'] = 0;
// Handle radio button input
if (isset($rawData['amount_type'])) {
switch ($rawData['amount_type']) {
case 'fixed':
$rawData['is_fixed_amt'] = 1;
break;
case 'perc':
$rawData['is_percent_amt'] = 1;
break;
}
}
$rawData['is_override'] = isset($rawData['is_override']) ? 1 : 0;
$empPayInDed->fill($rawData);
$empPayInDedModel->save($empPayInDed);
if($empPayInDedModel->getInsertID() == 0)
return redirect()->back()->withInput()->with('error', 'Failed to add employee compensation benefits');
else
return redirect()->to('/payroll/compben?empid='.$this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits Added');
}
}

@ -0,0 +1,85 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateEmpPayIncomeDeduction extends Migration
{
public function up()
{
$this->forge->addField([
'emppayinded_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true
],
'emppay_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'inded_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'is_fixed_amt' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'is_percent_amt' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'amount' => [
'type' => 'DECIMAL',
'constraint' => '12,4',
'null' => false
],
'is_override' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
// Common fields
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_by' => [
'type' => 'VARCHAR',
'constraint' => '20',
'null' => true
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_by' => [
'type' => 'VARCHAR',
'constraint' => '20',
'null' => true
],
'deleted_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('emppayinded_id', true);
$this->forge->addForeignKey('emppay_id', 'emp_pay_info', 'emppay_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('inded_id', 'pay_income_deduction', 'inded_id', 'CASCADE', 'RESTRICT');
$this->forge->createTable('emp_pay_inded');
}
public function down()
{
$this->forge->dropTable('emp_pay_inded');
}
}

@ -0,0 +1,22 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class EmpPayIncomeDeduction extends Entity
{
protected $attributes = [
'emppayinded_id' => null,
'emppay_id' => null,
'inded_id' => null,
'is_fixed_amt' => null,
'is_percent_amt' => null,
'amount' => null,
'is_override' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -0,0 +1,72 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class EmpPayIncomeDeductionModel extends Model
{
protected $table = 'emp_pay_inded';
protected $primaryKey = 'emppayinded_id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\EmpPayIncomeDeduction::class;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['emppay_id',
'inded_id',
'is_fixed_amt',
'is_percent_amt',
'amount',
'is_override',
];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ['assignCreatedAt'];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedAt'];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function assignCreatedAt(array $data)
{
$data['data']['created_at'] = date('Y-m-d H:i:s');
$data['data']['created_by'] = auth()->user()->employee_id;
return $data;
}
public function assignUpdatedAt(array $data)
{
$data['data']['updated_at'] = date('Y-m-d H:i:s');
$data['data']['updated_by'] = auth()->user()->employee_id;
return $data;
}
public function getEmpPayInDedByEmpPayId($empPayId, $isIncome)
{
$builder = $this->db->table('emp_pay_inded');
$builder->select('*');
$builder->join('pay_income_deduction', 'pay_income_deduction.inded_id = emp_pay_inded.inded_id');
$builder->where(['emp_pay_inded.emppay_id' => $empPayId, 'pay_income_deduction.is_income' => $isIncome]);
return $builder->get()->getResult();
}
}

@ -76,4 +76,14 @@ class EmployeePayrollInfoModel extends Model
$builder->join('pay_type', 'pay_type.paytype_id = emp_pay_info.paytype_id');
return $builder->get()->getResult();
}
public function getEmpPayInfoJoinedEmpPayTypeByEmpID($empID)
{
$builder = $this->db->table('emp_pay_info');
$builder->select('*');
$builder->join('employee', 'employee.employee_id = emp_pay_info.employee_id');
$builder->join('pay_type', 'pay_type.paytype_id = emp_pay_info.paytype_id');
$builder->where('emp_pay_info.employee_id', $empID);
return $builder->get()->getRow();
}
}

@ -27,13 +27,13 @@
<!-- Main content -->
<?= $this->section('main') ?>
<!-- Modal Add Branch -->
<div class="modal fade" id="mdlAddBranch">
<!-- Modal Add Income -->
<div class="modal fade" id="mdlAddIncome">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?= url_to('payroll/addpaytype') ?>" method="post">
<form action="<?= url_to('payroll/addcompben') ?>" method="post">
<div class="modal-header">
<h4 class="modal-title" >New Payroll Type</h4>
<h4 class="modal-title" >New Employee Income</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
@ -41,37 +41,116 @@
<div class="modal-body">
<div class="row">
<div class="col-12">
<p class="lead">Payroll Type Information</p>
<p class="lead">Employee Income Information</p>
<div class="row">
<?php if($empLoaded) : ?>
<div class="col-12">
<div class="form-group">
<label for="txtPayName">Payroll Type Name</label>
<input class="form-control" type="text" id="txtPayName" name="paytype_name" value="<?= old('paytype_name') ?>">
</div>
<div class="form-group">
<label for="txtPayCode">Payroll Type Code</label>
<input class="form-control" type="text" id="txtPayCode" name="paytype_code" values="<?= old('paytype_code') ?>">
<label>Select Income to Assign</label>
<select class="form-control" style="width: 100%;" name="inded_id">
<?php foreach($incomeList as $income): ?>
<option value="<?= $income->inded_id ?>"><?= $income->inded_name ?></option>
<?php endforeach; ?>
</select>
<input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
<input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="radio" id="rdoIsMonthly" name="paytype_sched" value="monthly">
<label for="rdoIsMonthly" class="form-check-label">Computation is based on monthly salary.</label>
<input class="form-check-input" type="radio" id="rdoFixedAmount" name="amount_type" value="fixed" checked>
<label for="rdoFixedAmount" class="form-check-label">Fixed amount.</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="rdoIsSemiMonthly" name="paytype_sched" value="semi_monthly" checked>
<label for="rdoIsSemiMonthly" class="form-check-label">Computation is based on semi-monthly salary.</label>
<input class="form-check-input" type="radio" id="rdoPercentageAmount" name="amount_type" value="perc">
<label for="rdoPercentageAmount" class="form-check-label">Amount is in percentage.</label>
</div>
</div>
<div class="form-group">
<label for="txtAmount">Amount</label>
<input class="form-control" type="number" id="txtAmount" name="amount" values="<?= old('amount') ?>">
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkIsOverride" name="is_override">
<label for="chkIsOverride" class="custom-control-label">Override computations if there are any.</label>
<p><small><i>Override will implement this amount and not the computational amount made like in SSS, Philhealth, Pag-IBIG and taxastion</i></small></p>
</div>
</div>
</div>
<?php else : ?>
<div class="col-12">
<p class="text-danger">No Employee Loaded. Please select employee first</p>
</div>
<?php endif ?>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal Add Deduction -->
<div class="modal fade" id="mdlAddDeduction">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?= url_to('payroll/addcompben') ?>" method="post">
<div class="modal-header">
<h4 class="modal-title" >New Employee Deduction</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<p class="lead">Employee Deduction Information</p>
<div class="row">
<?php if($empLoaded) : ?>
<div class="col-12">
<div class="form-group">
<label>Select Deduction to Assign</label>
<select class="form-control" style="width: 100%;" name="inded_id">
<?php foreach($deductionList as $deduction): ?>
<option value="<?= $deduction->inded_id ?>"><?= $deduction->inded_name ?></option>
<?php endforeach; ?>
</select>
<input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
<input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="radio" id="rdoIsDaily" name="paytype_sched" value="daily">
<label for="rdoIsDaily" class="form-check-label">Computation is based on daily salary.</label>
<input class="form-check-input" type="radio" id="rdoFixedAmount" name="amount_type" value="fixed" checked>
<label for="rdoFixedAmount" class="form-check-label">Fixed amount.</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="rdoIsHourly" name="paytype_sched" value="hourly">
<label for="rdoIsHourly" class="form-check-label">Computation is based on daily salary.</label>
<input class="form-check-input" type="radio" id="rdoPercentageAmount" name="amount_type" value="perc">
<label for="rdoPercentageAmount" class="form-check-label">Amount is in percentage.</label>
</div>
</div>
<div class="form-group">
<label for="txtAmount">Amount</label>
<input class="form-control" type="number" id="txtAmount" name="amount" values="<?= old('amount') ?>">
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkIsOverride" name="is_override">
<label for="chkIsOverride" class="custom-control-label">Override computations if there are any.</label>
<p><small><i>Override will implement this amount and not the computational amount made like in SSS, Philhealth, Pag-IBIG and taxastion</i></small></p>
</div>
</div>
</div>
<?php else : ?>
<div class="col-12">
<p class="text-danger">No Employee Loaded. Please select employee first</p>
</div>
<?php endif ?>
</div>
</div>
</div>
</div>
@ -92,20 +171,101 @@
<h3 class="card-title">List of Payroll Type</h3>
</div>
<div class="card-body">
<div class="card-body table-responsive p-0">
<?php /*$tblPayrollType*/ ?>
<form action="">
<div class="row">
<div class="col-12">
<form action="/payroll/compben" method="get">
<div class="form-group">
<label>Select Employee</label>
<div class="input-group mb-3">
<input type="text" class="form-control rounded-0">
<select class="form-control select2 rounded-0" name="empid">
<?php foreach($empPayInfos as $empPayInfo): ?>
<?php $selected = ($empLoaded && $selectedEmployee->employee_id == $empPayInfo->employee_id) ? 'selected' : ''; ?>
<?= '<option value="'.$empPayInfo->employee_id.'" '.$selected.'>'.$empPayInfo->last_name.', '.$empPayInfo->first_name.'</option>' ?>
<?php endforeach; ?>
</select>
<span class="input-group-append">
<button type="button" class="btn btn-info btn-flat">Search</button>
<button type="submit" class="btn btn-info btn-flat">Load Income &amp; Deduction</button>
</span>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-12">
<?php if($empLoaded): ?>
<h3>Payroll Income and Deduction Details</h3>
<div class="row">
<div class="col-6 col-xs-6">
<p><strong>Employee Name:</strong> <?= $selectedEmployee->last_name . ', ' . $selectedEmployee->first_name ?></p>
<p><strong>Employee ID:</strong> <?= $selectedEmployee->company_issued_id ?></p>
</div>
<div class="col-6 col-xs-6 text-right">
<p><strong>Basic Salary</strong> <?= $selectedEmployee->basic_monthly_pay ?></p>
<p><strong>Date:</strong> 20/09/2024</p>
</div>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>Description</th>
<th colspan="2" class="text-center">Amount</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$grossTotal = 0;
foreach($empPayIncomeList as $empPayIncome):?>
<tr>
<td><span class="pl-3"><?= $empPayIncome->inded_name ?></span></td>
<td>&nbsp;</td>
<td><?= $empPayIncome->amount ?></td>
<td>&nbsp;</td>
</tr>
<?php endforeach; ?>
<tr>
<td><strong>Gross Total</strong></td>
<td>&nbsp;</td>
<td><strong>$500.00</strong></td>
<td>&nbsp;</td>
</tr>
<?php foreach($empPayDeductionList as $empPayDeduction):?>
<tr>
<td><span class="pl-3"><?= $empPayDeduction->inded_name ?></span></td>
<td>-<?= $empPayDeduction->amount ?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php endforeach; ?>
<tr>
<td><strong>Total Deductions</strong></td>
<td><strong>$500.00</strong></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
<tfoot>
<tr>
<th><span class="text-uppercase">Net Income</span></th>
<td>&nbsp;</td>
<th>$3300.00</th>
<td>&nbsp;</td>
</tr>
</tfoot>
</table>
<?php else: ?>
<p>Select an employee first then click on "Load Income &amp; Deduction" button</p>
<?php endif; ?>
</div>
</div>
</div>
<div class="card-footer">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddBranch">Add Payroll Type</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddIncome">Add Income</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddDeduction">Add Deduction</button>
</div>
</div>
</div>

@ -86,7 +86,7 @@
<div class="form-group">
<label for="txtMonthlyBasicPay">Monthly Basic Salary</label>
<div class="input-group mb-3">
<input class="form-control rounded-0" type="number" id="txtMonthlyBasicPay" name="basic_monthly_pay" values="<?= old('basic_monthly_pay') ?>">
<input class="form-control rounded-0" type="text" id="txtMonthlyBasicPay" name="basic_monthly_pay" values="<?= old('basic_monthly_pay') ?>">
<span class="input-group-append">
<button type="button" class="btn btn-info btn-flat" onclick="computeBasicPay('fromMonthly')">Compute</button>
</span>
@ -95,12 +95,12 @@
</div>
<div class="form-group">
<label for="txtSemiMonthlyBasicPay">Semi-monthly Basic Salary</label>
<input class="form-control" type="number" id="txtSemiMonthlyBasicPay" name="basic_semi_monthly_pay" value="<?= old('basic_semi_monthly_pay') ?>">
<input class="form-control" type="text" id="txtSemiMonthlyBasicPay" name="basic_semi_monthly_pay" value="<?= old('basic_semi_monthly_pay') ?>">
</div>
<div class="form-group">
<label for="txtDailyBasicPay">Daily Basic Salary</label>
<div class="input-group mb-3">
<input class="form-control rounded-0" type="number" id="txtDailyBasicPay" name="basic_daily_pay" values="<?= old('basic_daily_pay') ?>">
<input class="form-control rounded-0" type="text" id="txtDailyBasicPay" name="basic_daily_pay" values="<?= old('basic_daily_pay') ?>">
<span class="input-group-append">
<button type="button" class="btn btn-info btn-flat" onclick="computeBasicPay('fromDaily')">Compute</button>
</span>
@ -109,7 +109,7 @@
</div>
<div class="form-group">
<label for="txtHourlyBasicPay">Hourly Basic Salary</label>
<input class="form-control" type="number" id="txtHourlyBasicPay" name="basic_hourly_pay" value="<?= old('basic_hourly_pay') ?>">
<input class="form-control" type="text" id="txtHourlyBasicPay" name="basic_hourly_pay" value="<?= old('basic_hourly_pay') ?>">
</div>
<p id="txtSalaryFormula"></p>
<div class="form-group">
@ -168,14 +168,6 @@
<div class="card-body">
<div class="card-body table-responsive p-0">
<?= $tblEmpPayInfo ?>
<!-- <form action="">
<div class="input-group mb-3">
<input type="text" class="form-control rounded-0">
<span class="input-group-append">
<button type="button" class="btn btn-info btn-flat">Search</button>
</span>
</div>
</form> -->
</div>
</div>
<div class="card-footer">
@ -199,8 +191,11 @@
<script>
$(document).ready(function() {
//Initialize Select2 Elements
$('.select2').select2();
$('.select2').select2({
dropdownParent: $('#mdlEmpPayInfo')
});
//Initialize Select2 Elements
$('.select2bs4').select2({

@ -71,7 +71,7 @@
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkIncludeInGross" name="include_in_gross">
<input class="custom-control-input" type="checkbox" id="chkIncludeInGross" name="include_in_gross" checked>
<label for="chkIncludeInGross" class="custom-control-label">Include in Gross?</label>
</div>
</div>

@ -222,7 +222,7 @@
<a href="/payroll/inded" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
Income and Deductions
Income &amp; Deductions
</p>
</a>
</li>
@ -254,10 +254,10 @@
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<a href="/payroll/compben" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
Deductions
Compensation &amp; Benefits
</p>
</a>
</li>

@ -1 +0,0 @@
__ci_last_regenerate|i:1725775160;_ci_previous_url|s:22:"http://localhost:8080/";csrf_test_name|s:32:"0a1c5406b3c32ddbc36b51f62231cd84";

@ -1 +0,0 @@
__ci_last_regenerate|i:1726049669;csrf_test_name|s:32:"ed6e1473d2f3c51bcafefa3c48fa20d0";_ci_previous_url|s:27:"http://localhost:8080/login";

@ -1 +0,0 @@
__ci_last_regenerate|i:1725758031;beforeLoginUrl|s:28:"http://localhost:8080/hr/emp";__ci_vars|a:1:{s:14:"beforeLoginUrl";i:1725758331;}

@ -1 +0,0 @@
__ci_last_regenerate|i:1725758031;csrf_test_name|s:32:"008a89b6d66736f5372a0975a2dd537b";_ci_previous_url|s:27:"http://localhost:8080/login";

@ -1 +0,0 @@
__ci_last_regenerate|i:1726051237;csrf_test_name|s:32:"b51217379da0b60e2486dc03c8785d46";_ci_previous_url|s:27:"http://localhost:8080/login";

@ -1 +0,0 @@
__ci_last_regenerate|i:1726049668;beforeLoginUrl|s:28:"http://localhost:8080/hr/emp";__ci_vars|a:1:{s:14:"beforeLoginUrl";i:1726049968;}

@ -1 +0,0 @@
__ci_last_regenerate|i:1725561216;_ci_previous_url|s:22:"http://localhost:8080/";csrf_test_name|s:32:"75a15d472aa07c40129f5c1806fabe69";
Loading…
Cancel
Save