Created a base template and added to the others

This commit is contained in:
JKuijperM 2026-02-04 15:01:40 +01:00
parent 9511ea93ba
commit 595ba93e39
16 changed files with 710 additions and 691 deletions

View File

@ -1,3 +1,43 @@
body {
margin: 0;
font-family: system-ui, sans-serif;
background: #f6f7f9;
}
.topbar {
background: #1f2937;
padding: 12px 20px;
}
.nav {
display: flex;
align-items: center;
gap: 16px;
}
.nav a {
color: #e5e7eb;
text-decoration: none;
font-weight: 500;
}
.nav a:hover {
text-decoration: underline;
}
.spacer {
flex: 1;
}
.user {
color: #9ca3af;
margin-right: 8px;
}
.content {
padding: 24px;
}
.dashboard-grid { .dashboard-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 500px)); grid-template-columns: repeat(auto-fit, minmax(300px, 500px));

View File

@ -1,24 +1,18 @@
{% load static %} {% extends "expenses/base.html" %}
<!DOCTYPE> {% block title %}Eliminar{% endblock %}
<html> {% block content %}
<head>
<title>Eliminar</title>
<link rel="stylesheet" href="{% static 'expenses/css/base.css' %}">
</head>
<body>
<h1>Eliminar cuenta</h1> <h1>Eliminar cuenta</h1>
<p> <p>
¿Seguro que quieres eliminar la cuenta ¿Seguro que quieres eliminar la cuenta
<strong>{{ account.name }}</strong> <strong>{{ account.name }}</strong>
</p> </p>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<button type="submit">Sí, eliminar</button> <button type="submit">Sí, eliminar</button>
<a href="{% url 'account_list' %}">Cancelar</a> <a href="{% url 'account_list' %}">Cancelar</a>
</form> </form>
</body> {% endblock %}
</html>

View File

@ -1,27 +1,21 @@
{% load static %} {% extends "expenses/base.html" %}
<!DOCTYPE> {% block title %}Cuenta{% endblock %}
<html> {% block content %}
<head>
<title>Cuenta</title>
<link rel="stylesheet" href="{% static 'expenses/css/base.css' %}">
</head>
<body>
<h1> <h1>
{% if form.instance.pk %} {% if form.instance.pk %}
Editar cuenta Editar cuenta
{% else %} {% else %}
Nueva cuenta Nueva cuenta
{% endif %} {% endif %}
</h1> </h1>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<button type="submit">Guardar</button> <button type="submit">Guardar</button>
<a href="{% url 'account_list' %}">Cancelar</a> <a href="{% url 'account_list' %}">Cancelar</a>
</form> </form>
</body> {% endblock %}
</html>

View File

@ -1,44 +1,38 @@
{% load static %} {% extends "expenses/base.html" %}
<!DOCTYPE> {% block title %}Cuentas{% endblock %}
<html> {% block content %}
<head>
<title>Cuentas</title>
<link rel="stylesheet" href="{% static 'expenses/css/base.css' %}">
</head>
<body>
<h1>Mis cuentas</h1> <h1>Mis cuentas</h1>
<a href="{% url 'account_create' %}"> Nueva cuenta</a> <a href="{% url 'account_create' %}"> Nueva cuenta</a>
<table> <table>
<thead> <thead>
<tr>
<th>Nombre</th>
<th>Saldo inicial</th>
<th>Saldo actual</th>
<th>Activa</th>
<th></th>
</tr>
</thead>
<tbody>
{% for account in accounts %}
<tr> <tr>
<th>Nombre</th> <td>{{ account.name }}</td>
<th>Saldo inicial</th> <td>{{ account.initial_balance }}</td>
<th>Saldo actual</th> <td>{{ account.current_balance|floatformat:2 }}</td>
<th>Activa</th> <td>{{ account.active }}</td>
<th></th> <td>
<a href="{% url 'account_edit' account.id %}">Editar</a>
<a href="{% url 'account_delete' account.id %}">Eliminar</a>
</td>
</tr> </tr>
</thead> {% empty %}
<tbody> <tr>
{% for account in accounts %} <td colspan="5">No hay cuentas</td>
<tr> </tr>
<td>{{ account.name }}</td> {% endfor %}
<td>{{ account.initial_balance }}</td> </tbody>
<td>{{ account.current_balance|floatformat:2 }}</td> </table>
<td>{{ account.active }}</td> {% endblock %}
<td>
<a href="{% url 'account_edit' account.id %}">Editar</a>
<a href="{% url 'account_delete' account.id %}">Eliminar</a>
</td>
</tr>
{% empty %}
<tr>
<td colspan="5">No hay cuentas</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,36 @@
{% load static %}
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}Expenses manager{% endblock %}</title>
<link rel="stylesheet" href="{% static 'expenses/css/base.css' %}">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<header class="topbar">
<nav class="nav">
<a href="{% url 'home' %}">Home</a>
<a href="{% url 'dashboard' %}">Dashboard</a>
<a href="{% url 'expense_list' %}">Gastos</a>
<a href="{% url 'account_list' %}">Cuentas</a>
<a href="{% url 'income_list' %}">Ingresos</a>
<a href="{% url 'tag_list' %}">Etiquetas</a>
<span class="spacer"></span>
<span class="user">
{{ request.user.username }}
</span>
<!-- <a href="{ url 'logout' }">Salir</a> -->
</nav>
</header>
<main class="content">
{% block content %}{% endblock %}
</main>
</body>
</html>

