First commit

This commit is contained in:
2026-11-17 21:48:36 +01:00
parent a3014ae75d
commit 1366d6b69d
35 changed files with 3770 additions and 1 deletions
+52
View File
@@ -0,0 +1,52 @@
{% extends "base.html" %}
{% from "_debt_form.html" import debt_form with context %}
{% block title %}{{ d.name }}{% endblock %}
{% block content %}
<p><a class="btn ghost sm" href="/debts">{{ icon('chevron-left', 'sm') }} All debts</a></p>
<div class="page-head">
<h1>{{ d.name }} <span class="badge">{{ 'I owe' if d.direction == 'i_owe' else 'owed to me' }}</span>
{% if d.closed %}<span class="badge">closed</span>{% endif %}</h1>
<div class="actions">
{% if d.match_pattern %}<form method="post" action="/debts/{{ d.id }}/rematch"><button class="secondary sm">{{ icon('link', 'sm') }} Re-match bank</button></form>{% endif %}
<form method="post" action="/debts/{{ d.id }}/toggle"><button class="secondary sm">{{ 'Re-open' if d.closed else 'Close' }}</button></form>
<form method="post" action="/debts/{{ d.id }}/delete" data-confirm="Delete this debt and its payment history?"><button class="danger sm">{{ icon('trash-2', 'sm') }} Delete</button></form>
</div>
</div>
<div class="grid cols-4 mb">
<div class="card kpi"><div class="label">Remaining</div><div class="value">{{ s.remaining|eur }}</div><div class="sub">of {{ d.principal|eur }}</div></div>
<div class="card kpi"><div class="label">Paid</div><div class="value">{{ s.paid|eur }}</div>
<div class="progress"><div style="width:{{ [s.pct,100]|min }}%"></div></div></div>
<div class="card kpi"><div class="label">Status</div>
<div class="value {{ 'bad' if s.status == 'behind' else 'good' }}">{{ s.status }}</div>
<div class="sub">{% if s.expected is not none %}expected by now {{ s.expected|eur }} ({{ s.diff|eur(2, true) }}){% else %}set a monthly payment to track schedule{% endif %}</div></div>
<div class="card kpi"><div class="label">Next due</div><div class="value">{{ s.next_due.strftime('%d %b') if s.next_due else '—' }}</div>
<div class="sub">{{ 'paid off ≈ ' + s.payoff.strftime('%b %Y') if s.payoff }}</div></div>
</div>
<div class="grid cols-2">
<div class="card">
<h2>{{ icon('banknote') }} Payments</h2>
<form method="post" action="/debts/{{ d.id }}/payment" class="row mb">
<input type="date" name="date" value="{{ today().isoformat() }}">
<input name="amount" inputmode="decimal" placeholder="€" required style="width:110px">
<input name="notes" placeholder="note" style="width:140px">
<button class="sm">{{ icon('plus', 'sm') }} Add payment</button>
</form>
<div class="table-wrap"><table>
<thead><tr><th>Date</th><th class="num">Amount</th><th class="num">Balance after</th><th>Note</th><th></th></tr></thead>
<tbody>
{% for p, bal in running %}
<tr><td>{{ p.date.strftime('%d-%m-%Y') }}</td><td class="num">{{ p.amount|eur }}</td><td class="num">{{ bal|eur }}</td>
<td class="small">{{ p.notes }}{% if p.transaction_id %} <span class="badge accent" title="Matched from bank">{{ icon('landmark', 'sm') }} bank</span>{% endif %}</td>
<td><form method="post" action="/payments/{{ p.id }}/delete" data-confirm="Remove this payment?"><button class="sm ghost icon" title="Remove">{{ icon('trash-2', 'sm') }}</button></form></td></tr>
{% else %}<tr><td colspan="5" class="muted">No payments yet.</td></tr>{% endfor %}
</tbody>
</table></div>
</div>
<div class="card">
<h2>{{ icon('pencil') }} Details</h2>
{{ debt_form(d) }}
</div>
</div>
{% endblock %}