Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Salary::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'salary' => $this->salary, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'uid' => Yii::$app->user->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'remark', $this->remark]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Salary::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'salary' => $this->salary, 'date_salary' => $this->date_salary]);
     $query->andFilterWhere(['like', 'employee', $this->employee])->andFilterWhere(['like', 'year', $this->year])->andFilterWhere(['like', 'month', $this->month]);
     return $dataProvider;
 }
Example #3
0
 public function update($id, SalaryPaymentRequest $request)
 {
     try {
         DB::transaction(function () use($request, $id) {
             $inputs = $request->input();
             $user = Auth::user();
             $time = time();
             $date = strtotime(date('d-m-Y'));
             $balance_type = Config::get('common.balance_type_intermediate');
             $year = CommonHelper::get_current_financial_year();
             $salaryPayment = SalaryPayment::find($id);
             $salary = Salary::where(['id' => $salaryPayment->salary_id, 'employee_id' => $salaryPayment->employee_id, 'workspace_id' => $salaryPayment->workspace_id])->first();
             if ($salary->net > $inputs['salary'] && $salaryPayment->amount > $inputs['salary']) {
                 //Decrease amount from Salary payment table
                 $salaryPayment->amount -= $inputs['salary'];
                 $salaryPayment->updated_by = $user->id;
                 $salaryPayment->updated_at = $time;
                 $salaryPayment->update();
                 //Update salaries table
                 $salary->due = $salary->net - $inputs['salary'];
                 $salary->paid = $inputs['salary'];
                 $salary->payment_status = Config::get('common.salary_payment_status.partial');
                 $salary->update();
                 //Update Personal Account
                 $personalAccount = PersonalAccount::where(['person_id' => $salaryPayment->employee_id, 'person_type' => Config::get('common.person_type_employee')])->first();
                 $personalAccount->balance += $salaryPayment->amount - $inputs['salary'];
                 //ADD
                 $personalAccount->updated_by = $user->id;
                 $personalAccount->updated_at = $time;
                 $personalAccount->save();
                 //Update Workspace Ledger
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 42000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $salaryPayment->amount - $inputs['salary'];
                 //Add Wage Payable
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 11000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $salaryPayment->amount - $inputs['salary'];
                 //Add Cash
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 // General Journal Table Impact
                 $generalJournal = GeneralJournal::where(['transaction_type' => Config::get('common.transaction_type.salary_payment'), 'reference_id' => $id, 'account_code' => 42000, 'workspace_id' => $user->workspace_id, 'year' => $year])->first();
                 $generalJournal->amount -= $salaryPayment->amount - $inputs['salary'];
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
                 $generalJournal = GeneralJournal::where(['transaction_type' => Config::get('common.transaction_type.salary_payment'), 'reference_id' => $id, 'account_code' => 11000, 'workspace_id' => $user->workspace_id, 'year' => $year])->first();
                 $generalJournal->amount -= $salaryPayment->amount - $inputs['salary'];
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
             }
         });
     } catch (\Exception $e) {
         Session()->flash('error_message', 'Salary payment update cannot successful. Please Try again.');
         return Redirect::back();
     }
     Session()->flash('flash_message', 'Salary payment update successfully.');
     return redirect('salary_payment');
 }