View File

@ -1,258 +1,253 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
{% block title %}Dashboard{% endblock %}
<html> {% block content %}
<head> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<title>Dashboard</title>
</head>
<body> <h1>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> Dashboard
{% if selected_account_obj %}
— {{ selected_account_obj.name }}
{% endif %}
</h1>
<h1> <!-- ========================= -->
Dashboard <!-- Filters -->
{% if selected_account_obj %} <!-- ========================= -->
— {{ selected_account_obj.name }}
{% endif %}
</h1>
<!-- ========================= --> <div>
<!-- Filters --> <a href="{% url 'dashboard' %}?period=this_month">Este mes</a> |
<!-- ========================= --> <a href="{% url 'dashboard' %}?period=last_month">Mes anterior</a> |
<a href="{% url 'dashboard' %}?period=this_year">Este año</a>
</div>
<div> <br>
<a href="{% url 'dashboard' %}?period=this_month">Este mes</a> |
<a href="{% url 'dashboard' %}?period=last_month">Mes anterior</a> |
<a href="{% url 'dashboard' %}?period=this_year">Este año</a>
</div>
<br> <form method="get" class="filters">
<label>
<form method="get" class="filters"> Año:
<label> <select name="year">
Año: {% for y in year_list %}
<select name="year"> <option value="{{ y }}"
{% for y in year_list %} {% if y == selected_year %}selected{% endif %}
<option value="{{ y }}"
{% if y == selected_year %}selected{% endif %}
>
{{y}}
</option>
{% endfor %}
</select>
</label>
<label>
Mes:
<select name="month">
<option value="">Todos</option>
{% for m in months %}
<option value="{{ m }}"
{% if m == selected_month %}selected{% endif %}
>
{{ m }}
</option>
{% endfor %}
</select>
</label>
<label>
<input type="checkbox" name="compare" value="1"
{% if compare_enabled %}checked{% endif %}>
Comparar con periodo anterior
</label>
<label for="account">Cuenta:</label>
<select name="account" id="account">
<option value="">Todas</option>
{% for acc in accounts %}
<option value="{{ acc.id }}"
{% if selected_account == acc.id %}selected{% endif %}
> >
{{ acc.name }} {{y}}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
</label>
<button type="submit">Aplicar</button> <label>
</form> Mes:
<select name="month">
<option value="">Todos</option>
{% for m in months %}
<option value="{{ m }}"
{% if m == selected_month %}selected{% endif %}
>
{{ m }}
</option>
{% endfor %}
</select>
</label>
<p> <label>
Mostrando: <input type="checkbox" name="compare" value="1"
<strong>{{ selected_year }}</strong> {% if compare_enabled %}checked{% endif %}>
{% if selected_month %}/<strong>{{ selected_month }}</strong>{% endif %} Comparar con periodo anterior
</p> </label>
<p>Comparado con el periodo inmediatamente anterior</p>
<hr> <label for="account">Cuenta:</label>
<select name="account" id="account">
<option value="">Todas</option>
{% for acc in accounts %}
<option value="{{ acc.id }}"
{% if selected_account == acc.id %}selected{% endif %}
>
{{ acc.name }}
</option>
{% endfor %}
</select>
<!-- ========================= --> <button type="submit">Aplicar</button>
<!-- KPIs --> </form>
<!-- ========================= -->
<p>
Mostrando:
<strong>{{ selected_year }}</strong>
{% if selected_month %}/<strong>{{ selected_month }}</strong>{% endif %}
</p>
<p>Comparado con el periodo inmediatamente anterior</p>
<hr>
<!-- ========================= -->
<!-- KPIs -->
<!-- ========================= -->
<div class="kpis"> <div class="kpis">
<div class="kpi">
<h3>Saldo actual</h3>
{{ kpi_balance|floatformat:2 }}€
</div>
<div class="kpi">
<h3>Total</h3>
<p>{{ kpi_total }}€</p>
</div>
<div class="kpi">
<h3>Nº de gastos</h3>
<p>{{ kpi_count }}</p>
</div>
<div class="kpi">
<h3>Categorías</h3>
<p>{{ kpi_categories }}</p>
</div>
<div class="kpi">
<h3>Saldo actual</h3>
{{ kpi_balance|floatformat:2 }}€
</div> </div>
{% if compare_enabled %} <div class="kpi">
<section class="kpi compare"> <h3>Total</h3>
<h3>Comparación con periodo anterior</h3> <p>{{ kpi_total }}€</p>
</div>
{% if kpi_previous_total == 0 %} <div class="kpi">
<p><em>No hay datos en el periodo anterior</em></p> <h3>Nº de gastos</h3>
{% else %} <p>{{ kpi_count }}</p>
<p> </div>
Total anterior: <strong>{{ kpi_previous_total|floatformat:2 }}</strong>
</p>
{% endif %}
<div> <div class="kpi">
Diferencia: <h3>Categorías</h3>
{% if kpi_trend == "up" %} <p>{{ kpi_categories }}</p>
<span style="color:red;">▲ {{ kpi_difference|floatformat:2 }}€</span> </div>
{% elif kpi_trend == "down" %}
<span style="color:green;">▼ {{ kpi_difference_abs|floatformat:2 }}€</span> </div>
{% else %}
<span>0€</span> {% if compare_enabled %}
{% endif %} <section class="kpi compare">
</div> <h3>Comparación con periodo anterior</h3>
{% if kpi_previous_total == 0 %}
<p><em>No hay datos en el periodo anterior</em></p>
{% else %}
<p> <p>
Variación: Total anterior: <strong>{{ kpi_previous_total|floatformat:2 }}</strong>
{% if kpi_percentage is not None %}
{{ kpi_percentage|floatformat:2 }}%
{% else %}
Variación: N/D
{% endif %}
</p> </p>
</section> {% endif %}
{% endif %}
<!-- ========================= --> <div>
<!-- Expenses by category --> Diferencia:
<!-- ========================= --> {% if kpi_trend == "up" %}
<h2>Gastos por categoría</h2> <span style="color:red;">▲ {{ kpi_difference|floatformat:2 }}€</span>
{% elif kpi_trend == "down" %}
<span style="color:green;">▼ {{ kpi_difference_abs|floatformat:2 }}€</span>
{% else %}
<span>0€</span>
{% endif %}
</div>
<p>
Variación:
{% if kpi_percentage is not None %}
{{ kpi_percentage|floatformat:2 }}%
{% else %}
Variación: N/D
{% endif %}
</p>
</section>
{% endif %}
{% if not by_category %} <!-- ========================= -->
<p>No hay gastos para este periodo.</p> <!-- Expenses by category -->
{% else %} <!-- ========================= -->
<table> <h2>Gastos por categoría</h2>
<thead>
{% if not by_category %}
<p>No hay gastos para este periodo.</p>
{% else %}
<table>
<thead>
<tr>
<th>Categoría</th>
<th>Total</th>
</tr>
</thead>
<tbody>
{% for row in by_category %}
<tr> <tr>
<th>Categoría</th> <td>{{ row.category__name }}</td>
<th>Total</th> <td>{{ row.total }}</td>
</tr> </tr>
</thead> {% empty %}
<tbody>
{% for row in by_category %}
<tr>
<td>{{ row.category__name }}</td>
<td>{{ row.total }}</td>
</tr>
{% empty %}
<tr>
<td colspan="2">Sin datos</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if compare_enabled %}
<h3>Comparativa por categoría</h3>
<table>
<thead>
<tr> <tr>
<th>Categoría</th> <td colspan="2">Sin datos</td>
<th>Actual</th>
<th>Anterior</th>
<th>Diferencia</th>
</tr> </tr>
</thead> {% endfor %}
<tbody> </tbody>
{% for row in category_comparison %} </table>
<tr> {% endif %}
<td>{{ row.category }}</td>
<td>{{ row.current|floatformat:2 }}€</td>
<td>{{ row.previous }}</td>
<td>
{% if row.difference > 0 %}
<span style="color:red;">▲ {{ row.difference|floatformat:2 }}€</span>
{% elif row.difference < 0 %}
<span style="color:green;">▼ {{ row.difference_abs|floatformat:2 }}€</span>
{% else %}
=
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
<hr> {% if compare_enabled %}
<h3>Comparativa por categoría</h3>
<!-- ========================= --> <table>
<!-- Expenses by month --> <thead>
<!-- ========================= --> <tr>
<th>Categoría</th>
<th>Actual</th>
<th>Anterior</th>
<th>Diferencia</th>
</tr>
</thead>
<tbody>
{% for row in category_comparison %}
<tr>
<td>{{ row.category }}</td>
<td>{{ row.current|floatformat:2 }}€</td>
<td>{{ row.previous }}</td>
<td>
{% if row.difference > 0 %}
<span style="color:red;">▲ {{ row.difference|floatformat:2 }}€</span>
{% elif row.difference < 0 %}
<span style="color:green;">▼ {{ row.difference_abs|floatformat:2 }}€</span>
{% else %}
=
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
<h2>Gastos por mes</h2> <hr>
<ul> <!-- ========================= -->
{% for row in by_month %} <!-- Expenses by month -->
<li>Mes {{ row.month }} → {{ row.total }}</li> <!-- ========================= -->
{% endfor %}
</ul>
<!-- ========================= --> <h2>Gastos por mes</h2>
<!-- Chart -->
<!-- ========================= -->
<h3>Distribución mensual (año completo)</h3> <ul>
{% for row in by_month %}
<li>Mes {{ row.month }} → {{ row.total }}</li>
{% endfor %}
</ul>
<canvas id="expensesChart"></canvas> <!-- ========================= -->
<!-- Chart -->
<!-- ========================= -->
<script> <h3>Distribución mensual (año completo)</h3>
const labels = {{ chart_labels|safe }};
const data = {{ chart_data|safe }};
const ctx = document.getElementById('expensesChart'); <canvas id="expensesChart"></canvas>
new Chart(ctx, { <script>
type: 'bar', const labels = {{ chart_labels|safe }};
data: { const data = {{ chart_data|safe }};
labels: labels,
datasets:[{
label: 'Gastos',
data: data,
}]
}
});
</script>
<hr> const ctx = document.getElementById('expensesChart');
new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets:[{
label: 'Gastos',
data: data,
}]
}
});
</script>
<hr>
</body> {% endblock %}
</html>

