LocalGovIMS_localgov-ims/src/Admin/Views/Transaction/_RefundList.cshtml
@model Admin.Models.Transaction.DetailsViewModel

@if (!Model.IsRefund)
{

    if ((Model.Transaction.ProcessedRefunds == null || !Model.Transaction.ProcessedRefunds.Any())
         && (Model.Transaction.PendingRefunds == null || !Model.Transaction.PendingRefunds.Any()))
    {
        <div class="alert alert-info mb-3">
            <div class="fw-bold pb-1">
                No refunds found
            </div>
            <p class="mb-0">
                There are no refunds found against this transaction.
            </p>
        </div>
    }
    else
    {
        <div class="table-responsive">
            <table class="table table-striped table-bordered mt-2">
                <thead>
                    <tr>
                        <th scope="col">Time</th>
                        <th scope="col">User</th>
                        <th scope="col">Type</th>
                        <th scope="col">Account</th>
                        <th scope="col">Narrative</th>
                        <th scope="col">Amount (£)</th>
                        <th scope="col">Status</th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model.Transaction.ProcessedRefunds != null && Model.Transaction.ProcessedRefunds.Any())
                    {
                        foreach (var transaction in Model.Transaction.ProcessedRefunds)
                        {
                            <tr class="positive">
                                <td>@transaction.TransactionDate</td>
                                <td>@(transaction.User != null ? transaction.User.DisplayName : transaction.UserCode.ToString())</td>
                                <td>@(transaction.Fund != null ? string.Format("{0} ({1})", transaction.Fund.FundName, transaction.Fund.FundCode) : "")</td>
                                <td>@transaction.AccountReference</td>
                                <td>@transaction.Narrative</td>
                                <td class="text-end @if (transaction.Amount < 0) { @Html.Raw("td--negative") }">
                                    @Html.ToCurrency(transaction.Amount)
                                </td>
                                <td><i class="icon fa fa-check"></i> Complete</td>
                            </tr>
                        }
                    }

                    @if (Model.Transaction.FailedRefunds != null && Model.Transaction.FailedRefunds.Any())
                    {
                        foreach (var transaction in Model.Transaction.FailedRefunds)
                        {
                            <tr class="error">
                                <td>@transaction.EntryDate</td>
                                <td>@(transaction.User != null ? transaction.User.DisplayName : transaction.UserCode.ToString())</td>
                                <td>@(transaction.Fund != null ? transaction.Fund.FundName : "")</td>
                                <td>@transaction.AccountReference</td>
                                <td>@transaction.Narrative</td>
                                <td class="text-end @if (transaction.Amount < 0) { @Html.Raw("td--negative") }">
                                    @Html.ToCurrency(transaction.Amount)
                                </td>
                                <td><i class="icon fa fa-exclamation"></i> Failed</td>
                            </tr>
                        }
                    }

                    @if (Model.Transaction.PendingRefunds != null && Model.Transaction.PendingRefunds.Any())
                    {
                        foreach (var transaction in Model.Transaction.PendingRefunds)
                        {
                            <tr class="warning">
                                <td>@transaction.EntryDate</td>
                                <td>@(transaction.User != null ? transaction.User.DisplayName : transaction.UserCode.ToString())</td>
                                <td>@(transaction.Fund != null ? transaction.Fund.FundName : "")</td>
                                <td>@transaction.AccountReference</td>
                                <td>@transaction.Narrative</td>
                                <td class="text-end @if (transaction.Amount < 0) { @Html.Raw("td--negative") }">
                                    @Html.ToCurrency(transaction.Amount)
                                </td>
                                <td><i class="icon fa fa-hourglass-half"></i> Pending</td>
                            </tr>
                        }
                    }
                </tbody>
            </table>
        </div>
    }
}
