/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); /* KREDIT */ data_jurnal::create(['id_faktur' => $this->req['id_faktur'], 'id_coa_ledger' => $this->req['id_coa_ledger'], 'tanggal' => date('Y-m-d', strtotime($this->req['tanggal'])), 'deskripsi' => $this->req['deskripsi'], 'id_payment_methode' => $this->req['id_payment_methode'], 'tipe' => 2, 'total' => $this->req['total']]); /* DEBET */ data_jurnal::create(['id_faktur' => $this->req['id_faktur'], 'id_coa_ledger' => $this->req['perkiraan'], 'tanggal' => date('Y-m-d', strtotime($this->req['tanggal'])), 'deskripsi' => $this->req['deskripsi'], 'id_payment_methode' => $this->req['id_payment_methode'], 'tipe' => 1, 'total' => $this->req['total']]); $faktur = data_faktur::find($this->req['id_faktur']); if ($this->req['total'] == $this->req['total_old']) { $faktur->status = 2; } else { $faktur->status = 1; } $faktur->amount_due = $faktur->amount_due + $this->req['total']; $faktur->save(); /* KREDIT */ $coa = ref_coa_ledger::find($this->req['id_coa_ledger']); $coa->balance = $coa->balance + $this->req['total']; $coa->save(); /* DEBET */ $kira = ref_coa_ledger::find($this->req['perkiraan']); $kira->balance = $kira->balance + $this->req['total']; $kira->save(); \DB::commit(); return ['label' => 'success', 'err' => 'Payment berhasil dilakukan']; } catch (\Exception $e) { \DB::rollback(); return ['label' => 'danger', 'err' => $e->getMessage()]; } }
/** * Execute the job. * * @return void */ public function handle() { ref_coa_ledger::find($this->req['id_coa_ledger'])->update(['grup_coa' => $this->req['idparent'], 'nm_coa_ledger' => $this->req['nm_coa_ledger'], 'no_coa_ledger' => $this->req['no_coa_ledger'], 'status_balance' => $this->req['status_balance'], 'balance' => $this->req['balance'], 'keterangan' => $this->req['keterangan']]); return $this->req; }
public function postDestroyledger(Request $req) { ref_coa_ledger::find($req->id)->delete(); return json_encode(['result' => true]); }
public function select_coa($data, $parent = 0) { static $i = 1; $tab = str_repeat(' ', $i); if (isset($data[$parent])) { $out = ''; $i++; foreach ($data[$parent] as $item) { $out .= '<optgroup label="' . $tab . $item->no_coa . ' ' . $item->nm_coa . '">'; $coas = ref_coa_ledger::where('grup_coa', $item->id_coa)->get(); if (count($coas) > 0) { foreach ($coas as $coa) { $out .= '<option value="' . $coa->id_coa_ledger . '">' . $tab . $coa->no_coa_ledger . ' ' . $coa->nm_coa_ledger . '</option>'; } } $out .= '</optgroup>'; $anak = $this->select_coa($data, $item->id_coa); if ($anak) { $out .= $anak; $i--; } } return $out; } else { return false; } }