income and deduction

income and deduction
pull/3/head
paulcortez 8 months ago
parent 94ef2e070a
commit da9a3b315d

@ -35,8 +35,8 @@ $routes->get('payroll', 'PayrollController::index');
$routes->get('payroll/paygroup', 'PayrollController::payrollGroup');
$routes->post('payroll/addpaygroup', 'PayrollController::addPayrollGroup');
$routes->get('payroll/emppaygrpassign', 'PayrollController::employeePayrollGroupAssignment');
$routes->post('payroll/addemppaygrpassign', 'PayrollController::addEmployeePayrollGroupAssignment');
$routes->get('payroll/inded', 'PayrollController::incomeDeduction');
$routes->post('payroll/addinded', 'PayrollController::addIncomeDeduction');
// Administrator Routes
$routes->get('adminuser', 'AdministratorController::index');

@ -7,10 +7,12 @@ use CodeIgniter\HTTP\ResponseInterface;
// Models
use App\Models\PayrollGroupModel;
use App\Models\IncomeDeductionModel;
// Entities
use App\Entities\PayrollGroup;
use App\Entities\IncomeDeduction;
// Class Library
use App\ClassLib\MiscLib;
@ -36,7 +38,7 @@ class PayrollController extends BaseController
{
foreach($payGroups as $group)
{
$payGroupHTMLTable->setHeading('Group ID', 'Group Name', 'Action');
$payGroupHTMLTable->setHeading('ID', 'Group Name', 'Action');
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Group Information"><i class="fas fa-eye "></i></a>';
@ -65,14 +67,50 @@ class PayrollController extends BaseController
return redirect()->to('/payroll/paygroup')->with('message', 'Payroll Group Added');
}
public function employeePayrollGroupAssignment()
public function incomeDeduction()
{
$incomeDeductions = (new IncomeDeductionModel())->findAll();
return view('payroll/empaygrpview');
$inDedHTMLTable = new \CodeIgniter\View\Table();
$inDedHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($incomeDeductions == null)
$data['tblIncomeDeduction'] = '<p>No income and deduction found.</p>';
else
{
foreach($incomeDeductions as $incomeDeduction)
{
$inDedHTMLTable->setHeading('ID', 'Payslip Display', 'COA Code', 'Deduction Name', 'Income', 'Taxable', 'Include in Gross', 'Action');
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>';
$inDedHTMLTable->addRow($incomeDeduction->inded_id, $incomeDeduction->payslip_display, $incomeDeduction->coa_code, $incomeDeduction->income_deduction_name, ($incomeDeduction->is_income) ? 'Yes' : 'No', ($incomeDeduction->is_taxable) ? 'Yes' : 'No', ($incomeDeduction->include_in_gross) ? 'Yes' : 'No', $iconView);
}
$data['tblIncomeDeduction'] = $inDedHTMLTable->generate();
}
return view('payroll/incomedeductionview', $data);
}
public function addEmployeePayrollGroupAssignment()
public function addIncomeDeduction()
{
$incomeDeduction = new IncomeDeduction();
$incomeDeductionModel = new IncomeDeductionModel();
$rawData = $this->request->getPost();
// Handle checkbox inputs
$rawData['is_income'] = isset($rawData['is_income']) ? 1 : 0; // Set to 1 if checked, 0 if not
$rawData['is_taxable'] = isset($rawData['is_taxable']) ? 1 : 0; // Same for taxable
$rawData['include_in_gross'] = isset($rawData['include_in_gross']) ? 1 : 0; // Same for include in gross
$incomeDeduction->fill($rawData);
$incomeDeductionModel->save($incomeDeduction);
if($incomeDeductionModel->getInsertID() == 0)
return redirect()->back()->withInput()->with('error', 'Failed to add income or deduction');
else
return redirect()->to('/payroll/inded')->with('message', 'Income or Deduction Added');
}
}

@ -0,0 +1,82 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateIncomeDeduction extends Migration
{
public function up()
{
$this->forge->addField([
'inded_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true
],
'payslip_display' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => false
],
'inded_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => false
],
'coa_code' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => true,
],
'is_income' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'is_taxable' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'include_in_gross' => [
'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('inded_id', true);
$this->forge->createTable('pay_income_deduction');
}
public function down()
{
$this->forge->dropTable('pay_income_deduction');
}
}

