Browse Source

Add paid via column to invoices list

main
def 6 days ago
parent
commit
735b53588d
  1. 26
      backend/app.py
  2. 2
      templates/invoices/list.html

26
backend/app.py

@ -3076,6 +3076,32 @@ def invoices():
"client_id": client_id,
"limit": limit_count,
}
for inv in invoices:
inv["paid_via"] = "-"
if str(inv.get("status") or "").lower() not in {"paid", "partial"}:
continue
pay_conn = get_db_connection()
pay_cursor = pay_conn.cursor(dictionary=True)
pay_cursor.execute("""
SELECT payment_method, payment_currency
FROM payments
WHERE invoice_id = %s
AND payment_status = 'confirmed'
ORDER BY COALESCE(received_at, created_at) DESC, id DESC
LIMIT 1
""", (inv["id"],))
last_payment = pay_cursor.fetchone()
pay_conn.close()
if last_payment:
inv["paid_via"] = payment_method_label(
last_payment.get("payment_method"),
last_payment.get("payment_currency"),
)
return render_template("invoices/list.html", invoices=invoices, filters=filters, clients=clients)

2
templates/invoices/list.html

@ -130,6 +130,7 @@ select {
<th>Paid</th>
<th>Remaining</th>
<th>Status</th>
<th>Paid Via</th>
<th>Issued</th>
<th>Due</th>
<th>Actions</th>
@ -147,6 +148,7 @@ select {
<td>
<span class="status-badge status-{{ i.status }}">{{ i.status }}</span>
</td>
<td>{{ i.paid_via or "-" }}</td>
<td>{{ i.issued_at|localtime }}</td>
<td>{{ i.due_at|localtime }}</td>
<td>

Loading…
Cancel
Save