<div class="col-sm-12">
    <div class="row">
        <div class="col-sm-6">
            <div class="card p-2">
                <div class="table-responsive">

                    <table class="table" style="width:100%">
                        <thead style="width:100%">

                            <tr class="bg-dark">
                                <th >Income Details</th>
                                <th style="text-align: right">Amount</th>

                            </tr>

                        </thead>

                        <tbody>
                            <tr>
                                <td>Openig balance</td>
                                <td style="text-align: right">{{number_format($previous_income, 2, '.', '')}}</td>
                            </tr>
                            @php
                                $income_sum =0;
                            @endphp
                            @foreach ($incomes as $key=>$item)
                                @php
                                    $income_sum += $item->sum('amount');
                                @endphp
                                @if ($item->sum('amount') > 0)

                                    <tr>
                                        <td>{{$income_head_with_sash[$key]}}</td>
                                        <td style="text-align: right">{{number_format($item->sum('amount'), 2, '.', '')}}</td>
                                    </tr>
                                @endif
                            @endforeach
                            <tr>

                                <td class="text-left"><strong>Total Income</strong></td>
                                <td class="text-right"> <strong>{{number_format($income_sum + $previous_income, 2, '.', '')}} TK</strong></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>




        <div class="col-sm-6">
            <div class="card p-2">
                <div class="table-responsive">

                    <table class="table" style="width:100%">
                        <thead style="width:100%">

                            <tr class="bg-dark">
                                <th >Expense Details</th>

                                <th class="text-right">Amount</th>


                            </tr>
                        </thead>

                        <tbody>
                            <tbody>
                                <tr>
                                    <td>Openig balance</td>
                                    <td style="text-align: right">{{number_format($previous_expense, 2, '.', '')}}</td>
                                </tr>
                                @php
                                    $expense_sum =0;
                                @endphp
                                @foreach ($expenses as $key=>$item)
                                    @php
                                        $expense_sum += $item->sum('amount');
                                    @endphp
                                    @if ($item->sum('amount') > 0)

                                        <tr>
                                            <td>{{$expense_head_with_sash[$key]}}</td>
                                            <td style="text-align: right">{{number_format($item->sum('amount'), 2, '.', '')}}</td>
                                        </tr>
                                    @endif
                                @endforeach
                                <tr>

                                    <td class="text-left"><strong>Total Expense</strong></td>
                                    <td class="text-right"> <strong>{{number_format($expense_sum + $previous_expense, 2, '.', '')}} TK</strong></td>
                                </tr>
                            </tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>

    <div class="col-sm-12">
        <div class="card p-2">
            <div class="table-responsive">

                <table class="table" style="width:100%">
                    <thead style="width:100%">
                        <tr style="text-align: right" >
                            <td class="bg-info"></td>
                            <td class="bg-info">Total Income: {{number_format($income_sum + $previous_income, 2, '.', '')}} TK</td>
                            <td class="bg-info">Total Expense: {{number_format($expense_sum + $previous_expense, 2, '.', '')}} TK</td>
                            <td class="bg-info">Current Amount: {{ number_format(($previous_income - $previous_expense + $income_sum - $expense_sum), 2, '.', '')}} Tk</td>
                        </tr>
                        <tr style="text-align: right" >
                            <td class="bg-secondary"></td>
                            <td class="bg-secondary">Total Income: ({{$start->format('m/d/y')}} - {{$end->format('m/d/y')}}) {{number_format($income_sum , 2, '.', '')}} TK</td>
                            <td class="bg-secondary">Total Expense: ({{$start->format('m/d/y')}} - {{$end->format('m/d/y')}}) {{number_format($expense_sum , 2, '.', '')}} TK</td>
                            <td class="bg-secondary">Current Amount: ({{$start->format('m/d/y')}} - {{$end->format('m/d/y')}}) {{ number_format(($income_sum - $expense_sum), 2, '.', '')}} Tk</td>
                        </tr>

                    </thead>

                </table>
            </div>
        </div>
    </div>

</div>
