Ejemplo n.º 1
0
 /**
  * get the profile tax salary details.
  *
  * @Get("ajax/profile/salary/edit")
  * @Get("ajax/profile/salary")
  * @Get("ajax/pim/employee-list/{id}/salary")
  * @Get("ajax/pim/employee-list/{id}/salary/edit")
  *
  * @param SalaryRequest $request
  * @author Jim Callanta
  */
 public function updateSalary(SalaryRequest $request)
 {
     if ($request->ajax()) {
         $mode = Config::get('salary.semi_monthly');
         $semiMonthly = $request->get('salary') / $mode;
         $status = $request->get('status');
         $sss = $request->get('sss');
         $taxableSalary = $semiMonthly - $request->get('deductions');
         try {
             if ($request->get('type') == 'sss') {
                 $getSSS = SSSContribution::where('range_compensation_from', '<=', $semiMonthly)->orderBy('range_compensation_from', 'desc')->first();
                 $deductions = $request->get('deductions') - $sss + $getSSS->sss_ee;
                 $sss = $getSSS->sss_ee;
                 $taxableSalary = $semiMonthly - $deductions;
             } else {
                 $taxableSalary = $semiMonthly - $request->get('deductions');
             }
             $taxes = TaxComputation::getTaxRate($status, $taxableSalary);
             $over = 0;
             if ($taxableSalary > $taxes->{$status}) {
                 $over = $taxableSalary - $taxes->{$status};
             }
             $totalTax = $taxes->exemption + $over * $taxes->percentage_over;
             $return = json_encode(['tax' => $totalTax, 'sss' => $sss, 'salary' => $semiMonthly]);
             print $return;
         } catch (Exception $e) {
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Updates the Profile - Salary.
  *
  * @Patch("profile/salary")
  * @Patch("pim/employee-list/{id}/salary")
  *
  * @param SalaryRequest $request
  * @return \Illuminate\Http\RedirectResponse
  * @author Bertrand Kintanar
  */
 public function update(SalaryRequest $request)
 {
     $id = $request->get('employee_id');
     $fields = $request->except('_method', '_token', 'employee_id');
     foreach ($fields as $value) {
         $value['employee_id'] = $id;
         if ($value['effective_date'] == 0) {
             $value['effective_date'] = date('Y-m-d');
         }
         try {
             $employee_salary_component = $this->employee_salary_component->getCurrentComponentValue($id, $value['component_id']);
             if ($employee_salary_component->value != 0 && $employee_salary_component->value != $value['value']) {
                 $this->employee_salary_component->create($value);
             } else {
                 $employee_salary_component->value = $value['value'];
                 $employee_salary_component->effective_date = $value['effective_date'];
                 $employee_salary_component->save();
             }
         } catch (Exception $e) {
             return redirect()->to($request->path())->with('danger', UNABLE_UPDATE_MESSAGE);
         }
     }
     return redirect()->to($request->path())->with('success', SUCCESS_UPDATE_MESSAGE);
 }