{% extends 'base.html' %}
{% block title %}Owner Draws{% endblock %}

{% block content %}
<div class="flex justify-between items-center mb-6">
  <h1 class="text-2xl font-bold">Owner Draws</h1>
  <a href="{% url 'finance:draw_create' %}" class="btn btn-primary btn-sm">➕ Add Draw</a>
</div>

<div class="card bg-base-100 shadow">
  <div class="card-body p-0">
    <table class="table table-zebra">
      <thead>
        <tr>
          <th>Description</th>
          <th>Account</th>
          <th>Amount</th>
          <th>Date</th>
          <th>By</th>
        </tr>
      </thead>
      <tbody>
        {% for draw in draws %}
        <tr>
          <td>{{ draw.description|default:"—" }}</td>
          <td>{{ draw.account.name }}</td>
          <td class="text-error font-medium">{{ business.currency }} {{ draw.amount|floatformat:0 }}</td>
          <td>{{ draw.date|date:"d M Y" }}</td>
          <td>{{ draw.created_by.username|default:"—" }}</td>
        </tr>
        {% empty %}
        <tr>
          <td colspan="5" class="text-center text-base-content/40 py-10">
            No draws recorded yet.
            <a href="{% url 'finance:draw_create' %}" class="link link-primary">Add first draw</a>
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}