|
|
|
|
@ -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) |
|
|
|
|
|
|
|
|
|
|