From 2a6d05f9df4ff7c5b3ac610a755ea3f3777b58e3 Mon Sep 17 00:00:00 2001 From: paulcortez Date: Fri, 4 Oct 2024 16:22:22 +0800 Subject: [PATCH] Payroll processing - pay transaction pay transaction --- app/Config/Routes.php | 5 + app/Controllers/PayrollController.php | 56 +++++ ...-10-02-045734_CreatePayrollTransaction.php | 102 +++++++++ ...-062830_AddConstraintOnEmployeePayInfo.php | 22 ++ .../2024-10-04-072909_CreateEmpPayTrans.php | 193 ++++++++++++++++++ app/Entities/PayrollTransaction.php | 24 +++ app/Models/PayrollTransactionModel.php | 62 ++++++ .../payroll/compensationbenefitsview.php | 14 +- app/Views/payroll/emppaytransactionview.php | 165 +++++++++++++++ app/Views/payroll/paytransactionview.php | 159 +++++++++++++++ .../templates/adminlte/generalcontent.php | 6 +- 11 files changed, 796 insertions(+), 12 deletions(-) create mode 100644 app/Database/Migrations/2024-10-02-045734_CreatePayrollTransaction.php create mode 100644 app/Database/Migrations/2024-10-02-062830_AddConstraintOnEmployeePayInfo.php create mode 100644 app/Database/Migrations/2024-10-04-072909_CreateEmpPayTrans.php create mode 100644 app/Entities/PayrollTransaction.php create mode 100644 app/Models/PayrollTransactionModel.php create mode 100644 app/Views/payroll/emppaytransactionview.php create mode 100644 app/Views/payroll/paytransactionview.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c1010e9..530ac13 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -51,6 +51,11 @@ $routes->post('payroll/delcomben', 'PayrollController::deleteEmployeeCompensatio $routes->get('payroll/paysettings', 'PayrollController::payrollSettings'); $routes->post('payroll/paysettings', 'PayrollController::payrollSettings'); +$routes->get('payroll/paytrans', 'PayrollController::payrollTransactions'); +$routes->post('payroll/addpaytrans', 'PayrollController::addPayrollTransactions'); + +$routes->get('payroll/emppaytrans/(:num)', 'PayrollController::employeePayrollTransactions/$1'); + // Administrator Routes $routes->get('adminuser', 'AdministratorController::index'); $routes->get('adminuser/newuser', 'AdministratorController::newUserView'); diff --git a/app/Controllers/PayrollController.php b/app/Controllers/PayrollController.php index 78b5bd0..95bade1 100644 --- a/app/Controllers/PayrollController.php +++ b/app/Controllers/PayrollController.php @@ -14,6 +14,7 @@ use App\Models\EmployeeModel; use App\Models\EmpPayIncomeDeductionModel; use App\Models\SettingsModel; use App\Models\PayrollScheduleModel; +use App\Models\PayrollTransactionModel; // Entities @@ -25,6 +26,7 @@ use App\Entities\Employee; use App\Entities\EmpPayIncomeDeduction; use App\Entities\Settings; use App\Entities\PayrollSchedule; +use App\Entities\PayrollTransaction; // Class Library use App\ClassLib\MiscLib; @@ -344,4 +346,58 @@ class PayrollController extends BaseController return view('payroll/paysettingsview', $data); } + + public function payrollTransactions() + { + $data['paytypes'] = (new PayrollTypeModel())->findAll(); + $data['paySchedules'] = (new PayrollScheduleModel())->findAll(); + + $payTrans = (new PayrollTransactionModel())->orderBy('created_at', 'DESC')->findAll(); + + $payTransHTMLTable = new \CodeIgniter\View\Table(); + $payTransHTMLTable->setTemplate(MiscLib::adminLTETableTemplate()); + + if($payTrans == null) + $data['tblPayTrans'] = '

No transactions found.

'; + else + { + foreach($payTrans as $trans) + { + $payTransHTMLTable->setHeading('ID', 'From', 'To', 'No. of Days', 'Status', 'Remarks', 'Action'); + + $iconEdit = ''; + + $payTransHTMLTable->addRow($trans->paytrans_id, $trans->payroll_from, $trans->payroll_to, $trans->no_of_days, $trans->is_open ? 'Open' : ' Closed', $trans->remarks, $iconEdit); + } + + $data['tblPayTrans'] = $payTransHTMLTable->generate(); + } + + return view('payroll/paytransactionview', $data); + } + + public function addPayrollTransactions() + { + $payTransModel = new PayrollTransactionModel(); + $payTrans = new PayrollTransaction(); + + $rawData = $this->request->getPost(); + + $payTrans->fill($rawData); + + if($payTransModel->save($payTrans)) + return redirect()->to('/payroll/paytrans')->with('message', 'Payroll Transaction Added'); + else + return redirect()->back()->withInput()->with('error', 'Failed to add payroll transaction'); + } + + public function employeePayrollTransactions($paytransid) + { + $data['paytransid'] = $paytransid; + $data['paygroupid'] = $this->request->getGet('grpid'); + + $data['paygroups'] = (new PayrollGroupModel())->findAll(); + + return view('payroll/emppaytransactionview', $data); + } } diff --git a/app/Database/Migrations/2024-10-02-045734_CreatePayrollTransaction.php b/app/Database/Migrations/2024-10-02-045734_CreatePayrollTransaction.php new file mode 100644 index 0000000..101f4c9 --- /dev/null +++ b/app/Database/Migrations/2024-10-02-045734_CreatePayrollTransaction.php @@ -0,0 +1,102 @@ +forge->addField([ + 'paytrans_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true + ], + 'paytype_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'payschedule_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'payroll_from' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'payroll_to' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'no_of_days' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => false, + 'default' => 0 + ], + 'total_emp' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => false, + 'default' => 0 + ], + 'total_gross' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'remarks' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true + ], + 'is_open' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 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('paytrans_id', true); + $this->forge->addForeignKey('paytype_id', 'pay_type', 'paytype_id', 'CASCADE', 'RESTRICT'); + $this->forge->addForeignKey('payschedule_id', 'pay_schedule', 'payschedule_id', 'CASCADE', 'RESTRICT'); + $this->forge->createTable('pay_trans'); + } + + public function down() + { + $this->forge->dropTable('pay_trans'); + } +} diff --git a/app/Database/Migrations/2024-10-02-062830_AddConstraintOnEmployeePayInfo.php b/app/Database/Migrations/2024-10-02-062830_AddConstraintOnEmployeePayInfo.php new file mode 100644 index 0000000..863871c --- /dev/null +++ b/app/Database/Migrations/2024-10-02-062830_AddConstraintOnEmployeePayInfo.php @@ -0,0 +1,22 @@ +forge->addForeignKey('employee_id', 'employee', 'employee_id', 'CASCADE', 'RESTRICT'); + $this->forge->addForeignKey('paytype_id', 'pay_type', 'paytype_id', 'CASCADE', 'RESTRICT'); + $this->forge->processIndexes('emp_pay_info'); + } + + public function down() + { + $this->forge->dropForeignKey('emp_pay_info', 'emp_pay_info_employee_id_foreign'); + $this->forge->dropForeignKey('emp_pay_info', 'emp_pay_info_paytype_id_foreign'); + $this->forge->processIndexes('emp_pay_info'); + } +} diff --git a/app/Database/Migrations/2024-10-04-072909_CreateEmpPayTrans.php b/app/Database/Migrations/2024-10-04-072909_CreateEmpPayTrans.php new file mode 100644 index 0000000..78d909b --- /dev/null +++ b/app/Database/Migrations/2024-10-04-072909_CreateEmpPayTrans.php @@ -0,0 +1,193 @@ +forge->addField([ + 'emppaytrans_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true + ], + 'paytrans_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'company_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'dept_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'job_title_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'emp_status_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'employee_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true + ], + 'company_issued_id' => [ + 'type' => 'VARCHAR', + 'constraint' => 25, + ], + 'last_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + ], + 'first_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + ], + 'middle_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + ], + 'suffix' => [ + 'type' => 'VARCHAR', + 'constraint' => 10, + 'null' => true, + ], + 'email_address' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + ], + 'is_ATM' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'savings_account' => [ + 'type' => 'VARCHAR', + 'constraint' => 50, + 'null' => true + ], + 'basic_monthly_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'basic_daily_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'basic_hourly_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'has_cola' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_philhealth' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_hdmf' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_sss' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_gsis' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'gross_income' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'taxable_income' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'nontaxable_income' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'income_tax' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'total_deduction' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'net_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + '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('emppaytrans_id', true); + $this->forge->addForeignKey('paytype_id', 'pay_type', 'paytype_id', 'CASCADE', 'RESTRICT'); + $this->forge->addForeignKey('payschedule_id', 'pay_schedule', 'payschedule_id', 'CASCADE', 'RESTRICT'); + $this->forge->createTable('pay_trans'); + } + + public function down() + { + // + } +} diff --git a/app/Entities/PayrollTransaction.php b/app/Entities/PayrollTransaction.php new file mode 100644 index 0000000..fce911f --- /dev/null +++ b/app/Entities/PayrollTransaction.php @@ -0,0 +1,24 @@ + null, + 'paytype_id' => null, + 'payschedule_id' => null, + 'payroll_from' => null, + 'payroll_to' => null, + 'no_of_days' => null, + 'total_emp' => null, + 'total_gross' => null, + 'remarks' => null, + 'is_open' => null, + ]; + protected $datamap = []; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + protected $casts = []; +} diff --git a/app/Models/PayrollTransactionModel.php b/app/Models/PayrollTransactionModel.php new file mode 100644 index 0000000..95eeda7 --- /dev/null +++ b/app/Models/PayrollTransactionModel.php @@ -0,0 +1,62 @@ +user()->employee_id; + return $data; + } + + public function assignUpdatedBy(array $data) + { + $data['data']['updated_by'] = auth()->user()->employee_id; + return $data; + } +} diff --git a/app/Views/payroll/compensationbenefitsview.php b/app/Views/payroll/compensationbenefitsview.php index 8023768..bdbb915 100644 --- a/app/Views/payroll/compensationbenefitsview.php +++ b/app/Views/payroll/compensationbenefitsview.php @@ -322,9 +322,10 @@
- - payschedule_id) ? 'selected' : ''; ?> payschedule_id.'" '.$selected.'>['.$paySchedule->sched_code.'] '.$paySchedule->sched_name.'' ?> + payschedule_id) ? 'selected' : ''; ?> + payschedule_id.'" '.$selected.'>['.$paySchedule->sched_code.'] '.$paySchedule->sched_name.'' ?>
@@ -511,14 +512,9 @@ + + + +endSection() ?> + + \ No newline at end of file diff --git a/app/Views/payroll/paytransactionview.php b/app/Views/payroll/paytransactionview.php new file mode 100644 index 0000000..678d1f9 --- /dev/null +++ b/app/Views/payroll/paytransactionview.php @@ -0,0 +1,159 @@ + +extend('templates/adminlte/generalcontent') ?> + + + +section('title') ?>Payroll TransactionendSection() ?> + + + +section('css') ?> + + + + +endSection() ?> + + + +section('bodyclass') ?>sidebar-miniendSection() ?> + + + +section('containertitle') ?>Payroll TransactionendSection() ?> + + + +section('activebreadcrumb') ?>Payroll TransactionendSection() ?> + + + +section('main') ?> + + + + + +
+
+
+
+

List of Payroll Transaction

+
+
+
+ +
+
+ +
+
+
+ +endSection() ?> + + + + +section('js') ?> + + + + + + + + + +endSection() ?> + + \ No newline at end of file diff --git a/app/Views/templates/adminlte/generalcontent.php b/app/Views/templates/adminlte/generalcontent.php index 47b5c12..1370996 100644 --- a/app/Views/templates/adminlte/generalcontent.php +++ b/app/Views/templates/adminlte/generalcontent.php @@ -275,16 +275,16 @@

- Payroll Preparation + Payroll Processing