{% extends "base.html" %}
{% block title %}Sales Return {{ sales_return.reference }}{% endblock %}
{% block content %}
<div class="space-y-4">
  <div class="flex justify-between items-start">
    <div>
      <h1 class="text-2xl font-bold">{{ sales_return.reference }}</h1>
      <p class="opacity-70">Sale: {{ sales_return.sale.reference }} | Status: {{ sales_return.get_status_display }}</p>
    </div>
    {% if sales_return.status == 'draft' %}
    <a href="{% url 'sales:sales_return_process' sales_return.pk %}" class="btn btn-primary btn-sm">Process Return</a>
    {% endif %}
  </div>

  <div class="card bg-base-100 border border-base-200">
    <div class="overflow-x-auto">
      <table class="table table-zebra">
        <thead><tr><th>Product</th><th>Qty</th><th>Unit Price</th><th>Line Total</th></tr></thead>
        <tbody>
          {% for item in sales_return.items.all %}
          <tr>
            <td>{{ item.product }}</td>
            <td>{{ item.quantity }}</td>
            <td>{{ item.unit_price }}</td>
            <td>{{ item.line_total }}</td>
          </tr>
          {% empty %}
          <tr><td colspan="4" class="text-center opacity-70">No items.</td></tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}
