@extends('layouts.admin')

@section('content')
<div class="content-header">
    <div class="container-fluid">
        <h1 class="m-0"><i class="fas fa-balance-scale-left mr-2"></i>Neraca Keuangan</h1>
    </div>
</div>

<section class="content">
    <div class="container-fluid">
        <div class="row">
            <!-- AKTIVA (ASET) -->
            <div class="col-md-6">
                <div class="card card-info card-outline">
                    <div class="card-header">
                        <h3 class="card-title">Aktiva (Aset)</h3>
                    </div>
                    <div class="card-body">
                        <table class="table table-bordered table-striped">
                            <tbody>
                                <tr>
                                    <td>Kas</td>
                                    <td class="text-right">Rp{{ number_format($data['kas'], 0, ',', '.') }}</td>
                                </tr>
                                <tr>
                                    <td>Persediaan Barang Dagang</td>
                                    <td class="text-right">Rp{{ number_format($data['persediaan'], 0, ',', '.') }}</td>
                                </tr>
                                <tr class="bg-info text-white">
                                    <td><strong>Total Aktiva</strong></td>
                                    <td class="text-right"><strong>Rp{{ number_format($data['total_aset'], 0, ',', '.') }}</strong></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- PASIVA (KEWAJIBAN & EKUITAS) -->
            <div class="col-md-6">
                <div class="card card-danger card-outline">
                    <div class="card-header">
                        <h3 class="card-title">Pasiva (Kewajiban & Ekuitas)</h3>
                    </div>
                    <div class="card-body">
                        <table class="table table-bordered table-striped">
                            <tbody>
                                <tr>
                                    <td>Hutang Usaha</td>
                                    <td class="text-right">Rp{{ number_format($data['hutang'], 0, ',', '.') }}</td>
                                </tr>
                                <tr>
                                    <td>Modal Akhir</td>
                                    <td class="text-right">Rp{{ number_format($data['modal_akhir'], 0, ',', '.') }}</td>
                                </tr>
                                <tr class="bg-danger text-white">
                                    <td><strong>Total Pasiva</strong></td>
                                    <td class="text-right"><strong>Rp{{ number_format($data['total_pasiva'], 0, ',', '.') }}</strong></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-12">
                @if($data['total_aset'] == $data['total_pasiva'])
                    <div class="alert alert-success text-center">
                        <h5><i class="icon fas fa-check"></i> Neraca Balance!</h5>
                        Aktiva (Rp{{ number_format($data['total_aset'], 0, ',', '.') }}) = Pasiva (Rp{{ number_format($data['total_pasiva'], 0, ',', '.') }})
                    </div>
                @else
                    <div class="alert alert-danger text-center">
                        <h5><i class="icon fas fa-ban"></i> Neraca Tidak Balance!</h5>
                        Selisih: Rp{{ number_format(abs($data['total_aset'] - $data['total_pasiva']), 0, ',', '.') }}
                    </div>
                @endif
            </div>
        </div>
    </div>
</section>
@endsection
