{% extends "base.html" %}
{% block title %}Profit and Loss for {{ job.job_title }}{% endblock %}

{% block content %}
<div class="container mt-4">
    <h2>Profit and Loss Report</h2>
    <h5>Job: {{ job.job_title }}</h5>
    <hr>

    <h4>Revenue</h4>
    <table class="table table-bordered">
        <thead><tr><th>Account</th><th class="text-end">Amount</th></tr></thead>
        <tbody>
            {% for name, amount in revenue_breakdown %}
            <tr><td>{{ name }}</td><td class="text-end">{{ amount }}</td></tr>
            {% empty %}
            <tr><td colspan="2">No revenue</td></tr>
            {% endfor %}
        </tbody>
    </table>

    <h4>Expenses</h4>
    <table class="table table-bordered">
        <thead><tr><th>Account</th><th class="text-end">Amount</th></tr></thead>
        <tbody>
            {% for name, amount in expense_breakdown %}
            <tr><td>{{ name }}</td><td class="text-end">{{ amount }}</td></tr>
            {% empty %}
            <tr><td colspan="2">No expenses</td></tr>
            {% endfor %}
        </tbody>
    </table>

    <hr>
    <h3 class="text-end">
        {% if profit_or_loss >= 0 %}
            Net Profit: <span class="text-success">{{ profit_or_loss }}</span>
        {% else %}
            Net Loss: <span class="text-danger">{{ profit_or_loss }}</span>
        {% endif %}
    </h3>
</div>
{% endblock %}
