@php
	function isNegative($number) {
		if ($number < 0) {
			return "(".currency(abs($number)).")";
		} else {
			return currency($number);
		}
	}

	function currency($number) {
		return number_format($number, 2, ',', '.');
	}
@endphp
<table>
	<thead>
		<tr>
			<td colspan="3" style="text-align: center; font-weight: bold;">CV. KETJUBUNG</td>
		</tr>
		<tr>
			<td colspan="3" style="text-align: center; font-weight: normal; font-style: italic;">Neraca</td>
		</tr>
		<tr>
			<td colspan="3" style="text-align: center; font-weight: normal; font-style: italic;">Periode : {{ $periode }}</td>
		</tr>
	</thead>
</table>

<table border="1">
	<tbody>
		<tr>
			<th style="text-align: center;">Kode Akun</th>
            <th style="text-align: center;">Nama Akun</th>
            <th style="text-align: center;">Saldo</th>
		</tr>
		@if(sizeOf($neraca) > 0)
			@php($total=0)
			@foreach($neraca AS $key => $value)
				@php
					$saldo = $value->saldo;
					$total += $saldo;
				@endphp
				<tr>
					<td style="text-align: left;">{{ $value->kode_perkiraan }}</td>
					<td>{{ $value->nama_perkiraan }}</td>
					<td style="text-align: right;">{{ isNegative($saldo) }}</td>
				</tr>
			@endforeach
			<tr>
				<td colspan="2" style="text-align: center; font-weight: bold;">Total</td>
				<td style="text-align: right;">{{ isNegative($total) }}</td>
			</tr>
		@endif
	</tbody>
</table>