Browse Source

Add color-coded client ledger links and edit-page ledger shortcut

main
def 2 weeks ago
parent
commit
275f44228c
  1. 2
      VERSION
  2. 7
      backend/app.py
  3. 6
      templates/clients/edit.html
  4. 5
      templates/clients/list.html

2
VERSION

@ -1 +1 @@
0.2.0
0.2.1

7
backend/app.py

@ -202,6 +202,10 @@ def clients():
cursor.execute("SELECT * FROM clients ORDER BY id DESC")
clients = cursor.fetchall()
conn.close()
for client in clients:
client["credit_balance"] = get_client_credit_balance(client["id"])
return render_template("clients/list.html", clients=clients)
@app.route("/clients/new", methods=["GET", "POST"])
@ -259,6 +263,7 @@ def edit_client(client_id):
if errors:
cursor.execute("SELECT * FROM clients WHERE id = %s", (client_id,))
client = cursor.fetchone()
client["credit_balance"] = get_client_credit_balance(client_id)
conn.close()
return render_template("clients/edit.html", client=client, errors=errors)
@ -292,6 +297,8 @@ def edit_client(client_id):
if not client:
return "Client not found", 404
client["credit_balance"] = get_client_credit_balance(client_id)
return render_template("clients/edit.html", client=client, errors=[])
@app.route("/credits/<int:client_id>")

6
templates/clients/edit.html

@ -10,6 +10,12 @@
<p><a href="/">Home</a></p>
<p><a href="/clients">Back to Clients</a></p>
<p>
<a href="/credits/{{ client.id }}"
style="{% if client.credit_balance > 0 %}color: green;{% elif client.credit_balance < 0 %}color: red;{% else %}color: blue;{% endif %}">
Ledger ({{ client.credit_balance|money('CAD') }})
</a>
</p>
{% if errors %}
<div style="border:1px solid red; padding:10px; margin-bottom:15px;">

5
templates/clients/list.html

@ -34,7 +34,10 @@
<td>{{ c.status }}</td>
<td>
<a href="/clients/edit/{{ c.id }}">Edit</a> |
<a href="/credits/{{ c.id }}">Ledger</a>
<a href="/credits/{{ c.id }}"
style="{% if c.credit_balance > 0 %}color: green;{% elif c.credit_balance < 0 %}color: red;{% else %}color: blue;{% endif %}">
Ledger ({{ c.credit_balance|money('CAD') }})
</a>
</td>
</tr>
{% endfor %}

Loading…
Cancel
Save