
	<table>
		<tbody>
		<tr>
			<td>{{$judul}}</td>
		</tr>
		<tr>
			<td>Akun</td>
			<td>: {{$akun}}</td>
		</tr>
		<tr>
			<td>Periode</td>
			<td>: {{$periode}}</td>
		</tr>
		</tbody>
	</table>
	
	<br>

	<table border="1">
		<thead>
			<tr>
				<th style="text-align: center; font-weight: bold;">Tanggal</th>
				<th style="text-align: center; font-weight: bold;">Keterangan</th>
				<th style="text-align: center; font-weight: bold;">Masuk</th>
				<th style="text-align: center; font-weight: bold;">Keluar</th>
				<th style="text-align: center; font-weight: bold;">Sisa</th>
			</tr>
		</thead>
		<tbody>
			<?php
				$sisa = 0;
				$total_masuk = 0;
				$total_keluar = 0;
			?>

			<tr>
				<td></td>
				<td>SALDO AWAL</td>
				<td></td>
				<td></td>
				<td style="text-align: right;">{{ setNominal($saldo_awal, 2) }}</td>
			</tr>

			@if(count($data) > 0)
				@foreach($data AS $key=>$value)
					@php
						$nominal = ["D"=>0, "K"=>0];

						if($value->tipe_id_akun=="D"){
						    $nominal["D"] += $value->nominal_transaksi;
						    $total_masuk += $value->nominal_transaksi;
						    $saldo_awal += $value->nominal_transaksi;
						}else{
						    $nominal["K"] += $value->nominal_transaksi;
						    $total_keluar += $value->nominal_transaksi;
						    $saldo_awal -= $value->nominal_transaksi;
						}

						$selisih = $nominal['D']-$nominal['K']; 

						$sisa += $selisih;
					@endphp
					<tr>
						<td>{{ date_db($value->tanggal_transaksi, true) }}</td>
						<td>{{ $value->keterangan }}</td>
						<td>{{ rupiah2($nominal['D'], 2) }}</td>
						<td>{{ rupiah2($nominal['K'], 2) }}</td>
						<td>{{ setNominal($saldo_awal, 2) }}</td>
					</tr>
				@endforeach
			@endif
			<tr>
				<td colspan="2" style="text-align: right; font-weight: bold;">Total</td>
				<td style="text-align: right; font-weight: bold;">{{ setNominal($total_masuk, 2) }}</td>
				<td style="text-align: right; font-weight: bold;">{{ setNominal($total_keluar, 2) }}</td>
				<td style="text-align: right; font-weight: bold;">{{ setNominal($saldo_awal, 2) }}</td>
			</tr>
		</tbody>
	</table>