@ -0,0 +1,21 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class IncomeDeduction extends Entity
{
protected $attributes = [
'inded_id' => null,
'payslip_display' => null,
'inded_name' => null,
'coa_code' => null,
'is_income' => null,
'is_taxable' => null,
'include_in_gross' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -0,0 +1,62 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class IncomeDeductionModel extends Model
{
protected $table = 'pay_income_deduction';
protected $primaryKey = 'inded_id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\IncomeDeduction::class;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['payslip_display',
'inded_name',
'coa_code',
'is_income',
'is_taxable',
'include_in_gross'];
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;
}
}

@ -0,0 +1,129 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>Income and Deduction<?= $this->endSection() ?>
<!-- .Title -->
<!-- CSS of the page -->
<?= $this->section('css') ?>
<?= $this->endSection() ?>
<!-- .CSS -->
<!-- body attribute - class definition -->
<?= $this->section('bodyclass') ?>sidebar-mini<?= $this->endSection() ?>
<!-- .body attribute -->
<!-- Container title -->
<?= $this->section('containertitle') ?>Income and Deduction<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('activebreadcrumb') ?>Income and Deduction<?= $this->endSection() ?>
<!-- .Active breadcrumb -->
<!-- Main content -->
<?= $this->section('main') ?>
<!-- Modal Add Branch -->
<div class="modal fade" id="mdlAddInDed">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?= url_to('payroll/addinded') ?>" method="post">
<div class="modal-header">
<h4 class="modal-title" >New Income or 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">Income or Deduction Information</p>
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="txtInDedName">Income or Deduction Name</label>
<input class="form-control" type="text" id="txtInDedName" name="inded_name" values="<?= old('inded_name') ?>">
</div>
<div class="form-group">
<label for="txtPayslipDisplay">Display on Payslip</label>
<input class="form-control" type="text" id="txtPayslipDisplay" name="payslip_display" value="<?= old('payslip_display') ?>">
<p style="font-size: smaller"><i>Short name that will appear in payslip</i></p>
</div>
<div class="form-group">
<label for="txtCOACode">COA Code</label>
<input class="form-control" type="text" id="txtCOACode" name="coa_code" value="<?= old('coa_code') ?>">
<p style="font-size: smaller"><i>COA code (Chart of Account) is a code used by accounting department</i></p>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkIsIncome" name="is_income">
<label for="chkIsIncome" class="custom-control-label">Is Income? this will be treated as deduction if unchecked</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkIsTaxable" name="is_taxable">
<label for="chkIsTaxable" class="custom-control-label">Is Taxable? this will be treated as non-taxable if unchecked</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkIncludeInGross" name="include_in_gross">
<label for="chkIncludeInGross" class="custom-control-label">Include in Gross?</label>
</div>
</div>
</div>
</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>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">List of Income and Deduction</h3>
</div>
<div class="card-body">
<div class="card-body table-responsive p-0">
<?= $tblIncomeDeduction ?>
</div>
</div>
<div class="card-footer">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddInDed">Add Income or Deduction</button>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<script>
$(document).ready(function() {
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->

@ -202,21 +202,58 @@
<?php if(auth()->user()->inGroup('admin', 'superadmin', 'payroll')): ?>
<li class="nav-header">PAYROLL</li>
<li class="nav-item">
<a href="/payroll/paygroup" class="nav-link">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
Payroll Group
References &amp; Settings
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="/payroll/paygroup" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
Payroll Group
</p>
</a>
</li>
<li class="nav-item">
<a href="/payroll/inded" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
Income and Deductions
</p>
</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="../gallery.html" class="nav-link">
<a href="#" class="nav-link">
<i class="nav-icon far fa-image"></i>
<p>
EmpPay Assignment
<span class="badge badge-info right">2</span>
Payroll Preparation
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon far fa-image"></i>
<p>
Initialize Payroll
</p>
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon far fa-image"></i>
<p>
Income &amp; Deduction
</p>
</a>
</li>
</ul>
</li>
<?php endif; ?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save