View File

@ -1,27 +1,24 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
<html>
<head>
<title>Borrar gasto</title>
</head>
<body> {% block title %}Borrar gasto{% endblock %}
<h1>Borrar gasto</h1>
<p> {% block content %}
¿Seguro que quieres borrar este gasto? <h1>Borrar gasto</h1>
</p>
<ul> <p>
<li>Fecha: {{ expense.date }}</li> ¿Seguro que quieres borrar este gasto?
<li>Importe: {{ expense.amount }}</li> </p>
<li>Categoría: {{ expense.category.name }}</li>
</ul>
<form method="post"> <ul>
{% csrf_token %} <li>Fecha: {{ expense.date }}</li>
<button type="submit">Sí, borrar</button> <li>Importe: {{ expense.amount }}</li>
</form> <li>Categoría: {{ expense.category.name }}</li>
</ul>
<a href="{% url 'expense_list' %}">Cancelar</a> <form method="post">
</body> {% csrf_token %}
</html> <button type="submit">Sí, borrar</button>
</form>
<a href="{% url 'expense_list' %}">Cancelar</a>
{% endblock %}

View File

@ -1,36 +1,33 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
<html>
<head> {% block title %}
<title> {% if form.instance.pk %}
Editar gasto
{% else %}
Nuevo gasto
{% endif %}
{% endblock %}
{% block content %}
<h1>
{% if form.instance.pk %}
Editar gasto
{% else %}
Nuevo gasto
{% endif %}
</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">
{% if form.instance.pk %} {% if form.instance.pk %}
Editar gasto Guardar gasto
{% else %} {% else %}
Nuevo gasto Crear gasto
{% endif %} {% endif %}
</title> </button>
</head> </form>
<body> <a href="{% url 'expense_list' %}">Volver</a>
<h1> {% endblock %}
{% if form.instance.pk %}
Editar gasto
{% else %}
Nuevo gasto
{% endif %}
</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">
{% if form.instance.pk %}
Guardar gasto
{% else %}
Crear gasto
{% endif %}
</button>
</form>
<a href="{% url 'expense_list' %}">Volver</a>
</body>
</html>

