Laba Rugi
Periode {{ $month . ' - ' . $year }}
@php $totalPenjualan = 0; $totalBeban = 0; $totalPajak = 0; $labaRugiKotor = 0; $labaRugiSebelumPajak = 0; $labaRugiBersih = 0; @endphp {{-- penjualan --}} @foreach ($rekeningPenjualan as $item) @php $mutasiDebet = 0; $mutasiKredit = 0; // cek transaksi di field kode $cekTransaksiDiKode = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('kode', $item->kode_akun) ->count(); if ($cekTransaksiDiKode > 0) { $sumMutasiDebetDiKode = \DB::table('view_laba_rugi') ->where('kode', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiKode = \DB::table('view_laba_rugi') ->where('kode', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiKode; $mutasiKredit += $sumMutasiKreditDiKode; // cek transaksi di field lawan $cekTransaksiDiLawan = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('lawan', $item->kode_akun) ->count(); if ($cekTransaksiDiLawan > 0) { $sumMutasiDebetDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiLawan; $mutasiKredit += $sumMutasiKreditDiLawan; } } else { // cek transaksi di field lawan // cek transaksi di field lawan $cekTransaksiDiLawan = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('lawan', $item->kode_akun) ->count(); if ($cekTransaksiDiLawan > 0) { $sumMutasiDebetDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiLawan; $mutasiKredit += $sumMutasiKreditDiLawan; } } $penjualan = $mutasiKredit - $mutasiDebet; $totalPenjualan += $penjualan; @endphp @endforeach {{-- Harga Pokok Penjualan --}} {{-- --}} {{-- laba rugi kotor --}} @php $labaRugiKotor = $totalPenjualan; @endphp {{-- beban --}} {{-- all beban --}} @foreach ($rekeningBeban as $item) @php $mutasiDebet = 0; $mutasiKredit = 0; // cek transaksi di field kode $cekTransaksiDiKode = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('kode', $item->kode_akun) ->count(); if ($cekTransaksiDiKode > 0) { $sumMutasiDebetDiKode = \DB::table('view_laba_rugi') ->where('kode', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiKode = \DB::table('view_laba_rugi') ->where('kode', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiKode; $mutasiKredit += $sumMutasiKreditDiKode; // cek transaksi di field lawan $cekTransaksiDiLawan = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('lawan', $item->kode_akun) ->count(); if ($cekTransaksiDiLawan > 0) { $sumMutasiDebetDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiLawan; $mutasiKredit += $sumMutasiKreditDiLawan; } } else { // cek transaksi di field lawan // cek transaksi di field lawan $cekTransaksiDiLawan = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('lawan', $item->kode_akun) ->count(); if ($cekTransaksiDiLawan > 0) { $sumMutasiDebetDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiLawan; $mutasiKredit += $sumMutasiKreditDiLawan; } } if ($item->kodeInduk->tipe == 'Debit') { $beban = $mutasiDebet - $mutasiKredit; $totalBeban += $beban; } else { $beban = $mutasiKredit - $mutasiDebet; $totalBeban -= $beban; } @endphp @endforeach {{-- laba rugi sebelum pajak --}} @php $labaRugiSebelumPajak = $labaRugiKotor - $totalBeban; @endphp {{-- pajak --}} {{-- all pajak --}} @foreach ($rekeningPajak as $item) @php $mutasiDebet = 0; $mutasiKredit = 0; // cek transaksi di field kode $cekTransaksiDiKode = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('kode', $item->kode_akun) ->count(); if ($cekTransaksiDiKode > 0) { $sumMutasiDebetDiKode = \DB::table('view_laba_rugi') ->where('kode', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiKode = \DB::table('view_laba_rugi') ->where('kode', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiKode; $mutasiKredit += $sumMutasiKreditDiKode; // cek transaksi di field lawan $cekTransaksiDiLawan = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('lawan', $item->kode_akun) ->count(); if ($cekTransaksiDiLawan > 0) { $sumMutasiDebetDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiLawan; $mutasiKredit += $sumMutasiKreditDiLawan; } } else { // cek transaksi di field lawan // cek transaksi di field lawan $cekTransaksiDiLawan = \DB::table('view_laba_rugi') ->where('bulan', $month) ->where('tahun', $year) ->where('lawan', $item->kode_akun) ->count(); if ($cekTransaksiDiLawan > 0) { $sumMutasiDebetDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') ->sum('view_laba_rugi.nominal'); $sumMutasiKreditDiLawan = \DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') ->sum('view_laba_rugi.nominal'); $mutasiDebet += $sumMutasiDebetDiLawan; $mutasiKredit += $sumMutasiKreditDiLawan; } } if ($item->kodeInduk->tipe == 'Debit') { $pajak = $mutasiDebet - $mutasiKredit; $totalPajak += $pajak; } else { $pajak = $mutasiKredit - $mutasiDebet; $totalPajak -= $pajak; } @endphp @endforeach {{-- laba rugi setelah pajak / bersih --}} @php $labaRugiBersih = $labaRugiSebelumPajak - $totalPajak; // // cek is data available // $isAvailable = \DB::table('support_ekuitas') // ->where('bulan', $month) // ->where('tahun', $year) // ->count(); // if ($isAvailable == 0) { // // insert ke table support ekuitas // \DB::table('support_ekuitas')->insert([ // 'bulan' => $month, // 'tahun' => $year, // 'laba_rugi_bersih' => $labaRugiBersih, // ]); // } else { // \DB::table('support_ekuitas') // ->where('bulan', $month) // ->where('tahun', $year) // ->update([ // 'bulan' => $month, // 'tahun' => $year, // 'laba_rugi_bersih' => $labaRugiBersih, // ]); // } @endphp
Penjualan
{{ $item->nama }} {{ $penjualan }}
Total Penjualan {{ $totalPenjualan }}
Harga Pokok Penjualan ({{$hpp}})
Laba Rugi Kotor {{ $labaRugiKotor }}
Beban
{{ $item->nama }} {{ $item->kodeInduk->tipe == 'Debit' ? $beban : '(' . $beban . ')' }}
Total Beban ({{ $totalBeban }})
Laba Rugi Sebelum Pajak {{ $labaRugiSebelumPajak }}
Pajak
{{ $item->nama }} {{ $item->kodeInduk->tipe == 'Debit' ? $pajak : '(' . $pajak . ')' }}
Total Pajak ({{ $totalPajak }})
Laba Rugi Bersih {{ $labaRugiBersih }}
@php $name = 'Laba Rugi.xls'; header('Content-Type: application/xls'); header("Content-Disposition: attachment; filename=$name"); @endphp