Example #4
0
 /**
  * Finds the Salary model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Salary the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Salary::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #5
0
 public function actionSave()
 {
     $request = Yii::$app->request;
     $columns = array("employee" => $request->post('employee'), "salary" => $request->post('salary'), "month" => $request->post('month'), "year" => $request->post('year'), "car_id" => $request->post('car_id'), "date_salary" => date("Y-m-d"));
     $result = Salary::find()->where(['employee' => $request->post('employee')])->andWhere(['year' => $request->post('year')])->andWhere(['month' => $request->post('month')])->one();
     if (empty($result)) {
         Yii::$app->db->createCommand()->insert("salary", $columns)->execute();
     } else {
         echo "1";
     }
 }
 public function update($id, SalaryGeneratorRequest $request)
 {
     try {
         DB::transaction(function () use($request, $id) {
             $user = Auth::user();
             $time = time();
             $date = strtotime(date('d-m-Y'));
             $year = CommonHelper::get_current_financial_year();
             $transaction_type = Config::get('common.transaction_type.salary');
             $balance_type = Config::get('common.balance_type_intermediate');
             $inputs = $request->input();
             $salary = Salary::find($id);
             $copy = clone $salary;
             $salary->cut = $inputs['cut'];
             $salary->net = $inputs['net'];
             $salary->net_due = $inputs['net'];
             if ($inputs['over_time'] > 0) {
                 $salary->over_time = $inputs['over_time'];
                 $salary->over_time_due = $inputs['overtime_amount'];
                 $salary->over_time_amount = $inputs['overtime_amount'];
             }
             if ($inputs['bonus'] > 0) {
                 $salary->bonus = $inputs['bonus'];
                 $salary->bonus_due = $inputs['bonus'];
             }
             $salary->update();
             $personalAccount = PersonalAccount::where(['person_id' => $copy->employee_id, 'person_type' => Config::get('common.person_type_employee')])->first();
             if ($inputs['net'] > $copy->net) {
                 $balance = $inputs['net'] - $copy->net;
                 $personalAccount->balance += $balance;
                 //Add
             } elseif ($inputs['net'] < $copy->net) {
                 $balance = $copy->net - $inputs['net'];
                 $personalAccount->balance -= $balance;
                 //Sub
             }
             if ($inputs['overtime_amount'] > $copy->over_time_amount) {
                 $personalAccount->overtime_balance += $inputs['overtime_amount'] - $copy->over_time_amount;
             } elseif ($inputs['overtime_amount'] < $copy->over_time_amount) {
                 $personalAccount->overtime_balance -= $copy->over_time_amount - $inputs['overtime_amount'];
             }
             if ($inputs['bonus'] > $copy->bonus) {
                 $personalAccount->bonus_balance += $inputs['bonus'] - $copy->bonus;
             } elseif ($inputs['bonus'] < $copy->bonus) {
                 $personalAccount->bonus_balance -= $copy->bonus - $inputs['bonus'];
             }
             $personalAccount->updated_by = $user->id;
             $personalAccount->updated_at = $time;
             $personalAccount->save();
             if ($inputs['net'] > $copy->net) {
                 //Update Workspace Ledger
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 42000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $balance;
                 //Add Salary Payable
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 22000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $balance;
                 //Add Salary Expense
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 // General Journal Table Impact
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 42000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 $generalJournal->amount += $balance;
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 22000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 $generalJournal->amount += $balance;
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
             } elseif ($inputs['net'] < $copy->net) {
                 //Update Workspace Ledger
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 42000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance -= $balance;
                 //Add Salary Payable
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 22000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance -= $balance;
                 //Add Salary Expense
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 // General Journal Table Impact
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 42000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 $generalJournal->amount -= $balance;
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 22000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 $generalJournal->amount -= $balance;
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
             }
             if ($inputs['over_time'] && !$copy->over_time) {
                 //Update Workspace Ledger
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 44000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $inputs['overtime_amount'];
                 //Add Overtime Payable
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 // General Journal Table Impact
                 $generalJournal = new GeneralJournal();
                 $generalJournal->date = $date;
                 $generalJournal->transaction_type = $transaction_type;
                 $generalJournal->reference_id = $salary->id;
                 $generalJournal->year = $year;
                 $generalJournal->account_code = 44000;
                 $generalJournal->workspace_id = $user->workspace_id;
                 $generalJournal->amount = $inputs['over_time'];
                 $generalJournal->dr_cr_indicator = Config::get('common.debit_credit_indicator.credit');
                 $generalJournal->created_by = $user->id;
                 $generalJournal->created_at = $time;
                 $generalJournal->save();
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 29993, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $inputs['overtime_amount'];
                 //Add Overtime Expense
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 $generalJournal = new GeneralJournal();
                 $generalJournal->date = $date;
                 $generalJournal->transaction_type = $transaction_type;
                 $generalJournal->reference_id = $salary->id;
                 $generalJournal->year = $year;
                 $generalJournal->account_code = 29993;
                 $generalJournal->workspace_id = $user->workspace_id;
                 $generalJournal->amount = $inputs['over_time'];
                 $generalJournal->dr_cr_indicator = Config::get('common.debit_credit_indicator.debit');
                 $generalJournal->created_by = $user->id;
                 $generalJournal->created_at = $time;
                 $generalJournal->save();
             } else {
                 if (!$inputs['over_time'] && $copy->over_time) {
                     //Update Workspace Ledger
                     $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 44000, 'balance_type' => $balance_type, 'year' => $year])->first();
                     $accountPayableWorkspaceData->balance -= $copy->over_time;
                     //Add Overtime Payable
                     $accountPayableWorkspaceData->updated_by = $user->id;
                     $accountPayableWorkspaceData->updated_at = $time;
                     $accountPayableWorkspaceData->update();
                     // General Journal Table Impact
                     $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 44000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                     $generalJournal->delete();
                     $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 29993, 'balance_type' => $balance_type, 'year' => $year])->first();
                     $accountPayableWorkspaceData->balance = $copy->over_time;
                     //Add Overtime Expense
                     $accountPayableWorkspaceData->updated_by = $user->id;
                     $accountPayableWorkspaceData->updated_at = $time;
                     $accountPayableWorkspaceData->update();
                     // General Journal Table Impact
                     $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 29993, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                     $generalJournal->deleet();
                 } else {
                     if ($inputs['over_time'] > $copy->over_time) {
                         //Update Workspace Ledger
                         $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 44000, 'balance_type' => $balance_type, 'year' => $year])->first();
                         $accountPayableWorkspaceData->balance += $inputs['overtime_amount'] - $copy->overtime_amount;
                         //Add Overtime Payable
                         $accountPayableWorkspaceData->updated_by = $user->id;
                         $accountPayableWorkspaceData->updated_at = $time;
                         $accountPayableWorkspaceData->update();
                         $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 29993, 'balance_type' => $balance_type, 'year' => $year])->first();
                         $accountPayableWorkspaceData->balance += $inputs['overtime_amount'] - $copy->overtime_amount;
                         //Add Overtime Expense
                         $accountPayableWorkspaceData->updated_by = $user->id;
                         $accountPayableWorkspaceData->updated_at = $time;
                         $accountPayableWorkspaceData->update();
                         // General Journal Table Impact
                         $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 44000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                         $generalJournal->amount += $inputs['overtime_amount'] - $copy->overtime_amount;
                         $generalJournal->updated_by = $user->id;
                         $generalJournal->updated_at = $time;
                         $generalJournal->save();
                         $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 29993, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                         $generalJournal->amount += $inputs['overtime_amount'] - $copy->overtime_amount;
                         $generalJournal->updated_by = $user->id;
                         $generalJournal->updated_at = $time;
                         $generalJournal->save();
                     } elseif ($inputs['over_time'] < $copy->over_time) {
                         //Update Workspace Ledger
                         $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 44000, 'balance_type' => $balance_type, 'year' => $year])->first();
                         $accountPayableWorkspaceData->balance -= $copy->overtime_amount - $inputs['overtime_amount'];
                         //Sub Overtime Payable
                         $accountPayableWorkspaceData->updated_by = $user->id;
                         $accountPayableWorkspaceData->updated_at = $time;
                         $accountPayableWorkspaceData->update();
                         $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 29993, 'balance_type' => $balance_type, 'year' => $year])->first();
                         $accountPayableWorkspaceData->balance -= $copy->overtime_amount - $inputs['overtime_amount'];
                         //Sub Overtime Expense
                         $accountPayableWorkspaceData->updated_by = $user->id;
                         $accountPayableWorkspaceData->updated_at = $time;
                         $accountPayableWorkspaceData->update();
                         // General Journal Table Impact
                         $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 44000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                         $generalJournal->amount -= $copy->overtime_amount - $inputs['overtime_amount'];
                         $generalJournal->updated_by = $user->id;
                         $generalJournal->updated_at = $time;
                         $generalJournal->save();
                         $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 29993, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                         $generalJournal->amount -= $copy->overtime_amount - $inputs['overtime_amount'];
                         $generalJournal->updated_by = $user->id;
                         $generalJournal->updated_at = $time;
                         $generalJournal->save();
                     }
                 }
             }
             if ($inputs['bonus'] > $copy->bonus) {
                 //Update Workspace Ledger
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 45000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $inputs['bonus'] - $copy->bonus;
                 //Add bonus Payable
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 29970, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance += $inputs['bonus'] - $copy->bonus;
                 //Add bonus Expense
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 // General Journal Table Impact
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 45000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 if ($generalJournal) {
                     $generalJournal->amount += $inputs['bonus'] - $copy->bonus;
                     $generalJournal->updated_by = $user->id;
                     $generalJournal->updated_at = $time;
                     $generalJournal->save();
                 } else {
                     $generalJournal = new GeneralJournal();
                     $generalJournal->date = $date;
                     $generalJournal->transaction_type = $transaction_type;
                     $generalJournal->reference_id = $salary->id;
                     $generalJournal->year = $year;
                     $generalJournal->account_code = 45000;
                     $generalJournal->workspace_id = $user->workspace_id;
                     $generalJournal->amount = $inputs['bonus'];
                     $generalJournal->dr_cr_indicator = Config::get('common.debit_credit_indicator.credit');
                     $generalJournal->created_by = $user->id;
                     $generalJournal->created_at = $time;
                     $generalJournal->save();
                 }
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 29970, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 if ($generalJournal) {
                     $generalJournal->amount += $inputs['bonus'] - $copy->bonus;
                     $generalJournal->updated_by = $user->id;
                     $generalJournal->updated_at = $time;
                     $generalJournal->save();
                 } else {
                     $generalJournal = new GeneralJournal();
                     $generalJournal->date = $date;
                     $generalJournal->transaction_type = $transaction_type;
                     $generalJournal->reference_id = $salary->id;
                     $generalJournal->year = $year;
                     $generalJournal->account_code = 29970;
                     $generalJournal->workspace_id = $user->workspace_id;
                     $generalJournal->amount = $inputs['bonus'];
                     $generalJournal->dr_cr_indicator = Config::get('common.debit_credit_indicator.debit');
                     $generalJournal->created_by = $user->id;
                     $generalJournal->created_at = $time;
                     $generalJournal->save();
                 }
             } elseif ($inputs['bonus'] < $copy->bonus) {
                 //Update Workspace Ledger
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 45000, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance -= $copy->bonus - $inputs['bonus'];
                 //Sub bonus Payable
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 $accountPayableWorkspaceData = WorkspaceLedger::where(['workspace_id' => $user->workspace_id, 'account_code' => 29970, 'balance_type' => $balance_type, 'year' => $year])->first();
                 $accountPayableWorkspaceData->balance -= $copy->bonus - $inputs['bonus'];
                 //Sub bonus Expense
                 $accountPayableWorkspaceData->updated_by = $user->id;
                 $accountPayableWorkspaceData->updated_at = $time;
                 $accountPayableWorkspaceData->update();
                 // General Journal Table Impact
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 45000, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 $generalJournal->amount -= $copy->bonus - $inputs['bonus'];
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
                 $generalJournal = GeneralJournal::where(['transaction_type' => $transaction_type, 'reference_id' => $id, 'account_code' => 29970, 'year' => $year, 'workspace_id' => $user->workspace_id])->first();
                 $generalJournal->amount -= $copy->bonus - $inputs['bonus'];
                 $generalJournal->updated_by = $user->id;
                 $generalJournal->updated_at = $time;
                 $generalJournal->save();
             }
         });
     } catch (\Exception $e) {
         dd($e);
         Session()->flash('error_message', 'Salary cannot Update. Please Try again.');
         return Redirect::back();
     }
     Session()->flash('flash_message', 'Salary updated successfully.');
     return redirect('salary_generator');
 }
Example #7
0
 public function getEmployeePayment(Request $request)
 {
     $employee_id = $request->employee_id;
     $month = $request->month;
     $salary = Salary::where('employee_id', '=', $employee_id)->where('employee_type', '=', Config::get('common.employee_type.Regular'))->where('year', '=', CommonHelper::get_current_financial_year())->where('month', '=', $month)->where('status', '!=', 4)->first();
     $employee = Employee::where('id', '=', $employee_id)->where('status', '=', 1)->with(['designation', 'workspace'])->first();
     $ajaxView = view('ajaxView.employeeSalaryPayment')->with(compact('salary', 'employee'))->render();
     return response()->json($ajaxView);
 }