{{--
--}}
@csrf
{{-- Cetak Download xls --}}
@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 $totalMutasi = 0; // Ambil semua mutasi saat akun muncul di field `kode` $mutasiKode = DB::table('view_laba_rugi') ->where('kode', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Debit') // karena beban = posisi debit ->sum('nominal'); // Ambil juga jika akun muncul di field `lawan`, tapi harus tetap dianggap debit $mutasiLawan = DB::table('view_laba_rugi') ->where('lawan', $item->kode_akun) ->where('bulan', $month) ->where('tahun', $year) ->where('tipe', 'Kredit') // lawan debit berarti akun ini sebagai debit ->sum('nominal'); // Jumlahkan semua $totalMutasi = $mutasiKode + $mutasiLawan; $beban = $totalMutasi; $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
Pendapatan
{{ $item->nama }} {{ number_format($penjualan, 2, ',', '.') }}
Total Pendapatan {{ number_format($totalPenjualan, 2, ',', '.') }}
Harga Pokok Penjualan ({{number_format($hpp, 2, ',', '.')}})
Laba Rugi Kotor {{ number_format($labaRugiKotor, 2, ',', '.') }}
Beban
{{ $item->nama }} {{ $item->kodeInduk->tipe == 'Debit' ? number_format($beban, 2, ',', '.') : '(' . number_format($beban, 2, ',', '.') . ')' }}
Total Beban ({{ number_format($totalBeban, 2, ',', '.') }})
Laba Rugi Sebelum Pajak {{ number_format($labaRugiSebelumPajak, 2, ',', '.') }}
Pajak
{{ $item->nama }} {{ $item->kodeInduk->tipe == 'Debit' ? number_format($pajak, 2, ',', '.') : '(' . number_format($pajak, 2, ',', '.') . ')' }}
Total Pajak ({{ number_format($totalPajak, 2, ',', '.') }})
Laba Rugi Bersih {{ number_format($labaRugiBersih, 2, ',', '.') }}