|
|
|
@ -275,7 +275,7 @@ class PayrollController extends BaseController
|
|
|
|
|
$data['salarycomputations'] = $payCompute->basic_salary_computations;
|
|
|
|
|
|
|
|
|
|
$empPayInfoHTMLTable = new \CodeIgniter\View\Table();
|
|
|
|
|
$empPayInfoHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
|
|
|
|
|
$empPayInfoHTMLTable->setTemplate(MiscLib::adminLTEDataTable1Template("tblEmployeeInfo"));
|
|
|
|
|
|
|
|
|
|
if($empPayInfos == null)
|
|
|
|
|
$data['tblEmpPayInfo'] = '<p>No employee payroll type found.</p>';
|
|
|
|
@ -510,11 +510,12 @@ class PayrollController extends BaseController
|
|
|
|
|
$incomeDeductionModel = new IncomeDeductionModel();
|
|
|
|
|
|
|
|
|
|
$data['paygroupid'] = $this->request->getGet('grpid');
|
|
|
|
|
$data['showInitBtn'] = false;
|
|
|
|
|
|
|
|
|
|
$payTrans = (new PayrollTransactionModel())->where('paytrans_id', $paytransid)->first();
|
|
|
|
|
$data['paytransid'] = $paytransid;
|
|
|
|
|
$data['initURL'] = $paytransid.'/'.$data['paygroupid'].'/'.$payTrans->paytype_id;
|
|
|
|
|
// INIT, OPEN, CLOSED
|
|
|
|
|
$data['transactionStatus'] = 'INIT';
|
|
|
|
|
|
|
|
|
|
//$payTrans = (new PayrollTransactionModel())->where('paytrans_id', $paytransid)->first();
|
|
|
|
|
$data['payTrans'] = (new PayrollTransactionModel())->find($paytransid);
|
|
|
|
|
|
|
|
|
|
$data['paygroups'] = (new PayrollGroupModel())->findAll();
|
|
|
|
|
$data['incomeList'] = $incomeDeductionModel->where("is_income", 1)->findAll();
|
|
|
|
@ -527,14 +528,14 @@ class PayrollController extends BaseController
|
|
|
|
|
|
|
|
|
|
if($empPayTrans == null)
|
|
|
|
|
{
|
|
|
|
|
$empPayTrans = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByPayGrpId($data['paygroupid'], $payTrans->paytype_id);
|
|
|
|
|
$empPayTrans = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByPayGrpId($data['paygroupid'], $data['payTrans']->paytype_id);
|
|
|
|
|
$attSummary = (new AttendanceSummaryModel())->where('paytrans_id', $paytransid)->findAll();
|
|
|
|
|
|
|
|
|
|
$empPayTransHTMLTable->setHeading('ID', 'Company ID', 'Name', 'Branch', 'Daily Basic', 'Work Days');
|
|
|
|
|
|
|
|
|
|
if($empPayTrans != null)
|
|
|
|
|
{
|
|
|
|
|
$data['showInitBtn'] = true;
|
|
|
|
|
$data['transactionStatus'] = 'INIT';
|
|
|
|
|
|
|
|
|
|
foreach($empPayTrans as $trans)
|
|
|
|
|
{
|
|
|
|
@ -547,6 +548,8 @@ class PayrollController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$data['transactionStatus'] = 'OPEN';
|
|
|
|
|
|
|
|
|
|
$empPayTransHTMLTable->setHeading('ID', 'Name', 'Branch', 'Basic Salary', 'Days Work', 'Gross', 'Deduction', 'Net', 'Action');
|
|
|
|
|
|
|
|
|
|
foreach($empPayTrans as $trans)
|
|
|
|
@ -569,11 +572,101 @@ class PayrollController extends BaseController
|
|
|
|
|
return view('payroll/emppaytransactionview', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function employeePayrollTransactionsViewEmpForInit($paytransid, $paygroupid)
|
|
|
|
|
{
|
|
|
|
|
$incomeDeductionModel = new IncomeDeductionModel();
|
|
|
|
|
|
|
|
|
|
$data['payGroup'] = (new PayrollGroupModel())->find($paygroupid);
|
|
|
|
|
$data['payTrans'] = (new PayrollTransactionModel())->find($paytransid);
|
|
|
|
|
|
|
|
|
|
// INIT, OPEN, CLOSED
|
|
|
|
|
$data['transactionStatus'] = 'INIT';
|
|
|
|
|
|
|
|
|
|
$empPayTrans = (new EmployeePayTransactionModel())->getEmpPayTransByPayTransIdGroupId($paytransid, $paygroupid);
|
|
|
|
|
$empPayInfos = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByPayGrpId($paygroupid, $data['payTrans']->paytype_id);
|
|
|
|
|
|
|
|
|
|
$empPayTransHTMLTable = new \CodeIgniter\View\Table();
|
|
|
|
|
$empPayTransHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
|
|
|
|
|
|
|
|
|
|
$attSummary = (new AttendanceSummaryModel())->where('paytrans_id', $paytransid)->findAll();
|
|
|
|
|
|
|
|
|
|
$empPayTransHTMLTable->setHeading('ID', 'Company ID', 'Name', 'Branch', 'Daily Basic', 'Work Days', 'Action');
|
|
|
|
|
|
|
|
|
|
foreach($empPayInfos as $empPayInfo)
|
|
|
|
|
{
|
|
|
|
|
$empAttSum = MiscLib::searchFromAsocArray('employee_id', $empPayInfo->employee_id, $attSummary);
|
|
|
|
|
$empIsInEmpPayTrans = (MiscLib::searchFromAsocArray('employee_id', $empPayInfo->employee_id, $empPayTrans) == null) ? false : true;
|
|
|
|
|
$empPayTransHTMLTable->addRow($empPayInfo->employee_id, $empPayInfo->company_issued_id, $empPayInfo->last_name . ', ' . $empPayInfo->first_name, $empPayInfo->branch_code, $empPayInfo->basic_monthly_pay, ($empAttSum === null) ? 0 : $empAttSum->att_work_days, ($empIsInEmpPayTrans) ? '<button type="button" class="btn btn-primary btn-sm" disabled>Already Initialized</button>' : '<a href="/payroll/emppaytransempinit/'.$data['payTrans']->paytrans_id.'/'.$empPayInfo->emppay_id.'" class="btn btn-warning btn-sm">Initialize</a>');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data['tblEmpPayTrans'] = $empPayTransHTMLTable->generate();
|
|
|
|
|
|
|
|
|
|
return view('payroll/emppaytransinitempview', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function empPayTransFillArrayFromEmpPayInfo($paytransid, $empPayInfo, $empAttSum)
|
|
|
|
|
{
|
|
|
|
|
return ['paytrans_id' => $paytransid,
|
|
|
|
|
'company_id' => $empPayInfo->company_id,
|
|
|
|
|
'branch_code' => $empPayInfo->branch_code,
|
|
|
|
|
'dept_id' => $empPayInfo->dept_id,
|
|
|
|
|
'job_title_id' => $empPayInfo->job_title_id,
|
|
|
|
|
'pay_group_id' => $empPayInfo->pay_group_id,
|
|
|
|
|
'emp_status_id' => $empPayInfo->emp_status_id,
|
|
|
|
|
'employee_id' => $empPayInfo->employee_id,
|
|
|
|
|
'company_issued_id' => $empPayInfo->company_issued_id,
|
|
|
|
|
'last_name' => $empPayInfo->last_name,
|
|
|
|
|
'first_name' => $empPayInfo->first_name,
|
|
|
|
|
'middle_name' => $empPayInfo->middle_name,
|
|
|
|
|
'suffix' => $empPayInfo->suffix,
|
|
|
|
|
'email_address' => $empPayInfo->email_address,
|
|
|
|
|
'is_ATM' => $empPayInfo->is_ATM,
|
|
|
|
|
'savings_account' => $empPayInfo->savings_account,
|
|
|
|
|
'basic_sal_computation' => $empPayInfo->basic_sal_computation,
|
|
|
|
|
'basic_monthly_pay' => $empPayInfo->basic_monthly_pay,
|
|
|
|
|
'basic_semi_monthly_pay' => $empPayInfo->basic_semi_monthly_pay,
|
|
|
|
|
'basic_daily_pay' => $empPayInfo->basic_daily_pay,
|
|
|
|
|
'basic_hourly_pay' => $empPayInfo->basic_hourly_pay,
|
|
|
|
|
'has_cola' => $empPayInfo->has_cola,
|
|
|
|
|
'has_philhealth' => $empPayInfo->has_philhealth,
|
|
|
|
|
'has_hdmf' => $empPayInfo->has_hdmf,
|
|
|
|
|
'has_sss' => $empPayInfo->has_sss,
|
|
|
|
|
'has_gsis' => $empPayInfo->has_gsis,
|
|
|
|
|
'actual_work_days' => ($empAttSum === null) ? 0 : $empAttSum->att_work_days,
|
|
|
|
|
'basic_pay' => 0,
|
|
|
|
|
'gross_income' => 0,
|
|
|
|
|
'taxable_income' => 0,
|
|
|
|
|
'nontaxable_income' => 0,
|
|
|
|
|
'income_tax' => 0,
|
|
|
|
|
'total_deduction' => 0,
|
|
|
|
|
'taxable_deduction' => 0,
|
|
|
|
|
'nontaxable_deduction' => 0,
|
|
|
|
|
'net_pay' => 0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function empPayTransInDedFillArrayFromEmpPayInDed($emppaytransid, $empPayInDed, $amount)
|
|
|
|
|
{
|
|
|
|
|
return ['emppaytrans_id' => $emppaytransid,
|
|
|
|
|
'inded_id' => $empPayInDed->inded_id,
|
|
|
|
|
'payslip_display' => $empPayInDed->payslip_display,
|
|
|
|
|
'inded_name' => $empPayInDed->inded_name,
|
|
|
|
|
'coa_code' => $empPayInDed->coa_code,
|
|
|
|
|
'is_income' => $empPayInDed->is_income,
|
|
|
|
|
'is_taxable' => $empPayInDed->is_taxable,
|
|
|
|
|
'include_in_gross' => $empPayInDed->include_in_gross,
|
|
|
|
|
'is_fixed_amt' => $empPayInDed->is_fixed_amt,
|
|
|
|
|
'is_percent_amt' => $empPayInDed->is_percent_amt,
|
|
|
|
|
'worked_days_based' => $empPayInDed->worked_days_based,
|
|
|
|
|
'amount' => $amount,
|
|
|
|
|
'base_amount' => $empPayInDed->amount,
|
|
|
|
|
'is_override' => $empPayInDed->is_override];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function empPayTransInitializePayroll($paytransid, $paygroupid, $transtypid)
|
|
|
|
|
{
|
|
|
|
|
$empPayInfos = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByPayGrpId($paygroupid, $transtypid);
|
|
|
|
|
$attSummary = (new AttendanceSummaryModel())->where('paytrans_id', $paytransid)->findAll();
|
|
|
|
|
$payTrans = (new PayrollTransactionModel())->where('paytrans_id', $paytransid)->first();
|
|
|
|
|
$payTrans = (new PayrollTransactionModel())->find($paytransid);
|
|
|
|
|
$empPayTransactionModel = new EmployeePayTransactionModel();
|
|
|
|
|
|
|
|
|
|
foreach($empPayInfos as $empPayInfo)
|
|
|
|
@ -581,44 +674,7 @@ class PayrollController extends BaseController
|
|
|
|
|
$empPayTransaction = new EmployeePayTransaction();
|
|
|
|
|
$empAttSum = MiscLib::searchFromAsocArray('employee_id', $empPayInfo->employee_id, $attSummary);
|
|
|
|
|
|
|
|
|
|
$empPayTransaction->fill(
|
|
|
|
|
['paytrans_id' => $paytransid,
|
|
|
|
|
'company_id' => $empPayInfo->company_id,
|
|
|
|
|
'branch_code' => $empPayInfo->branch_code,
|
|
|
|
|
'dept_id' => $empPayInfo->dept_id,
|
|
|
|
|
'job_title_id' => $empPayInfo->job_title_id,
|
|
|
|
|
'pay_group_id' => $empPayInfo->pay_group_id,
|
|
|
|
|
'emp_status_id' => $empPayInfo->emp_status_id,
|
|
|
|
|
'employee_id' => $empPayInfo->employee_id,
|
|
|
|
|
'company_issued_id' => $empPayInfo->company_issued_id,
|
|
|
|
|
'last_name' => $empPayInfo->last_name,
|
|
|
|
|
'first_name' => $empPayInfo->first_name,
|
|
|
|
|
'middle_name' => $empPayInfo->middle_name,
|
|
|
|
|
'suffix' => $empPayInfo->suffix,
|
|
|
|
|
'email_address' => $empPayInfo->email_address,
|
|
|
|
|
'is_ATM' => $empPayInfo->is_ATM,
|
|
|
|
|
'savings_account' => $empPayInfo->savings_account,
|
|
|
|
|
'basic_sal_computation' => $empPayInfo->basic_sal_computation,
|
|
|
|
|
'basic_monthly_pay' => $empPayInfo->basic_monthly_pay,
|
|
|
|
|
'basic_semi_monthly_pay' => $empPayInfo->basic_semi_monthly_pay,
|
|
|
|
|
'basic_daily_pay' => $empPayInfo->basic_daily_pay,
|
|
|
|
|
'basic_hourly_pay' => $empPayInfo->basic_hourly_pay,
|
|
|
|
|
'has_cola' => $empPayInfo->has_cola,
|
|
|
|
|
'has_philhealth' => $empPayInfo->has_philhealth,
|
|
|
|
|
'has_hdmf' => $empPayInfo->has_hdmf,
|
|
|
|
|
'has_sss' => $empPayInfo->has_sss,
|
|
|
|
|
'has_gsis' => $empPayInfo->has_gsis,
|
|
|
|
|
'actual_work_days' => ($empAttSum === null) ? 0 : $empAttSum->att_work_days,
|
|
|
|
|
'basic_pay' => 0,
|
|
|
|
|
'gross_income' => 0,
|
|
|
|
|
'taxable_income' => 0,
|
|
|
|
|
'nontaxable_income' => 0,
|
|
|
|
|
'income_tax' => 0,
|
|
|
|
|
'total_deduction' => 0,
|
|
|
|
|
'taxable_deduction' => 0,
|
|
|
|
|
'nontaxable_deduction' => 0,
|
|
|
|
|
'net_pay' => 0]
|
|
|
|
|
);
|
|
|
|
|
$empPayTransaction->fill($this->empPayTransFillArrayFromEmpPayInfo($paytransid, $empPayInfo, $empAttSum));
|
|
|
|
|
|
|
|
|
|
$empPayTransactionModel->save($empPayTransaction);
|
|
|
|
|
$empPayTransaction = $empPayTransactionModel->find($empPayTransactionModel->getInsertID());
|
|
|
|
@ -637,22 +693,7 @@ class PayrollController extends BaseController
|
|
|
|
|
'worked_days_based'=>$empPayInDed->worked_days_based];
|
|
|
|
|
$amount = $payCompute->computeIncomeDeductionByComputationType($rawData, $empPayTransaction);
|
|
|
|
|
|
|
|
|
|
$empPayTransInDed->fill(
|
|
|
|
|
['emppaytrans_id' => $empPayTransaction->emppaytrans_id,
|
|
|
|
|
'inded_id' => $empPayInDed->inded_id,
|
|
|
|
|
'payslip_display' => $empPayInDed->payslip_display,
|
|
|
|
|
'inded_name' => $empPayInDed->inded_name,
|
|
|
|
|
'coa_code' => $empPayInDed->coa_code,
|
|
|
|
|
'is_income' => $empPayInDed->is_income,
|
|
|
|
|
'is_taxable' => $empPayInDed->is_taxable,
|
|
|
|
|
'include_in_gross' => $empPayInDed->include_in_gross,
|
|
|
|
|
'is_fixed_amt' => $empPayInDed->is_fixed_amt,
|
|
|
|
|
'is_percent_amt' => $empPayInDed->is_percent_amt,
|
|
|
|
|
'worked_days_based' => $empPayInDed->worked_days_based,
|
|
|
|
|
'amount' => $amount,
|
|
|
|
|
'base_amount' => $empPayInDed->amount,
|
|
|
|
|
'is_override' => $empPayInDed->is_override]
|
|
|
|
|
);
|
|
|
|
|
$empPayTransInDed->fill($this->empPayTransInDedFillArrayFromEmpPayInDed($empPayTransaction->emppaytrans_id, $empPayInDed, $amount));
|
|
|
|
|
|
|
|
|
|
$empPayTransInDedModel->save($empPayTransInDed);
|
|
|
|
|
}
|
|
|
|
@ -663,6 +704,45 @@ class PayrollController extends BaseController
|
|
|
|
|
return redirect()->back()->withInput()->with('message', 'Payroll processed. Please verify the entries.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function empPayTransInitializeEmpPayroll($paytransid, $emppayid)
|
|
|
|
|
{
|
|
|
|
|
$empPayTransactionModel = new EmployeePayTransactionModel();
|
|
|
|
|
|
|
|
|
|
$empPayInfo = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByEmpPayId($emppayid);
|
|
|
|
|
$payTrans = (new PayrollTransactionModel())->find($paytransid);
|
|
|
|
|
$attSummary = (new AttendanceSummaryModel())->where('paytrans_id', $paytransid)->findAll();
|
|
|
|
|
$empAttSum = MiscLib::searchFromAsocArray('employee_id', $empPayInfo->employee_id, $attSummary);
|
|
|
|
|
|
|
|
|
|
$empPayTransaction = new EmployeePayTransaction();
|
|
|
|
|
$empPayTransaction->fill($this->empPayTransFillArrayFromEmpPayInfo($paytransid, $empPayInfo, $empAttSum));
|
|
|
|
|
|
|
|
|
|
$empPayTransactionModel->save($empPayTransaction);
|
|
|
|
|
$empPayTransaction = $empPayTransactionModel->find($empPayTransactionModel->getInsertID());
|
|
|
|
|
|
|
|
|
|
$empPayInDeds = (new EmpPayIncomeDeductionModel())->getEmpPayInDedByEmpPayIdSchedId($empPayInfo->emppay_id, $payTrans->payschedule_id);
|
|
|
|
|
|
|
|
|
|
foreach($empPayInDeds as $empPayInDed)
|
|
|
|
|
{
|
|
|
|
|
$empPayTransInDed = new EmpPayTransIncomeDeduction();
|
|
|
|
|
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
|
|
|
|
|
|
|
|
|
|
$payCompute = new PayrollComputation();
|
|
|
|
|
$rawData = ['amount'=>$empPayInDed->amount,
|
|
|
|
|
'is_fixed_amt'=>$empPayInDed->is_fixed_amt,
|
|
|
|
|
'is_percent_amt'=>$empPayInDed->is_percent_amt,
|
|
|
|
|
'worked_days_based'=>$empPayInDed->worked_days_based];
|
|
|
|
|
$amount = $payCompute->computeIncomeDeductionByComputationType($rawData, $empPayTransaction);
|
|
|
|
|
|
|
|
|
|
$empPayTransInDed->fill($this->empPayTransInDedFillArrayFromEmpPayInDed($empPayTransaction->emppaytrans_id, $empPayInDed, $amount));
|
|
|
|
|
|
|
|
|
|
$empPayTransInDedModel->save($empPayTransInDed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->computeEmployeePayroll($empPayTransaction->emppaytrans_id, true);
|
|
|
|
|
|
|
|
|
|
return redirect()->back()->withInput()->with('message', 'Payroll processed. Please verify the entries.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function employeePayrollTransactionsEditDaysWorked()
|
|
|
|
|
{
|
|
|
|
|
$empPayTransModel = new EmployeePayTransactionModel();
|
|
|
|
|