{% extends "base.html" %}

{% block title %}Project Ledger - {{ project.project_title }}{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="card shadow">
        <div class="card-header bg-dark text-white">
            <h4 class="mb-0">Project Ledger for: {{ project.project_title }}</h4>
        </div>
        <div class="card-body">
            {% if ledger_data %}
            <table class="table table-bordered table-striped">
                <thead class="table-light">
                    <tr>
                        <th>Date</th>
                        <th>Entry No</th>
                        <th>Account</th>
                        <th>Description</th>
                        <th class="text-end">Debit</th>
                        <th class="text-end">Credit</th>
                        <th class="text-end">Balance</th>
                    </tr>
                </thead>
                <tbody>
                    {% for row in ledger_data %}
                    <tr>
                        <td>{{ row.date|date:"Y-m-d" }}</td>
                        <td>{{ row.entry_number }}</td>
                        <td>{{ row.account }}</td>
                        <td>{{ row.description }}</td>
                        <td class="text-end">{{ row.debit|floatformat:2 }}</td>
                        <td class="text-end">{{ row.credit|floatformat:2 }}</td>
                        <td class="text-end">{{ row.balance|floatformat:2 }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% else %}
            <p>No transactions found for this project.</p>
            {% endif %}

            <div class="text-end">
                <a href="{% url 'project_dashboard' project.id %}" class="btn btn-secondary mt-3">
                    <i class="bi bi-arrow-left"></i> Back to Dashboard
                </a>
            </div>
        </div>
    </div>
</div>
{% endblock %}