View File

@ -1,142 +1,141 @@
{% load static %} {% extends "expenses/base.html" %}
<!DOCTYPE html>
<html>
<head>
<title>Gastos</title>
<link rel="stylesheet" href="{% static 'expenses/css/base.css' %}">
</head>
<body>
<h1>Mis gastos</h1>
<form method="get">
<select name="year">
<option value="">Año</option>
{% for y in year_list %}
<option value="{{ y }}"
{% if selected_year == y %}selected{% endif %}
>
{{ y }}
</option>
{% endfor %}
</select>
<select name="month"> {% block title %}
<option value="">Mes</option> Gastos
{% for m in months %} {% endblock %}
<option value="{{ m }}"
{% if selected_month == m %}selected{% endif %}
>
{{ m }}
</option>
{% endfor %}
</select>
<label> {% block content %}
Categoría: <h1>Mis gastos</h1>
<select name="category">
<option value="">Todas</option>
{% for cat in categories %}
<option value="{{ cat.id }}"
{% if selected_category == cat.id %}selected{% endif%}
>
{{ cat.name }}
</option>
{% endfor %}
</select>
</label>
<select name="account"> <form method="get">
<option value="">Cuenta</option> <select name="year">
{% for acc in accounts %} <option value="">Año</option>
<option value="{{ acc.id }}" {% for y in year_list %}
{% if selected_account == acc.id %}selected{% endif %} <option value="{{ y }}"
> {% if selected_year == y %}selected{% endif %}
{{ acc.name }} >
{{ y }}
</option> </option>
{% endfor %}
</select>
<select name="month">
<option value="">Mes</option>
{% for m in months %}
<option value="{{ m }}"
{% if selected_month == m %}selected{% endif %}
>
{{ m }}
</option>
{% endfor %}
</select>
<label>
Categoría:
<select name="category">
<option value="">Todas</option>
{% for cat in categories %}
<option value="{{ cat.id }}"
{% if selected_category == cat.id %}selected{% endif%}
>
{{ cat.name }}
</option>
{% endfor %} {% endfor %}
</select> </select>
</label>
<label for="tag">Filtrar por tags:</label> <select name="account">
<div class="active-tags"> <option value="">Cuenta</option>
{% for tag in tags_with_state %} {% for acc in accounts %}
<a href="?{{ tag.query }}" <option value="{{ acc.id }}"
class="tag {% if tag.active %}active{% endif %}"> {% if selected_account == acc.id %}selected{% endif %}
{{ tag.name }} {% if tag.active %} ✕{% endif %} >
</a> {{ acc.name }}
{% endfor %} </option>
</div>> {% endfor %}
</select>
<button type="submit">Filtrar</button> <label for="tag">Filtrar por tags:</label>
<a href="{% url 'expense_list' %}">Limpiar</a> <div class="active-tags">
</form> {% for tag in tags_with_state %}
<a href="?{{ tag.query }}"
class="tag {% if tag.active %}active{% endif %}">
{{ tag.name }} {% if tag.active %} ✕{% endif %}
</a>
{% endfor %}
</div>>
<br> <button type="submit">Filtrar</button>
<a href="{% url 'expense_list' %}">Limpiar</a>
</form>
<a href="{% url 'expense_create' %}">Añadir gasto</a> <br>
<br> <a href="{% url 'expense_create' %}">Añadir gasto</a>
<section> <br>
<strong>Total:</strong> {{ kpi_total|floatformat:2 }}€ |
<strong>Gastos:</strong> {{ kpi_count }} |
<strong>Categorías:</strong> {{ kpi_categories }}
</section>
<table> <section>
<thead> <strong>Total:</strong> {{ kpi_total|floatformat:2 }}€ |
<strong>Gastos:</strong> {{ kpi_count }} |
<strong>Categorías:</strong> {{ kpi_categories }}
</section>
<table>
<thead>
<tr>
<th>Fecha</th>
<th>Categoría</th>
<th>Importe</th>
<th>Cuenta</th>
<th>Etiquetas</th>
<th></th>
</tr>
</thead>
<tbody>
{% for expense in page_obj %}
<tr> <tr>
<th>Fecha</th> <td>{{ expense.date }}</td>
<th>Categoría</th> <td>{{ expense.category.name }}</td>
<th>Importe</th> <td>{{ expense.amount }}</td>
<th>Cuenta</th> <td>{{ expense.account.name }}</td>
<th>Etiquetas</th> <td>
<th></th> {% for tag in expense.tags.all %}
<span class="tag">
{{ tag.name }}
</span>
{% empty %}
<span>-</span>
{% endfor %}
</td>
<td>
<a href="{% url 'expense_edit' expense.id %}">Editar</a>
<a href="{% url 'expense_delete' expense.id %}">Eliminar</a>
</td>
</tr> </tr>
</thead> {% empty %}
<tbody> <tr>
{% for expense in page_obj %} <td colspan="4">No hay gastos</td>
<tr> </tr>
<td>{{ expense.date }}</td> {% endfor %}
<td>{{ expense.category.name }}</td> </tbody>
<td>{{ expense.amount }}</td> </table>
<td>{{ expense.account.name }}</td>
<td>
{% for tag in expense.tags.all %}
<span class="tag">
{{ tag.name }}
</span>
{% empty %}
<span>-</span>
{% endfor %}
</td>
<td>
<a href="{% url 'expense_edit' expense.id %}">Editar</a>
<a href="{% url 'expense_delete' expense.id %}">Eliminar</a>
</td>
</tr>
{% empty %}
<tr>
<td colspan="4">No hay gastos</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="pagination"> <div class="pagination">
<span class="step-links"> <span class="step-links">
{% if page_obj.has_previous %} {% if page_obj.has_previous %}
<a href="?page=1{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">&laquo; Primero</a> <a href="?page=1{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">&laquo; Primero</a>
<a href="?page={{ page_obj.previous_page_number }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Anterior</a> <a href="?page={{ page_obj.previous_page_number }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Anterior</a>
{% endif %} {% endif %}
<span>Página {{ page_obj.number }} de {{ page_obj.paginator.num_pages }}</span> <span>Página {{ page_obj.number }} de {{ page_obj.paginator.num_pages }}</span>
{% if page_obj.has_next %} {% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Siguiente</a> <a href="?page={{ page_obj.next_page_number }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Siguiente</a>
<a href="?page={{ page_obj.paginator.num_pages }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Último &raquo;</a> <a href="?page={{ page_obj.paginator.num_pages }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Último &raquo;</a>
{% endif %} {% endif %}
</span> </span>
</div> </div>
</body> {% endblock %}
</html>

View File

@ -1,69 +1,63 @@
{% load static %} {% extends "expenses/base.html" %}
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="{% static 'expenses/css/base.css' %}">
</head>
<body> {% block title %}Home{% endblock %}
<h1>Home</h1> {% block content %}
<section> <h1>Home</h1>
<h2>Resumen del mes</h2>
<p>Total: {{ kpi_total }}</p>
<p>Gastos: {{ kpi_count }}</p>
<p>Categorías: {{ kpi_categories }}</p>
</section>
<section> <section>
<h2>Últimos gastos</h2> <h2>Resumen del mes</h2>
<ul> <p>Total: {{ kpi_total }}</p>
{% for expense in last_expenses %} <p>Gastos: {{ kpi_count }}</p>
<li> <p>Categorías: {{ kpi_categories }}</p>
{{ expense.date }} - </section>
{{ expense.category.name }} -
{{ expense.amount }}
</li>
{% empty %}
<li>No hay gastos</li>
{% endfor %}
</ul>
</section>
<section> <section>
<div class="dashboard-grid"> <h2>Últimos gastos</h2>
<div class="card card-chart"> <ul>
<h2>Últimos meses</h2> {% for expense in last_expenses %}
<canvas id="miniChart"></canvas> <li>
</div> {{ expense.date }} -
{{ expense.category.name }} -
{{ expense.amount }}
</li>
{% empty %}
<li>No hay gastos</li>
{% endfor %}
</ul>
</section>
<section>
<div class="dashboard-grid">
<div class="card card-chart">
<h2>Últimos meses</h2>
<canvas id="miniChart"></canvas>
</div> </div>
</div>
<script> <script>
const labels = {{ mini_chart_labels|safe }}; const labels = {{ mini_chart_labels|safe }};
const data = {{ mini_chart_data|safe }}; const data = {{ mini_chart_data|safe }};
const ctx = document.getElementById('miniChart'); const ctx = document.getElementById('miniChart');
new Chart(ctx, { new Chart(ctx, {
type: 'bar', type: 'bar',
data: { data: {
labels: labels, labels: labels,
datasets:[{ datasets:[{
label: 'Gastos', label: 'Gastos',
data: data, data: data,
}] }]
}, },
options: { options: {
responsive: true, responsive: true,
maintainAspectRatio: false maintainAspectRatio: false
} }
}); });
</script> </script>
</section> </section>
</body> {% endblock %}
</html>

View File

@ -1,27 +1,23 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
<html> {% block title %}Borrar ingreso{% endblock %}
<head>
<title>Borrar ingreso</title>
</head>
<body> {% block content %}
<h1>Borrar ingreso</h1> <h1>Borrar ingreso</h1>
<p> <p>
¿Seguro que quieres borrar este ingreso? ¿Seguro que quieres borrar este ingreso?
</p> </p>
<ul> <ul>
<li>Fecha: {{ income.date }}</li> <li>Fecha: {{ income.date }}</li>
<li>Importe: {{ income.amount }}</li> <li>Importe: {{ income.amount }}</li>
<li>Categoría: {{ income.category.name }}</li> <li>Categoría: {{ income.category.name }}</li>
</ul> </ul>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<button type="submit">Sí, borrar</button> <button type="submit">Sí, borrar</button>
</form> </form>
<a href="{% url 'income_list' %}">Cancelar</a> <a href="{% url 'income_list' %}">Cancelar</a>
</body> {% endblock %}
</html>

View File

@ -1,36 +1,32 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
<html> {% block title %}
<head>
<title>
{% if form.instance.pk %} {% if form.instance.pk %}
Editar ingreso Editar ingreso
{% else %} {% else %}
Nuevo ingreso Nuevo ingreso
{% endif %} {% endif %}
</title> {% endblock %}
</head>
<body> {% block content %}
<h1> <h1>
{% if form.instance.pk %}
Editar ingreso
{% else %}
Nuevo ingreso
{% endif %}
</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">
{% if form.instance.pk %} {% if form.instance.pk %}
Editar ingreso Guardar ingreso
{% else %} {% else %}
Nuevo ingreso Crear ingreso
{% endif %} {% endif %}
</h1> </button>
</form>
<form method="post"> <a href="{% url 'income_list' %}">Volver</a>
{% csrf_token %} {% endblock %}
{{ form.as_p }}
<button type="submit">
{% if form.instance.pk %}
Guardar ingreso
{% else %}
Crear ingreso
{% endif %}
</button>
</form>
<a href="{% url 'income_list' %}">Volver</a>
</body>
</html>

View File

@ -1,44 +1,38 @@
{% load static %} {% extends "expenses/base.html" %}
<!DOCTYPE html> {% block title %}Ingresos{% endblock %}
<html> {% block content %}
<head> <h1>Mis ingresos</h1>
<title>Ingresos</title>
<link rel="stylesheet" href="{% static 'expenses/css/base.css' %}">
</head>
<body>
<h1>Mis ingresos</h1>
<a href="{% url 'income_create' %}"> Nuevo ingreso</a> <a href="{% url 'income_create' %}"> Nuevo ingreso</a>
<table> <table>
<thead> <thead>
<tr>
<th>Nombre</th>
<th>Cuenta</th>
<th>Cantidad</th>
<th>Fecha ingreso</th>
<th></th>
</tr>
</thead>
<tbody>
{% for income in incomes %}
<tr> <tr>
<th>Nombre</th> <td>{{ income.name }}</td>
<th>Cuenta</th> <td>{{ income.account }}</td>
<th>Cantidad</th> <td>{{ income.amount|floatformat:2 }}</td>
<th>Fecha ingreso</th> <td>{{ income.date }}</td>
<th></th> <td>
<a href="{% url 'income_edit' income.id %}">Editar</a>
<a href="{% url 'income_delete' income.id %}">Eliminar</a>
</td>
</tr> </tr>
</thead> {% empty %}
<tbody> <tr>
{% for income in incomes %} <td colspan="5">No hay ingresos</td>
<tr> </tr>
<td>{{ income.name }}</td> {% endfor %}
<td>{{ income.account }}</td> </tbody>
<td>{{ income.amount|floatformat:2 }}</td> </table>
<td>{{ income.date }}</td>
<td>
<a href="{% url 'income_edit' income.id %}">Editar</a>
<a href="{% url 'income_delete' income.id %}">Eliminar</a>
</td>
</tr>
{% empty %}
<tr>
<td colspan="5">No hay ingresos</td>
</tr>
{% endfor %}
</tbody>
</table>
</body> {% endblock %}
</html>

View File

@ -1,15 +1,12 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
<html> {% block title %}Etiquetas{% endblock %}
<head> {% block content %}
</head> <h1>Eliminar etiqueta</h1>
<body>
<h1>Eliminar etiqueta</h1>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<button type="submit">Eliminar</button> <button type="submit">Eliminar</button>
</form> </form>
<a href="{% url 'tag_list' %}">Cancelar</a> <a href="{% url 'tag_list' %}">Cancelar</a>
</body> {% endblock %}
</html>

View File

@ -1,16 +1,13 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
<html> {% block title %}Etiquetas{% endblock %}
<head> {% block content %}
</head> <h1>Etiqueta</h1>
<body>
<h1>Etiqueta</h1>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<button type="submit">Guardar</button> <button type="submit">Guardar</button>
</form> </form>
<a href="{% url 'tag_list' %}">Volver</a> <a href="{% url 'tag_list' %}">Volver</a>
</body> {% endblock %}
</html>

View File

@ -1,20 +1,19 @@
<!DOCTYPE html> {% extends "expenses/base.html" %}
<html> {% block title %}Etiquetas{% endblock %}
<head> {% block content %}
</head> <h1>Etiquetas</h1>
<body>
<h1>Etiquetas</h1>
<ul> <a href="{% url 'tag_create' %}"> Nueva etiqueta</a>
{% for tag in tags %}
<li> <ul>
{{ tag.name }} {% for tag in tags %}
<a href="{% url 'tag_edit' tag.id %}">Editar</a> <li>
<a href="{% url 'tag_delete' tag.id %}">Eliminar</a> {{ tag.name }}
</li> <a href="{% url 'tag_edit' tag.id %}">Editar</a>
{% empty %} <a href="{% url 'tag_delete' tag.id %}">Eliminar</a>
<li>No hay etiquetas</li> </li>
{% endfor %} {% empty %}
</ul> <li>No hay etiquetas</li>
</body> {% endfor %}
</html> </ul>
{% endblock %}