{% extends "base.html" %}
{% load i18n %}
{% block content %}
<div class="container mt-4">
    <div class="card">
        <div class="card-header">
            <h4>{% trans "Quotation Details" %} - {{ quotation.id }}</h4>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <h5>{% trans "Customer Details" %}</h5>
                    <p>
                        <strong>{% trans "Name" %}:</strong> 
                        {{ quotation.customer.get_full_name }}</p>
                    <p><strong>{% trans "Address" %}:</strong> {{ quotation.customer.address }}</p>
                    <p><strong>{% trans "VAT No" %}:</strong> {{ quotation.customer.vat_number }}</p>
                </div>
                <div class="col-md-6">
                    <h5>{% trans "Quotation Information" %}</h5>
                    <p><strong>{% trans "Quotation No" %}:</strong> {{ quotation.id }}</p>
                    <p><strong>{% trans "Date" %}:</strong> {{ quotation.created_at|date }}</p>
                    <p><strong>{% trans "Remarks" %}:</strong> {{ quotation.remarks }}</p>
                </div>
            </div>

            <h5 class="mt-4">{% trans "Car Details" %}</h5>
            <table class="table table-bordered">
    <thead>
        <tr>
            <th>VIN</th>
            <th>Model</th>
            <th>Selling Price</th>
            <th>VAT</th>
            <th>Total</th>
        </tr>
    </thead>
    <tbody>
        {% for item in quotation.quotation_cars.all %}
        <tr>
            <td>{{ item.car.vin }}</td>
            <td>{{ item.car.id_car_model.get_local_name }}</td>
            <td>{{ item.car.selling_price }}</td>
            <td>{{ item.car.vat_amount }}</td>
            <td>{{ item.car.total }}</td>
        </tr>
        {% endfor %}
    </tbody>
    <tfoot>
        <tr>
            <th colspan="2">Totals</th>
            <th>{{ item.car.finances.total_vat_amount }}</th>
            <th>{{ item.car.finances.total_before_vat }}</th>
            <th>{{ item.car.finances.total }}</th>
        </tr>
    </tfoot>
</table>

            <h5 class="mt-4">{% trans "Summary" %}</h5>
            <table class="table table-bordered">
                <tr>
                    <th>{% trans "Total Sales Before VAT" %}</th>
                    <td>{{ quotations.total_sales_before_vat }}</td>
                </tr>
                <tr>
                    <th>{% trans "VAT Amount" %}</th>
                    <td>{{ quotations.vat_amount }}</td>
                </tr>
                <tr>
                    <th>{% trans "Total Sales After VAT" %}</th>
                    <td>{{ quotations.total_sales_after_vat }}</td>
                </tr>
            </table>
        </div>
        <div class="card-footer text-end">
            <a href="{% url 'quotation_list' %}" class="btn btn-secondary">{% trans "Back to Quotations" %}</a>
        </div>
    </div>
</div>
{% endblock %}