<?php
$customerTransactions = $customer->customerTransactions;
?>
<div id="generic-customer-invoices" class="">
    <div class="d-flex align-items-end pb-1">
        <h4 class="font-weight-bold m-0">
            Customer Ledger Transactions
        </h4>
        <span class="mx-2 text-secondary">|</span>
        @include('app.patient.company-client.partials.customer-create-manual-plus-form')
        <span class="mx-2 text-secondary">|</span>
        @include('app.patient.company-client.partials.customer-create-manual-minus-form')
    </div>
    @if (!count($customerTransactions))
    <div class="border p-2">This customer does not have any ledger transactions yet.</div>
    @else
    <table class="table table-sm table-bordered table-striped m-0">
        <thead>
            <tr>
                <th class="border-bottom-0">Created At</th>
                <th class="border-bottom-0">Amount</th>
                <th class="border-bottom-0">Plus/Minus</th>
                <th class="border-bottom-0">Starting Balance</th>
                <th class="border-bottom-0">Resulting Balance</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($customerTransactions as $record)
            <tr>
                <td>{{ friendly_date($record->created_at) }}</td>
                <td>${{ friendly_money($record->amount) }}</td>
                <td>{{ $record->plus_or_minus }}</td>
                <td>${{ friendly_money($record->starting_balance) }}</td>
                <td>${{ friendly_money($record->resulting_balance) }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>
    @endif
</div>