Beispiel #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) {
         }
     }
 }