{% extends 'budget/base.html' %}
{% load budget %}

{% block title %}Year Summary For {{ year }}{% endblock %}

{% block budget_content %}
    <h2>Year Summary For {{ year }}</h2>
    
    <h3>{{ budget.name }}</h3>
    
    <table class="report_table">
        <thead>
            <tr>
                <th>Category</th>
                <th class="numeric">Estimated Total</th>
                <th class="numeric">Actual Total</th>
            </tr>
        </thead>
        <tbody>
            {% if categories_estimates_and_transactions %}
                {% for cet_group in categories_estimates_and_transactions %}
                    <tr class="{% cycle 'odd' 'even' %}">
                        <td style="padding-left: {{ cet_group.category.level }}0px">
                            {{ cet_group.category.name }}
                            
                            {% if cet_group.transactions %}
                                <a href="#" id="id_hide_show_{{ cet_group.estimate.category.slug }}" class="hide_show_button">[+]</a>
                            
                                <table id="id_hidden_transaction_list_{{ cet_group.estimate.category.slug }}" class="transaction_table">
                                    <tbody>
                                    {% for trans in cet_group.transactions %}
                                        <tr>
                                            <td class="wide">{{ trans.notes }}</td>
                                            <td>{{ trans.date|date:"m/d/Y" }}</td>
                                            <td class="numeric">
                                                ${{ trans.amount|stringformat:".02f" }}
                                            </td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            {% endif %}
                        </td>
                        <td class="numeric"> {{ cet_group.estimate.yearly_estimated_amount|stringformat:".02f" }}</td>
                        <td class="numeric">
                            <span class="{% colorize_amount cet_group.estimate.yearly_estimated_amount cet_group.actual_amount %}">${{ cet_group.actual_amount|stringformat:".02f" }}</span>
                        </td>
                    </tr>
                {% endfor %}
            {% else %}
                <tr>
                    <td colspan="3">No data to show.</td>
                </tr>
            {% endif %}
        </tbody>
        <tfoot>
            <tr class="divider">
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr class="total">
                <td>
                    <strong>Total:</strong>
                </td>
                <td class="numeric">${{ budget.yearly_estimated_total|stringformat:".02f" }}</td>
                <td class="numeric">
                    <span class="{% colorize_amount budget.yearly_estimated_total actual_total %}">${{ actual_total|stringformat:".02f" }}</span>
                </td>
            </tr>
        </tfoot>
    </table>
{% endblock budget_content %}
