/** * Store a newly created resource in storage. * * @return Response */ public function store() { $v = Validator::make(Input::all(), ['nama' => 'required|min:1', 'jumlah' => 'required|min:1|numeric', 'tahun' => 'required|numeric']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } $cek = \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->where('id_jenis', Input::get('id_jenis'))->where('bulan', Input::get('bulan'))->where('tahun', Input::get('tahun'))->where('id_anggota', Input::get('id_anggota'))->where('jenis_transaksi', 'Simpanan')->get(); if (sizeof($cek) == 0) { $info_ke = \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->where('id_jenis', Input::get('id_jenis'))->where('id_anggota', Input::get('id_anggota'))->where('jenis_transaksi', 'Simpanan')->get(); $info_ke = sizeof($info_ke); $data = \App\Transaksi::orderBy('id', 'desc')->first()['id']; $new = new \App\Transaksi(); $new->no_transaksi = 'KSP-' . date("ymd") . ($data + 1) . "-S"; $new->id_anggota = Input::get('id_anggota'); $new->keterangan = Input::get('keterangan'); $new->jenis_transaksi = 'Simpanan'; $new->status = 'Lunas'; $new->id_jenis = Input::get('id_jenis'); $new->jumlah_asli = Input::get('jumlah'); $new->jumlah_bunga = 0; $new->bunga = 0; $new->info_ke = $info_ke + 1; $new->bulan = Input::get('bulan'); $new->tahun = Input::get('tahun'); $new->jumlah_total = Input::get('jumlah'); $new->id_koperasi = Auth::user()->assigned_koperasi; $new->created_by = Auth::user()->id; $new->save(); $data = \App\Keuangan::orderBy('id', 'desc')->first()['id']; $finan = new \App\Keuangan(); $finan->no_nota = 'KSP-' . date("ymd") . ($data + 1) . "-B"; $finan->id_koperasi = Auth::user()->assigned_koperasi; $finan->id_anggota = Input::get('id_anggota'); $finan->tabel = 'transaksis'; $finan->jenis = 'tabungan'; $finan->info = "Pembayaran " . \App\Simpanan::where('id_koperasi', Auth::user()->assigned_koperasi)->find(Input::get('id_jenis'))['nama'] . " " . \App\Anggota::where('id_koperasi', Auth::user()->assigned_koperasi)->find(Input::get('id_anggota'))['nama'] . " Rp. " . number_format(Input::get('jumlah'), 2, ",", ".") . " (" . date("d/m/Y H:i:s") . ") " . Auth::user()->name; $finan->id_transaksi = $new->id; $finan->masuk = Input::get('jumlah'); $finan->keluar = 0; $finan->save(); return redirect(url('transaksi/simpanan')); } else { return redirect(url('transaksi/simpanan/baru'))->withPesan('sudah_ada'); } }
public function simpanpengeluarantabungan() { $v = Validator::make(Input::all(), ['jumlah' => 'required|numeric', 'id_anggota' => 'required']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } $data = \App\Keuangan::orderBy('id', 'desc')->first()['id']; $new = new \App\Keuangan(); $new->no_nota = 'KSP-' . date("ymd") . ($data + 1) . "-KLT"; $new->id_koperasi = Auth::user()->assigned_koperasi; $new->id_anggota = Input::get('id_anggota'); $new->info = "Koreksi Tabungan " . Input::get('keterangan') . " Rp. " . number_format(Input::get('jumlah'), 2, ",", ".") . " (" . date("d/m/Y H:i:s") . ") " . Auth::user()->name; $new->jenis = 'tabungan'; $new->keluar = Input::get('jumlah'); $new->save(); return redirect('keuangan/pengeluaran/tabungan')->withData($new->no_nota); }
public function simpanpembayaran() { $v = Validator::make(Input::all(), ['nama' => 'required|min:1']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } $data = \App\Transaksi::where('id', Input::get('id_angsuran'))->first(); $data->no_transaksi = 'KSP-' . date("ymd") . ($data->id_induk . $data->info_ke) . "-PA"; $data->status = 'Lunas'; $data->denda = Input::get('jumlah_denda'); $data->total_denda = Input::get('total_denda'); $data->keterangan = Input::get('keterangan'); $data->save(); if (Input::get('jumlah_angsuran') > 0) { $old_num = \App\Keuangan::orderBy('id', 'desc')->first()['id']; $finan = new \App\Keuangan(); $finan->no_nota = 'KSP-' . date("ymd") . ($old_num + 1) . "-PS"; $finan->id_koperasi = Auth::user()->assigned_koperasi; $finan->id_anggota = Input::get('id_anggota'); $finan->tabel = 'transaksis'; $finan->jenis = 'angsuran'; $finan->info = "Pembayaran Pinjaman ke-" . $data->info_ke . " " . \App\Anggota::where('id_koperasi', Auth::user()->assigned_koperasi)->find(Input::get('id_anggota'))['nama'] . " Rp. " . number_format(Input::get('jumlah_angsuran'), 2, ",", ".") . " (" . date("d/m/Y H:i:s") . ") " . Auth::user()->name; $finan->id_transaksi = $data->id; $finan->masuk = Input::get('jumlah_angsuran'); $finan->keluar = 0; $finan->save(); } if (Input::get('jumlah_tabungan') > 0) { $old_num = \App\Keuangan::orderBy('id', 'desc')->first()['id']; $finan = new \App\Keuangan(); $finan->no_nota = 'KSP-' . date("ymd") . ($old_num + 1) . "-PST"; $finan->id_koperasi = Auth::user()->assigned_koperasi; $finan->id_anggota = Input::get('id_anggota'); $finan->tabel = 'transaksis'; $finan->jenis = 'tabungan'; $finan->info = "Pembayaran Tabungan Pinjaman ke-" . $data->info_ke . " " . \App\Anggota::where('id_koperasi', Auth::user()->assigned_koperasi)->find(Input::get('id_anggota'))['nama'] . " Rp. " . number_format(Input::get('jumlah_tabungan'), 2, ",", ".") . " (" . date("d/m/Y H:i:s") . ") " . Auth::user()->name; $finan->id_transaksi = $data->id; $finan->masuk = Input::get('jumlah_tabungan'); $finan->keluar = 0; $finan->save(); } if (Input::get('total_denda') > 0) { $old_num = \App\Keuangan::orderBy('id', 'desc')->first()['id']; $finan = new \App\Keuangan(); $finan->no_nota = 'KSP-' . date("ymd") . ($old_num + 1) . "-PSD"; $finan->id_koperasi = Auth::user()->assigned_koperasi; $finan->id_anggota = Input::get('id_anggota'); $finan->tabel = 'transaksis'; $finan->jenis = 'denda'; $finan->info = "Pembayaran Denda Pinjaman ke-" . $data->info_ke . " " . \App\Anggota::where('id_koperasi', Auth::user()->assigned_koperasi)->find(Input::get('id_anggota'))['nama'] . " Rp. " . number_format(Input::get('total_denda'), 2, ",", ".") . " (" . date("d/m/Y H:i:s") . ") " . Auth::user()->name; $finan->id_transaksi = $data->id; $finan->masuk = Input::get('total_denda'); $finan->keluar = 0; $finan->save(); } $cou = \App\Transaksi::where('status', 'Lunas')->where('id_induk', $data->id_induk)->get(); $induk = \App\Transaksi::where('id', $data->id_induk)->first(); if ($induk->info_ke == sizeof($cou)) { $induk->status = 'Lunas'; $induk->save(); } return redirect(url('transaksi/pembayaran/selesai/' . $data->no_transaksi)); }