Compare commits

...

74 commits

Author SHA1 Message Date
ee3ec21527
Update styling on invoice table 2024-01-05 09:11:38 +01:00
ad020e476b
Add icon to log in link in navbar 2024-01-05 09:00:08 +01:00
0ff191e0a4
Fix account table display on small devices 2024-01-05 08:56:16 +01:00
a6e84fbc13
Fix back link styling on year page 2024-01-04 18:45:42 +01:00
7369b36ab1
Move connected as item in navbar 2024-01-04 18:45:17 +01:00
63258147ee
Add icons to navbar 2024-01-04 18:33:56 +01:00
67e71b717b
Fix back link 2024-01-04 17:16:13 +01:00
e41b989862
Add creation links to statement and transaction list pages 2024-01-04 17:04:37 +01:00
ca7cd790b5
Update check icons in statement table 2024-01-04 16:58:47 +01:00
9d50dc7154
Separate detail and edit view for category, update statement page 2024-01-04 16:51:48 +01:00
218a6aca6f
Separate detail and edit view for account 2024-01-04 16:05:38 +01:00
6bd83feafe
Update up-down icons 2024-01-04 15:38:53 +01:00
b0716a65b7
Add icons on calendar plot 2024-01-03 19:02:08 +01:00
8db2720f75
Remove create links from navbar; Add a link to create categories in the category list on the homepage 2024-01-03 18:49:24 +01:00
954ee9ce17
Update big links styling 2024-01-03 18:35:31 +01:00
08b234a070
Add colors back to history 2024-01-03 18:29:14 +01:00
bf1d15574d
Fix previous commit 2024-01-03 16:14:54 +01:00
ef90d52807
Fix history regarding category__budget 2024-01-03 16:07:10 +01:00
e4169bd1c3
Split columns for income and expenses 2024-01-03 15:52:36 +01:00
e2f7a1dcc3
Fix history calendar 2024-01-03 15:37:48 +01:00
cc551c536c
Change date format in transaction table on month and year page 2024-01-03 15:35:06 +01:00
b3c9642adc
Update year history (remove year in plot lines) 2024-01-03 15:20:45 +01:00
b478286f47
Fix page layout 2024-01-03 15:13:54 +01:00
6d14602dd2
Fix homepage on small screens 2024-01-03 14:59:08 +01:00
0f1aba45ea
Add class value to balance in account table 2024-01-03 14:54:24 +01:00
05b7418162
Reshape home page 2024-01-03 14:51:40 +01:00
d48818e455
Create table for accounts 2024-01-03 14:40:48 +01:00
9927cbbab4
Move new and more links to tables 2024-01-03 14:25:25 +01:00
e44e3a51f0
Fix contrast issues with table icons 2024-01-02 17:03:55 +01:00
65d97f523c
Add title attribute to calendar plot for accessibility 2024-01-02 16:58:24 +01:00
6b08113f60
Add back link on month and year page 2024-01-02 16:04:04 +01:00
e5cdf19fa3
Add transaction list on year view 2024-01-02 15:42:51 +01:00
b4c7f88b3d
Add time elements for accessibility 2024-01-02 15:28:24 +01:00
87c12f47e9
Fix pagination on small devices 2024-01-02 15:15:57 +01:00
8ebb940f5b
Add missing section block in month page 2024-01-02 15:09:50 +01:00
5ccae7f4a3
Fix spacing with pagination 2024-01-02 15:07:42 +01:00
3fd87ff370
Update month page template 2024-01-02 15:03:45 +01:00
f8c0f9dced
Change date format in month pagination 2024-01-02 15:00:27 +01:00
2ba21fbd10
Refactor pagination for month/year 2024-01-02 14:56:13 +01:00
35b26f2d10
Add year link on month view 2024-01-02 14:36:36 +01:00
57279b1cda
Simplify duplicated code (archive views) 2024-01-02 14:21:58 +01:00
47c4de8fbb
Fix calendar scroll 2024-01-02 14:18:57 +01:00
1137cfc1cc
Fix top-gap in main 2024-01-02 12:21:36 +01:00
2f32c2b80f
Fix year urls on account pages 2024-01-02 12:13:57 +01:00
60f84fe20d
Add pagination to year archive view 2024-01-02 12:06:20 +01:00
8b9af8e1a4
Add links to category in year category plot 2024-01-02 11:59:44 +01:00
309281f5e1
Fix row colors in history plot 2024-01-02 11:55:54 +01:00
75df57f42a
Update year view (add link) 2024-01-02 11:52:04 +01:00
3dbc31eebc
Fix row colors in category plot 2024-01-02 11:47:58 +01:00
caa113859d
Add year archive view 2024-01-02 11:45:06 +01:00
45b47dd1ba
Move templatetags to history templatetags 2024-01-02 11:11:05 +01:00
003902b43f
Minor style updates 2024-01-02 11:00:56 +01:00
0940904cd8
Refactor History plot 2024-01-02 10:58:30 +01:00
6b50de5e35
Fix opacity calculation on chrome 2023-12-31 18:41:54 +01:00
e4e0f56be0
Use css nesting 2023-12-31 09:37:29 +01:00
ee043d3956
Fix back link in transation form (fix #12) 2023-12-31 09:03:49 +01:00
fe95222474
Fix bugs in html templates 2023-12-30 11:12:38 +01:00
47d8ff0382
Create tag for css imports 2023-12-30 10:54:01 +01:00
7f3b9c7b5c
Structure page content with sections 2023-12-30 10:38:30 +01:00
0e5b8ea85d
Use :is css pseudo-class 2023-12-30 10:24:24 +01:00
715822e48f
Remove unused spaceless tags 2023-12-30 10:18:17 +01:00
ee4e6b7ceb
Improve history plot with empty segments 2023-12-30 10:10:53 +01:00
55923e7709
Fix form fields on alternating background 2023-12-30 09:42:58 +01:00
14755df86b
Fix pagination on month archive, keep account 2023-12-30 09:40:11 +01:00
a0bc1a6608
Update pagination on montharchive to keep category 2023-12-30 09:35:05 +01:00
68ff2ae8ad
Set table borders to 1px 2023-12-30 09:17:47 +01:00
17fe61c9c0
Improve accessibility for links 2023-12-30 09:14:07 +01:00
aeb22521f3
Add alternating row colors 2023-12-30 09:12:03 +01:00
5013df903f
Add pagination to month archive view (fix #13) 2023-12-30 09:04:52 +01:00
c3ba376793
Fix month offset (missing first month in history) 2023-12-29 09:53:59 +01:00
4bb682fc88
Fix HTML for index page 2023-12-29 09:50:08 +01:00
8652eb0b57
Remove borders in calendar table 2023-12-29 09:23:51 +01:00
6f631607b8
Reduce computations in history generation 2023-12-28 16:31:13 +01:00
9dbbd3d48e
Add monthly year chart 2023-12-28 15:46:52 +01:00
55 changed files with 1265 additions and 672 deletions

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-22 15:16+0200\n" "POT-Creation-Date: 2024-01-04 16:18+0100\n"
"PO-Revision-Date: 2023-04-22 15:17+0200\n" "PO-Revision-Date: 2023-04-22 15:17+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n" "Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n" "Language-Team: \n"
@ -37,6 +37,22 @@ msgstr "Défaut"
msgid "Accounts" msgid "Accounts"
msgstr "Comptes" msgstr "Comptes"
#: .\account\templates\account\account_detail.html:13
msgid "Edit account"
msgstr "Modifier le compte"
#: .\account\templates\account\account_detail.html:16
msgid "Statements"
msgstr "Relevés"
#: .\account\templates\account\account_detail.html:20
msgid "Transactions"
msgstr "Transactions"
#: .\account\templates\account\account_detail.html:25
msgid "History"
msgstr "Historique"
#: .\account\templates\account\account_form.html:5 #: .\account\templates\account\account_form.html:5
msgid "Create account" msgid "Create account"
msgstr "Créer un compte" msgstr "Créer un compte"
@ -44,15 +60,3 @@ msgstr "Créer un compte"
#: .\account\templates\account\account_form.html:8 #: .\account\templates\account\account_form.html:8
msgid "New account" msgid "New account"
msgstr "Nouveau compte" msgstr "Nouveau compte"
#: .\account\templates\account\account_form.html:13
msgid "Statements"
msgstr "Relevés"
#: .\account\templates\account\account_form.html:15
msgid "Transactions"
msgstr "Transactions"
#: .\account\templates\account\account_form.html:18
msgid "History"
msgstr "Historique"

View file

@ -0,0 +1,29 @@
{% extends "main/base.html" %}
{% load main_extras %}
{% load i18n %}
{% block title %}{{ object }} {{ block.super }}{% endblock %}
{% block link %}
{{ block.super }}
{% css "main/css/table.css" %}
{% css "main/css/plot.css" %}
{% endblock %}
{% block body %}
<h2>{{ object.icon|remix }}{{ object }}</h2>
<p>
<a href="{% url "edit_account" object.pk %}">{% translate "Edit account" %}</a>
</p>
<section>
<h3>{% translate "Statements" %}</h3>
{% include "statement/statement_table.html" %}
</section>
<section>
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
</section>
{% if history %}
<section>
<h3>{% translate "History" %}</h3>
{% include "history/plot.html" %}
</section>
{% endif %}
{% endblock %}

View file

@ -8,15 +8,3 @@
{% translate "New account" %} {% translate "New account" %}
{% endblock %} {% endblock %}
{% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %} {% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block tables %}
{% if not form.instance|adding %}
<h3>{% translate "Statements" %}</h3>
{% include "statement/statement_table.html" %}
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
{% if history.data %}
<h3>{% translate "History" %}</h3>
{% include "history/plot.html" %}
{% endif %}
{% endif %}
{% endblock %}

View file

@ -1,12 +1,13 @@
from django.urls import path from django.urls import path
from statement.views import StatementCreateView from statement.views import StatementCreateView
from transaction.views import TransactionMonthView from transaction.views import TransactionMonthView, TransactionYearView
from . import views from . import views
urlpatterns = [ urlpatterns = [
path("new", views.AccountCreateView.as_view(), name="new_account"), path("new", views.AccountCreateView.as_view(), name="new_account"),
path("<account>", views.AccountUpdateView.as_view(), name="account"), path("<account>", views.AccountDetailView.as_view(), name="account"),
path("<account>/edit", views.AccountUpdateView.as_view(), name="edit_account"),
path( path(
"<account>/transactions", "<account>/transactions",
views.AccountTListView.as_view(), views.AccountTListView.as_view(),
@ -27,9 +28,14 @@ urlpatterns = [
views.AccountDeleteView.as_view(), views.AccountDeleteView.as_view(),
name="del_account", name="del_account",
), ),
path(
"<account>/history/<int:year>",
TransactionYearView.as_view(),
name="account_transaction_year",
),
path( path(
"<account>/history/<int:year>/<int:month>", "<account>/history/<int:year>/<int:month>",
TransactionMonthView.as_view(), TransactionMonthView.as_view(),
name="transaction_month", name="account_transaction_month",
), ),
] ]

View file

@ -1,7 +1,12 @@
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.urls import reverse_lazy from django.urls import reverse_lazy
from history.utils import history from history.utils import history
from main.views import NummiCreateView, NummiDeleteView, NummiUpdateView from main.views import (
NummiCreateView,
NummiDeleteView,
NummiDetailView,
NummiUpdateView,
)
from statement.views import StatementListView from statement.views import StatementListView
from transaction.views import TransactionListView from transaction.views import TransactionListView
@ -19,10 +24,20 @@ class AccountUpdateView(NummiUpdateView):
form_class = AccountForm form_class = AccountForm
pk_url_kwarg = "account" pk_url_kwarg = "account"
class AccountDeleteView(NummiDeleteView):
model = Account
pk_url_kwarg = "account"
class AccountDetailView(NummiDetailView):
model = Account
pk_url_kwarg = "account"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
_max = 8 _max = 8
data = super().get_context_data(**kwargs) data = super().get_context_data(**kwargs)
account = data["form"].instance account = data.get("object")
_transactions = account.transaction_set.all() _transactions = account.transaction_set.all()
if _transactions.count() > _max: if _transactions.count() > _max:
@ -45,11 +60,6 @@ class AccountUpdateView(NummiUpdateView):
} }
class AccountDeleteView(NummiDeleteView):
model = Account
pk_url_kwarg = "account"
class AccountMixin: class AccountMixin:
def get_queryset(self): def get_queryset(self):
self.account = get_object_or_404( self.account = get_object_or_404(

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-25 12:05+0100\n" "POT-Creation-Date: 2024-01-04 16:18+0100\n"
"PO-Revision-Date: 2023-04-22 15:18+0200\n" "PO-Revision-Date: 2023-04-22 15:18+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n" "Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n" "Language-Team: \n"
@ -38,6 +38,18 @@ msgstr "Budget"
msgid "Categories" msgid "Categories"
msgstr "Catégories" msgstr "Catégories"
#: .\category\templates\category\category_detail.html:12
msgid "Edit category"
msgstr "Modifier la catégorie"
#: .\category\templates\category\category_detail.html:15
msgid "Transactions"
msgstr "Transactions"
#: .\category\templates\category\category_detail.html:20
msgid "History"
msgstr "Historique"
#: .\category\templates\category\category_form.html:5 #: .\category\templates\category\category_form.html:5
msgid "Create category" msgid "Create category"
msgstr "Créer une catégorie" msgstr "Créer une catégorie"
@ -46,14 +58,6 @@ msgstr "Créer une catégorie"
msgid "New category" msgid "New category"
msgstr "Nouvelle catégorie" msgstr "Nouvelle catégorie"
#: .\category\templates\category\category_form.html:12
msgid "Transactions"
msgstr "Transactions"
#: .\category\templates\category\category_form.html:15
msgid "History"
msgstr "Historique"
#: .\category\templates\category\category_plot.html:15 #: .\category\templates\category\category_plot.html:15
msgid "Expenses" msgid "Expenses"
msgstr "Dépenses" msgstr "Dépenses"
@ -62,10 +66,10 @@ msgstr "Dépenses"
msgid "Income" msgid "Income"
msgstr "Revenus" msgstr "Revenus"
#: .\category\templates\category\category_plot.html:56 #: .\category\templates\category\category_plot.html:62
msgid "No transaction" msgid "No transaction"
msgstr "Aucune transaction" msgstr "Aucune transaction"
#: .\category\templates\category\category_plot.html:64 #: .\category\templates\category\category_plot.html:70
msgid "Total" msgid "Total"
msgstr "Total" msgstr "Total"

View file

@ -0,0 +1,24 @@
{% extends "main/base.html" %}
{% load main_extras i18n %}
{% block title %}{{ object }} {{ block.super }}{% endblock %}
{% block link %}
{{ block.super }}
{% css "main/css/table.css" %}
{% css "main/css/plot.css" %}
{% endblock %}
{% block body %}
<h2>{{ object.icon|remix }}{{ object }}</h2>
<p>
<a href="{% url "edit_category" object.pk %}">{% translate "Edit category" %}</a>
</p>
<section>
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
</section>
{% if history %}
<section>
<h3>{% translate "History" %}</h3>
{% include "history/plot.html" %}
</section>
{% endif %}
{% endblock %}

View file

@ -8,11 +8,3 @@
{% translate "New category" %} {% translate "New category" %}
{% endblock %} {% endblock %}
{% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %} {% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block tables %}
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
{% if history.data %}
<h3>{% translate "History" %}</h3>
{% include "history/plot.html" %}
{% endif %}
{% endblock %}

View file

@ -1,4 +1,4 @@
{% load main_extras %} {% load main_extras statement_extras %}
{% load i18n %} {% load i18n %}
<div class="plot"> <div class="plot">
<table class="full-width"> <table class="full-width">
@ -23,7 +23,9 @@
<th scope="row" class="l"> <th scope="row" class="l">
{% if cat.category %} {% if cat.category %}
{% if month %} {% if month %}
<a href="{% url "transaction_month" cat.category month.year month.month %}">{{ cat.category__name }}</a> <a href="{% url "category_transaction_month" cat.category month.year month.month %}">{{ cat.category__name }}</a>
{% elif year %}
<a href="{% url "category_transaction_year" cat.category year.year %}">{{ cat.category__name }}</a>
{% else %} {% else %}
{{ cat.category__name }} {{ cat.category__name }}
{% endif %} {% endif %}
@ -32,24 +34,28 @@
<td class="c"> <td class="c">
{% if cat.category %}{{ cat.category__icon|remix }}{% endif %} {% if cat.category %}{{ cat.category__icon|remix }}{% endif %}
</td> </td>
<td class="value">{{ cat.sum_m|pmrvalue }}</td> <td class="value">{{ cat.sum_m|pmvalue }}</td>
<td class="bar m"> <td class="bar m">
{% if cat.sum_m %}
<div style="width: {% widthratio cat.sum_m max -100 %}%"></div> <div style="width: {% widthratio cat.sum_m max -100 %}%"></div>
{% endif %}
{% if cat.sum < 0 %} {% if cat.sum < 0 %}
<div class="tot" style="width:{% widthratio cat.sum max -100 %}%"> <div class="tot" style="width:{% widthratio cat.sum max -100 %}%">
<span>{{ cat.sum|pmrvalue }}</span> <span>{{ cat.sum|pmvalue }}</span>
</div> </div>
{% endif %} {% endif %}
</td> </td>
<td class="bar p"> <td class="bar p">
{% if cat.sum_p %}
<div style="width: {% widthratio cat.sum_p max 100 %}%"></div> <div style="width: {% widthratio cat.sum_p max 100 %}%"></div>
{% endif %}
{% if cat.sum > 0 %} {% if cat.sum > 0 %}
<div class="tot" style="width:{% widthratio cat.sum max 100 %}%"> <div class="tot" style="width:{% widthratio cat.sum max 100 %}%">
<span>{{ cat.sum|pmrvalue }}</span> <span>{{ cat.sum|pmvalue }}</span>
</div> </div>
{% endif %} {% endif %}
</td> </td>
<td class="value">{{ cat.sum_p|pmrvalue }}</td> <td class="value">{{ cat.sum_p|pmvalue }}</td>
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
@ -58,16 +64,16 @@
{% endfor %} {% endfor %}
{% endspaceless %} {% endspaceless %}
</tbody> </tbody>
{% if categories %}
<tfoot> <tfoot>
{% if categories %}
<tr> <tr>
<th scope="row" colspan="2" class="l">{% translate "Total" %}</th> <th scope="row" colspan="2" class="l">{% translate "Total" %}</th>
<td class="value">{{ total_m|pmrvalue }}</td> <td class="value">{{ total_m|pmvalue }}</td>
<td class="bar m"> <td class="bar m">
<div style="width: {% widthratio total_m max -100 %}%"></div> <div style="width: {% widthratio total_m max -100 %}%"></div>
{% if total < 0 %} {% if total < 0 %}
<div class="tot" style="width:{% widthratio total max -100 %}%"> <div class="tot" style="width:{% widthratio total max -100 %}%">
<span>{{ total|pmrvalue }}</span> <span>{{ total|pmvalue }}</span>
</div> </div>
{% endif %} {% endif %}
</td> </td>
@ -75,13 +81,35 @@
<div style="width: {% widthratio total_p max 100 %}%"></div> <div style="width: {% widthratio total_p max 100 %}%"></div>
{% if total > 0 %} {% if total > 0 %}
<div class="tot" style="width:{% widthratio total max 100 %}%"> <div class="tot" style="width:{% widthratio total max 100 %}%">
<span>{{ total|pmrvalue }}</span> <span>{{ total|pmvalue }}</span>
</div> </div>
{% endif %} {% endif %}
</td> </td>
<td class="value">{{ total_p|pmrvalue }}</td> <td class="value">{{ total_p|pmvalue }}</td>
</tr> </tr>
</tfoot>
{% endif %} {% endif %}
{% if statement %}
<tr>
<th scope="row" class="l">{% translate "Expected total" %}</th>
<td class="c">{{ total|check:statement.diff }}</td>
<td></td>
<td class="bar m">
{% if statement.diff < 0 %}
<div class="tot" style="width:{% widthratio statement.diff max -100 %}%">
<span>{{ statement.diff|pmvalue }}</span>
</div>
{% endif %}
</td>
<td class="bar p">
{% if statement.diff >= 0 %}
<div class="tot" style="width:{% widthratio statement.diff max 100 %}%">
<span>{{ statement.diff|pmvalue }}</span>
</div>
{% endif %}
</td>
<td></td>
</tr>
{% endif %}
</tfoot>
</table> </table>
</div> </div>

View file

@ -6,10 +6,11 @@ register = template.Library()
@register.inclusion_tag("category/category_plot.html") @register.inclusion_tag("category/category_plot.html")
def category_plot(transactions, **kwargs): def category_plot(transactions, budget=True, **kwargs):
if budget:
transactions = transactions.exclude(category__budget=False)
categories = ( categories = (
transactions.exclude(category__budget=False) transactions.values("category", "category__name", "category__icon")
.values("category", "category__name", "category__icon")
.annotate( .annotate(
sum=models.Sum("value"), sum=models.Sum("value"),
sum_m=models.Sum("value", filter=models.Q(value__lt=0)), sum_m=models.Sum("value", filter=models.Q(value__lt=0)),

View file

@ -1,20 +1,26 @@
from django.urls import path from django.urls import path
from transaction.views import TransactionMonthView from transaction.views import TransactionMonthView, TransactionYearView
from . import views from . import views
urlpatterns = [ urlpatterns = [
path("new", views.CategoryCreateView.as_view(), name="new_category"), path("new", views.CategoryCreateView.as_view(), name="new_category"),
path("<category>", views.CategoryUpdateView.as_view(), name="category"), path("<category>", views.CategoryDetailView.as_view(), name="category"),
path("<category>/edit", views.CategoryUpdateView.as_view(), name="edit_category"),
path( path(
"<category>/transactions", "<category>/transactions",
views.CategoryTListView.as_view(), views.CategoryTListView.as_view(),
name="category_transactions", name="category_transactions",
), ),
path("<category>/delete", views.CategoryDeleteView.as_view(), name="del_category"), path("<category>/delete", views.CategoryDeleteView.as_view(), name="del_category"),
path(
"<category>/history/<int:year>",
TransactionYearView.as_view(),
name="category_transaction_year",
),
path( path(
"<category>/history/<int:year>/<int:month>", "<category>/history/<int:year>/<int:month>",
TransactionMonthView.as_view(), TransactionMonthView.as_view(),
name="transaction_month", name="category_transaction_month",
), ),
] ]

View file

@ -1,7 +1,12 @@
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.urls import reverse_lazy from django.urls import reverse_lazy
from history.utils import history from history.utils import history
from main.views import NummiCreateView, NummiDeleteView, NummiUpdateView from main.views import (
NummiCreateView,
NummiDeleteView,
NummiDetailView,
NummiUpdateView,
)
from transaction.views import TransactionListView from transaction.views import TransactionListView
from .forms import CategoryForm from .forms import CategoryForm
@ -18,10 +23,15 @@ class CategoryUpdateView(NummiUpdateView):
form_class = CategoryForm form_class = CategoryForm
pk_url_kwarg = "category" pk_url_kwarg = "category"
class CategoryDetailView(NummiDetailView):
model = Category
pk_url_kwarg = "category"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
_max = 8 _max = 8
data = super().get_context_data(**kwargs) data = super().get_context_data(**kwargs)
category = data["form"].instance category = data["object"]
data["transactions"] = category.transaction_set.all()[:_max] data["transactions"] = category.transaction_set.all()[:_max]
if len(data["transactions"]) == _max: if len(data["transactions"]) == _max:

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-22 15:16+0200\n" "POT-Creation-Date: 2024-01-03 15:51+0100\n"
"PO-Revision-Date: 2023-04-22 15:18+0200\n" "PO-Revision-Date: 2023-04-22 15:18+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n" "Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n" "Language-Team: \n"
@ -17,14 +17,18 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.2.2\n" "X-Generator: Poedit 3.2.2\n"
#: .\history\templates\history\plot.html:15 #: .\history\templates\history\plot.html:17
msgid "Month" msgid "Month"
msgstr "Mois" msgstr "Mois"
#: .\history\templates\history\plot.html:16 #: .\history\templates\history\plot.html:18
msgid "Expenses" msgid "Expenses"
msgstr "Dépenses" msgstr "Dépenses"
#: .\history\templates\history\plot.html:17 #: .\history\templates\history\plot.html:19
msgid "Income" msgid "Income"
msgstr "Revenus" msgstr "Revenus"
#: .\history\templates\history\plot.html:55
msgid "Year"
msgstr "Année"

View file

@ -1,6 +1,8 @@
{% load main_extras %} {% load main_extras %}
{% load history_extras %}
{% load transaction_extras %}
{% load i18n %} {% load i18n %}
<div class="plot"> <div class="history plot">
<table class="full-width"> <table class="full-width">
<colgroup> <colgroup>
<col class="icon"> <col class="icon">
@ -18,46 +20,67 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% spaceless %} {% for date in history.data reversed %}
{% for date in history.data %} {% ifchanged %}
<tr> {% if date.sum_m or date.sum_p %}
<td class="icon"> <tr {% if not date.month.month|divisibleby:"2" %}class="even"{% endif %}>
<span class="ri-{% if date.sum > 0 %}arrow-up-s-line green{% elif date.sum < 0 %}arrow-down-s-line red{% endif %}"></span> <td class="icon">{% up_down_icon date.sum %}</td>
</td>
<th class="date" scope="row"> <th class="date" scope="row">
{% if date.has_transactions %} {% if year %}
{% if account %} {% month_url date.month fmt="F" %}
<a href="{% url "transaction_month" account=account.pk year=date.month.year month=date.month.month %}">{{ date.month|date:"Y-m" }}</a>
{% elif category %}
<a href="{% url "transaction_month" category=category.pk year=date.month.year month=date.month.month %}">{{ date.month|date:"Y-m" }}</a>
{% else %} {% else %}
<a href="{% url "transaction_month" year=date.month.year month=date.month.month %}">{{ date.month|date:"Y-m" }}</a> {% month_url date.month %}
{% endif %}
{% else %}
{{ date.month|date:"Y-m" }}
{% endif %} {% endif %}
</th> </th>
<td class="value">{{ date.sum_m|pmrvalue }}</td> <td class="value">{{ date.sum_m|pmrvalue }}</td>
<td class="bar m"> <td class="bar m">{% plot_bar date.sum date.sum_m history.max.pm %}</td>
<div style="width: {% widthratio date.sum_m history.max -100 %}%"></div> <td class="bar p">{% plot_bar date.sum date.sum_p history.max.pm %}</td>
{% if date.sum < 0 %}
<div class="tot" style="width:{% widthratio date.sum history.max -100 %}%">
<span>{{ date.sum|pmrvalue }}</span>
</div>
{% endif %}
</td>
<td class="bar p">
<div style="width: {% widthratio date.sum_p history.max 100 %}%"></div>
{% if date.sum > 0 %}
<div class="tot" style="width:{% widthratio date.sum history.max 100 %}%">
<span>{{ date.sum|pmrvalue }}</span>
</div>
{% endif %}
</td>
<td class="value">{{ date.sum_p|pmrvalue }}</td> <td class="value">{{ date.sum_p|pmrvalue }}</td>
</tr> </tr>
{% else %}
<tr class="empty">
<td colspan="6" class="empty"></td>
</tr>
{% endif %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
</div>
<div class="calendar">
<table class="full-width">
<thead>
<tr>
{% if not year %}
<th scope="col">{% translate "Year" %}</th>
{% endif %}
{% calendar_head %}
</tr>
</thead>
<tbody>
{% regroup history.data by month.year as years_list %}
{% for y, y_data in years_list reversed %}
<tr>
{% if not year %}
<th class="date" scope="row">{% year_url y %}</th>
{% endif %}
{% for m in y_data %}
{% if forloop.parentloop.last and forloop.first %}
{% empty_calendar_cells_start m.month.month %}
{% endif %}
{% if m %}
<td class="{% if m.sum > 0 %}p{% else %}m{% endif %}"
style="--opacity: {% calendar_opacity m.sum history.max.sum %}"
title="{{ m.sum|pmrvalue }}">{% up_down_icon m.sum %}</td>
{% else %}
<td></td>
{% endif %}
{% if forloop.parentloop.first and forloop.last %}
{% empty_calendar_cells_end m.month.month %}
{% endif %}
{% endfor %}
</tr>
{% endfor %} {% endfor %}
{% endspaceless %}
</tbody> </tbody>
</table> </table>
</div> </div>

View file

@ -0,0 +1,62 @@
import math
from django import template
from django.utils.safestring import mark_safe
from main.templatetags.main_extras import pmrvalue, remix
register = template.Library()
@register.simple_tag
def calendar_opacity(v, vmax):
return f"{math.sin(math.fabs(v/vmax)*math.pi/2):.0%}"
@register.simple_tag
def empty_calendar_cells(n):
return mark_safe(n * "<td></td>")
@register.simple_tag
def empty_calendar_cells_start(n):
return empty_calendar_cells(n - 1)
@register.simple_tag
def empty_calendar_cells_end(n):
return empty_calendar_cells(12 - n)
@register.simple_tag
def up_down_icon(val):
if val > 0:
return remix("arrow-up-s", "green")
elif val < 0:
return remix("arrow-down-s", "red")
return remix("equal", "white")
@register.simple_tag
def plot_bar(s, sum_pm, s_max):
_res = ""
if sum_pm:
_w = abs(sum_pm / s_max)
_res += f"""<div style="width: {_w:.1%}"></div>"""
if sum_pm is not None and s * sum_pm > 0:
_w = abs(s / s_max)
_res += (
f"""<div class="tot" style="width: {_w:.1%}">"""
f"""<span>{pmrvalue(s)}</span></div>"""
)
return mark_safe(_res)
@register.simple_tag
def calendar_head():
months = range(1, 13)
th = (f"""<th>{month:02d}</th>""" for month in months)
return mark_safe("".join(th))

View file

@ -1,48 +1,47 @@
from django.db import models import datetime
from django.db.models import Func, Max, Min, Q, Sum, Value
from django.db.models.functions import Now, TruncMonth
from django.db.models import Max, Min, Q, Sum
class GenerateMonth(Func): from django.db.models.functions import Abs, TruncMonth
function = "generate_series"
template = "%(function)s(%(expressions)s, '1 month')::date"
def history(transaction_set): def history(transaction_set):
if not transaction_set.exists(): if not transaction_set.exists():
return None return None
_transaction_month = transaction_set.values(month=TruncMonth("date")).order_by( _transaction_month = transaction_set.values(month=TruncMonth("date")).order_by(
"-date" "-date"
) )
_months = ( _first_month = _transaction_month.last()["month"]
transaction_set.values( _last_month = _transaction_month.first()["month"]
month=GenerateMonth(
_transaction_month.last()["month"],
Now(output_field=models.DateField()),
)
)
.annotate(
sum_m=Value(0), sum_p=Value(0), sum=Value(0), has_transactions=Value(0)
)
.difference(
_transaction_month.annotate(
sum_m=Value(0), sum_p=Value(0), sum=Value(0), has_transactions=Value(0)
)
)
)
_history = _transaction_month.annotate( _history = _transaction_month.annotate(
sum_p=Sum("value", filter=Q(value__gt=0)), sum_p=Sum("value", filter=Q(value__gt=0)),
sum_m=Sum("value", filter=Q(value__lt=0)), sum_m=Sum("value", filter=Q(value__lt=0)),
sum=Sum("value"), sum=Sum("value"),
has_transactions=Value(1),
).order_by("-month") ).order_by("-month")
_data = [
_history.filter(month=datetime.date(y, m + 1, 1)).first()
or {"month": datetime.date(y, m + 1, 1), "sum": 0}
for y in range(
_first_month.year,
_last_month.year + 1,
)
for m in range(
_first_month.month - 1 if _first_month.year == y else 0,
_last_month.month if _last_month.year == y else 12,
)
]
return { return {
"data": _history.union(_months).order_by("-month"), "data": _data,
"max": max( "max": {
"pm": max(
_history.aggregate( _history.aggregate(
max=Max("sum_p", default=0), max=Max("sum_p", default=0),
min=-Min("sum_m", default=0), min=-Min("sum_m", default=0),
).values(), ).values(),
), ),
"sum": _history.aggregate(max=Max(Abs("sum")))["max"],
},
} }

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-25 12:05+0100\n" "POT-Creation-Date: 2024-01-04 16:18+0100\n"
"PO-Revision-Date: 2023-04-23 08:03+0200\n" "PO-Revision-Date: 2023-04-23 08:03+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n" "Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n" "Language-Team: \n"
@ -21,67 +21,51 @@ msgstr ""
msgid "User" msgid "User"
msgstr "Utilisateur" msgstr "Utilisateur"
#: .\main\templates\main\base.html:27 #: .\main\templates\main\base.html:28
msgid "Skip to main content" msgid "Skip to main content"
msgstr "Aller au contenu principal" msgstr "Aller au contenu principal"
#: .\main\templates\main\base.html:33 #: .\main\templates\main\base.html:34
msgid "Home" msgid "Home"
msgstr "Accueil" msgstr "Accueil"
#: .\main\templates\main\base.html:38 .\main\templates\main\index.html:40 #: .\main\templates\main\base.html:39
msgid "Statements" msgid "Statements"
msgstr "Relevés" msgstr "Relevés"
#: .\main\templates\main\base.html:44 .\main\templates\main\index.html:24 #: .\main\templates\main\base.html:45
msgid "Transactions" msgid "Transactions"
msgstr "Transactions" msgstr "Transactions"
#: .\main\templates\main\base.html:50 #: .\main\templates\main\base.html:51 .\main\templates\main\list.html:10
msgid "Create account" #: .\main\templates\main\list.html:34
msgstr "Créer un compte"
#: .\main\templates\main\base.html:55
msgid "Create statement"
msgstr "Créer un relevé"
#: .\main\templates\main\base.html:60
msgid "Create category"
msgstr "Créer une catégorie"
#: .\main\templates\main\base.html:65
msgid "Create transaction"
msgstr "Créer une transaction"
#: .\main\templates\main\base.html:70 .\main\templates\main\list.html:10
#: .\main\templates\main\list.html:36
msgid "Search" msgid "Search"
msgstr "Rechercher" msgstr "Rechercher"
#: .\main\templates\main\base.html:73 #: .\main\templates\main\base.html:54
msgid "Log out" msgid "Log out"
msgstr "Se déconnecter" msgstr "Se déconnecter"
#: .\main\templates\main\base.html:78 .\main\templates\main\form\login.html:6 #: .\main\templates\main\base.html:59 .\main\templates\main\form\login.html:6
#: .\main\templates\main\login.html:14 #: .\main\templates\main\login.html:11
msgid "Log in" msgid "Log in"
msgstr "Se connecter" msgstr "Se connecter"
#: .\main\templates\main\base.html:84 #: .\main\templates\main\base.html:65
#, python-format #, python-format
msgid "Logged in as <strong>%(user)s</strong>" msgid "Logged in as <strong>%(user)s</strong>"
msgstr "Connecté en tant que <strong>%(user)s</strong>" msgstr "Connecté en tant que <strong>%(user)s</strong>"
#: .\main\templates\main\confirm_delete.html:19 #: .\main\templates\main\confirm_delete.html:15
#, python-format #, python-format
msgid "Are you sure you want do delete <strong>%(object)s</strong> ?" msgid "Are you sure you want do delete <strong>%(object)s</strong> ?"
msgstr "Êtes-vous sûr de vouloir supprimer <strong>%(object)s</strong> ?" msgstr "Êtes-vous sûr de vouloir supprimer <strong>%(object)s</strong> ?"
#: .\main\templates\main\confirm_delete.html:23 #: .\main\templates\main\confirm_delete.html:19
msgid "Cancel" msgid "Cancel"
msgstr "Annuler" msgstr "Annuler"
#: .\main\templates\main\confirm_delete.html:24 #: .\main\templates\main\confirm_delete.html:20
msgid "Confirm" msgid "Confirm"
msgstr "Confirmer" msgstr "Confirmer"
@ -105,26 +89,51 @@ msgstr "Créer"
msgid "Save" msgid "Save"
msgstr "Enregistrer" msgstr "Enregistrer"
#: .\main\templates\main\index.html:15 #: .\main\templates\main\index.html:13
msgid "Accounts" msgid "Accounts"
msgstr "Comptes" msgstr "Comptes"
#: .\main\templates\main\index.html:20 #: .\main\templates\main\index.html:17
msgid "Account"
msgstr "Compte"
#: .\main\templates\main\index.html:18
msgid "Balance"
msgstr "Solde"
#: .\main\templates\main\index.html:19 .\main\templates\main\index.html:31
msgid "Edit"
msgstr "Modifier"
#: .\main\templates\main\index.html:36
msgid "No account" msgid "No account"
msgstr "Aucun compte" msgstr "Aucun compte"
#: .\main\templates\main\index.html:28 #: .\main\templates\main\index.html:43
msgid "Create account"
msgstr "Créer un compte"
#: .\main\templates\main\index.html:50
msgid "Categories" msgid "Categories"
msgstr "Catégories" msgstr "Catégories"
#: .\main\templates\main\index.html:34 #: .\main\templates\main\index.html:56
msgid "No category" msgid "Create category"
msgstr "Aucune catégorie" msgstr "Créer une catégorie"
#: .\main\templates\main\index.html:44 #: .\main\templates\main\index.html:63
msgid "History" msgid "History"
msgstr "Historique" msgstr "Historique"
#: .\main\views.py:68 #: .\main\views.py:69
msgid "was created successfully" msgid "was created successfully"
msgstr "a été créé avec succès" msgstr "a été créé avec succès"
#~ msgid "Create statement"
#~ msgstr "Créer un relevé"
#~ msgid "Create transaction"
#~ msgstr "Créer une transaction"
#~ msgid "No category"
#~ msgstr "Aucune catégorie"

View file

@ -5,58 +5,65 @@ form ul.errorlist {
margin: 0; margin: 0;
} }
form > table > tbody > tr > th { form {
> table > tbody > tr > th {
background: var(--bg-01); background: var(--bg-01);
background-clip: padding-box; background-clip: padding-box;
border-right: 1px solid var(--gray);
} }
form tbody input, tbody :is(input, select, textarea) {
form tbody select,
form tbody textarea {
font: inherit; font: inherit;
border: none; border: none;
background: var(--bg); background: transparent;
width: 100%; width: 100%;
height: 100%; height: 100%;
line-height: 1.5; line-height: 1.5;
} }
form input[type="checkbox"] { input[type="checkbox"] {
width: initial; width: initial;
} }
table.file-input tr { tfoot {
border: none;
}
table.file-input th {
text-align: left;
}
table.file-input tr :first-child {
padding-left: 0;
}
table.file-input tr :last-child {
padding-right: 0;
}
form tfoot {
text-align: right; text-align: right;
} }
.buttons input { }
table.file-input {
tr {
border: none;
:first-child {
padding-left: 0;
}
:last-child {
padding-right: 0;
}
}
th {
text-align: left;
}
}
.buttons {
input {
font: inherit; font: inherit;
line-height: 1.5; line-height: 1.5;
margin-left: var(--gap); margin-left: var(--gap);
border-radius: var(--radius); border-radius: var(--radius);
padding: 0 var(--gap); padding: 0 var(--gap);
cursor: pointer; cursor: pointer;
}
.buttons input:hover { &:hover {
text-decoration: underline; text-decoration: underline;
} }
.buttons input[type="submit"] { &[type="submit"] {
border: 0.1rem solid var(--green); border: 0.1rem solid var(--green);
background: var(--green-1); background: var(--green-1);
} }
.buttons input[type="reset"] { &[type="reset"] {
border: 0.1rem solid var(--red); border: 0.1rem solid var(--red);
background: var(--red-1); background: var(--red-1);
} }
.buttons a.del { }
a.del {
color: var(--red); color: var(--red);
} }
}

View file

@ -1,4 +1,5 @@
@import "https://rsms.me/inter/inter.css"; @import "https://rsms.me/inter/inter.css";
@import "https://cdn.jsdelivr.net/npm/remixicon@4.0.0/fonts/remixicon.css";
*, *,
*::before, *::before,
@ -39,7 +40,8 @@
--border: 0.5em; --border: 0.5em;
--radius: 0.25em; --radius: 0.25em;
--num: "tnum", "ss01", "ss02", "case"; --default-ffs: "dlig", "ss01", "ss04";
--num: var(--default-ffs), "tnum", "case";
} }
body { body {
@ -51,6 +53,7 @@ body {
display: grid; display: grid;
grid-template-columns: max-content 1fr; grid-template-columns: max-content 1fr;
font-feature-settings: var(--default-ffs);
} }
p { p {
@ -60,11 +63,31 @@ a {
color: var(--text-link); color: var(--text-link);
text-decoration: none; text-decoration: none;
display: inline-block; display: inline-block;
}
a:hover { &:is(:hover, :focus) {
text-decoration: underline; text-decoration: underline;
} }
&.big-link {
margin-right: 1em;
padding: 0 0.5em;
color: white;
background: var(--green);
border-radius: var(--radius);
height: 1.5rem;
line-height: 1.5rem;
[class^="ri-"] {
margin-right: 0.5em;
}
&.add {
color: var(--text-link);
background: var(--bg-01);
}
}
}
.red { .red {
color: var(--red); color: var(--red);
fill: var(--red); fill: var(--red);
@ -83,6 +106,23 @@ main {
grid-column: 2; grid-column: 2;
grid-row: 1; grid-row: 1;
overflow-x: hidden; overflow-x: hidden;
h2.new {
opacity: 0.8;
}
.split {
display: grid;
column-gap: var(--gap);
row-gap: var(--gap);
grid-template-columns: 100%;
@media (width > 720px) {
grid-template-columns: max-content 1fr;
}
& > section > :first-child {
margin-top: 0;
}
}
} }
nav { nav {
grid-column: 1; grid-column: 1;
@ -95,38 +135,46 @@ nav {
background: var(--bg-01); background: var(--bg-01);
line-height: 2rem; line-height: 2rem;
}
nav h1 img { h1 img {
height: 1cap; height: 1cap;
} }
nav ul { ul {
list-style: none; list-style: none;
padding: 0; padding: 0;
margin: 0; margin: 0;
position: relative; position: relative;
} }
nav .skip-link { a {
opacity: 0.8; &.skip-link {
font-weight: 300; font-weight: 300;
}
nav .skip-link:active, &:is(:active, :focus) {
nav .skip-link:focus {
opacity: initial;
font-weight: 500; font-weight: 500;
} }
nav a {
display: block;
} }
nav a.cur { display: grid;
grid-template-columns: 1fr max-content;
align-items: baseline;
[class^="ri-"] {
height: 1.5em;
width: 1.5em;
line-height: 1.5em;
border-radius: var(--radius);
}
&.cur {
font-weight: 550; font-weight: 550;
[class^="ri-"] {
background: var(--text-link);
color: var(--bg);
} }
nav a.cur::after {
content: "◎";
position: absolute;
right: 0;
} }
nav > :first-child, }
main > :first-child { }
:is(nav, main) > :first-child,
main > section:first-child > :first-child {
margin-top: 0; margin-top: 0;
} }
footer { footer {
@ -135,16 +183,46 @@ footer {
font-weight: 250; font-weight: 250;
} }
#pagination { .pagination {
text-align: center; text-align: center;
font-feature-settings: var(--num); font-feature-settings: var(--num);
}
#pagination a { a {
width: 2rem; min-width: 1rem;
} padding: 0 0.5rem;
#pagination a.cur {
&.cur {
font-weight: 650; font-weight: 650;
text-decoration: underline dotted; text-decoration: underline dotted;
&:is(:hover, :focus) {
text-decoration: underline;
}
}
}
@media (width > 720px) {
&.n3 {
display: grid;
grid-template-columns: repeat(3, 1fr);
width: max-content;
margin: 0.5rem auto;
.prev {
grid-column: 1;
}
.cur {
grid-column: 2;
}
.next {
grid-column: 3;
}
}
}
& + section :first-child {
margin-top: 0;
}
} }
@media (width < 1024px) { @media (width < 1024px) {
@ -160,15 +238,34 @@ footer {
height: initial; height: initial;
} }
} }
[class^="ri-"] {
display: inline-block;
text-align: center;
font-weight: normal;
a.big-link { &.green,
margin-right: 1em; &.red,
&.white {
&.green {
background: var(--green);
color: var(--bg);
} }
a.big-link [class^="ri-"] { &.red {
background: var(--red);
color: var(--bg);
}
&.white {
background: var(--bg-01);
}
border-radius: var(--radius);
height: 1.5em;
width: 1.5em;
line-height: 1.5em;
}
h2 & {
margin-right: 0.5em; margin-right: 0.5em;
} }
[class^="ri-"] {
font-weight: normal;
} }
h1, h1,
@ -188,9 +285,6 @@ h2 {
h3 { h3 {
font-size: 1.5rem; font-size: 1.5rem;
} }
main h2.new {
opacity: 0.8;
}
p { p {
margin: 0.5em 0; margin: 0.5em 0;
} }
@ -201,18 +295,42 @@ ul.messages {
margin: 0; margin: 0;
background: var(--bg-01); background: var(--bg-01);
padding: 0; padding: 0;
}
ul.messages li { li {
padding: calc(var(--gap) / 2) var(--gap); padding: calc(var(--gap) / 2) var(--gap);
border-left: var(--border) solid var(--gray); border-left: var(--border) solid var(--gray);
}
ul.messages li.msg-level-25 { &.msg-level-25 {
border-left-color: var(--green-1); border-left-color: var(--green-1);
} }
ul.messages li.msg-level-30 { &.msg-level-30 {
border-left-color: var(--red-1); border-left-color: var(--red-1);
} }
ul.messages li.msg-level-40 { &.msg-level-40 {
border-left-color: var(--red); border-left-color: var(--red);
} }
}
}
.backlinks {
display: grid;
grid-template-columns: repeat(2, 1fr);
p {
grid-column: 1;
&.back {
grid-column: 2;
text-align: right;
a {
margin-right: 0;
margin-left: 1em;
[class^="ri-"] {
margin-right: 0em;
margin-left: 0.5em;
}
}
}
}
}

View file

@ -1,52 +1,33 @@
table.full-width col.bar { table.full-width col.bar {
width: auto; width: auto;
} }
.plot { .plot {
overflow-x: auto; overflow-x: auto;
}
.plot td.bar { td.bar {
position: relative; position: relative;
padding: 0; padding: 0;
overflow: hidden;
@media (width < 720px) {
width: 0;
} }
.plot td.bar div {
div {
position: absolute; position: absolute;
height: 0.5rem; height: 0.5rem;
top: 0; top: 0;
} &:not(.tot) {
.plot td.bar div:not(.tot) {
width: 0; width: 0;
box-sizing: border-box; box-sizing: border-box;
z-index: 1; z-index: 1;
display: inline-block; display: inline-block;
} }
.plot td.bar.p div { &.tot {
left: 0;
border-radius: 0 var(--radius) var(--radius) 0;
}
.plot td.bar.m div {
right: 0;
border-radius: var(--radius) 0 0 var(--radius);
}
.plot td.bar.m div {
background: var(--red-1);
}
.plot td.bar.p div {
background: var(--green-1);
}
.plot td.bar div.tot {
z-index: 10; z-index: 10;
height: 0.5rem; height: 0.5rem;
}
.plot td.bar.m div.tot { span {
background: var(--red);
}
.plot td.bar.p div.tot {
background: var(--green);
}
.plot td.bar div.tot span {
position: absolute; position: absolute;
display: inline-block; display: inline-block;
white-space: nowrap; white-space: nowrap;
@ -57,20 +38,81 @@ table.full-width col.bar {
height: 1.5rem; height: 1.5rem;
font-feature-settings: var(--num); font-feature-settings: var(--num);
} }
.plot td.bar.p div.tot span { }
}
&.p div {
left: 0;
border-radius: 0 var(--radius) var(--radius) 0;
background: var(--green-1);
&.tot {
background: var(--green);
span {
left: 0; left: 0;
} }
.plot td.bar.m div.tot span { }
}
&.m div {
right: 0;
border-radius: var(--radius) 0 0 var(--radius);
background: var(--red-1);
&.tot {
background: var(--red);
span {
right: 0; right: 0;
} }
}
@media (width < 720px) {
.plot .bar {
width: 0;
overflow: hidden;
} }
} }
.plot tfoot { &.history tbody tr {
background: initial;
}
tbody tr {
&.empty {
height: 0.5rem;
}
&.even {
background: #eeeeff;
}
}
tfoot {
background: var(--bg-01); background: var(--bg-01);
} }
}
.calendar {
overflow-x: auto;
margin-top: var(--gap);
font-feature-settings: var(--num);
table {
tbody tr {
background: initial;
&:not(:last-child) {
border-bottom: none;
}
&:not(:first-child) {
border-top: none;
}
td {
text-align: center;
background-color: color-mix(
in hsl,
var(--td-bg, var(--bg)) var(--opacity),
var(--bg)
);
&.p {
--td-bg: var(--green);
}
&.m {
--td-bg: var(--red);
}
}
}
}
}

View file

@ -1,29 +1,37 @@
.table, .table,
form { form {
overflow-x: auto; overflow-x: auto;
width: 100%;
} }
table { table {
border-collapse: collapse; border-collapse: collapse;
}
table.more tbody:last-child tr:last-child { &.full-width {
border-bottom: 0.1rem dashed var(--gray);
}
table.full-width {
width: 100%; width: 100%;
}
thead { col {
background: var(--bg-01);
}
table.full-width col {
width: 8rem; width: 8rem;
} }
table col.icon { }
col.icon {
width: 1ch; width: 1ch;
} }
thead tr:not(.new) {
background: var(--bg-01);
}
tr { tr {
border: 0.1rem solid var(--gray); border: 1px solid var(--gray);
height: 2rem; height: 2rem;
line-height: 2rem; line-height: 2rem;
tbody &:where(:nth-of-type(even)) {
background: #eeeeff;
}
&.more,
&.new {
text-align: center;
border-style: dashed;
}
} }
td, td,
th { th {
@ -31,7 +39,14 @@ th {
position: relative; position: relative;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
&.empty {
text-align: center;
opacity: 0.8;
font-weight: 300;
} }
}
}
.date, .date,
.value { .value {
font-feature-settings: var(--num); font-feature-settings: var(--num);
@ -47,8 +62,3 @@ th {
.date { .date {
text-align: center; text-align: center;
} }
td.empty {
text-align: center;
opacity: 0.8;
font-weight: 300;
}

View file

@ -1,17 +1,17 @@
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% load main_extras %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1" /> <meta name="viewport" content="width=device-width,initial-scale=1">
<title> <title>
{% block title %}Nummi{% endblock %} {% block title %}Nummi{% endblock %}
</title> </title>
{% block link %} {% block link %}
<link rel="icon" href="{% static "main/svg/logo.svg" %}" type="image/svg+xml" /> <link rel="icon" href="{% static "main/svg/logo.svg" %}" type="image/svg+xml">
<link rel="stylesheet" href="{% static "main/css/main.css" %}" type="text/css" /> {% css "main/css/main.css" %}
<link rel="stylesheet" href="{% static "main/remixicon/remixicon.css" %}" type="text/css" />
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
@ -19,7 +19,7 @@
{% spaceless %} {% spaceless %}
<nav> <nav>
<h1> <h1>
<img src="{% static "main/svg/logo.svg" %}" alt="" /> <img src="{% static "main/svg/logo.svg" %}" alt="">
Nummi Nummi
</h1> </h1>
<ul> <ul>
@ -30,60 +30,52 @@
<li> <li>
<a href="{% url "index" %}" <a href="{% url "index" %}"
class="home{% if request.resolver_match.url_name == "index" %} cur{% endif %}" class="home{% if request.resolver_match.url_name == "index" %} cur{% endif %}"
accesskey="h">{% translate "Home" %}</a> accesskey="h">
<span>{% translate "Home" %}</span>
{{ "home"|remix }}
</a>
</li> </li>
<li> <li>
<a href="{% url "statements" %}" <a href="{% url "statements" %}"
class="{% if request.resolver_match.url_name == "statements" %}cur{% endif %}"> class="{% if request.resolver_match.url_name == "statements" %}cur{% endif %}">
{% translate "Statements" %} <span>{% translate "Statements" %}</span>
{{ "file"|remix }}
</a> </a>
</li> </li>
<li> <li>
<a href="{% url "transactions" %}" <a href="{% url "transactions" %}"
class="{% if request.resolver_match.url_name == "transactions" %}cur{% endif %}"> class="{% if request.resolver_match.url_name == "transactions" %}cur{% endif %}">
{% translate "Transactions" %} <span>{% translate "Transactions" %}</span>
{{ "receipt"|remix }}
</a> </a>
</li> </li>
<li>
<a href="{% url "new_account" %}"
class="{% if request.resolver_match.url_name == "new_account" %}cur{% endif %}"
accesskey="a">{% translate "Create account" %}</a>
</li>
<li>
<a href="{% url "new_statement" %}"
class="{% if request.resolver_match.url_name == "new_statement" %}cur{% endif %}"
accesskey="s">{% translate "Create statement" %}</a>
</li>
<li>
<a href="{% url "new_category" %}"
class="{% if request.resolver_match.url_name == "new_category" %}cur{% endif %}"
accesskey="c">{% translate "Create category" %}</a>
</li>
<li>
<a href="{% url "new_transaction" %}"
class="{% if request.resolver_match.url_name == "new_transaction" %}cur{% endif %}"
accesskey="t">{% translate "Create transaction" %}</a>
</li>
<li> <li>
<a href="{% url "search" %}" <a href="{% url "search" %}"
class="{% if request.resolver_match.url_name == "search" %}cur{% endif %}" class="{% if request.resolver_match.url_name == "search" %}cur{% endif %}"
accesskey="r">{% translate "Search" %}</a> accesskey="r">
<span>{% translate "Search" %}</span>
{{ "search"|remix }}
</a>
</li> </li>
<li> <li>
<a href="{% url "logout" %}" accesskey="l">{% translate "Log out" %}</a> {% blocktranslate %}Logged in as <strong>{{ user }}</strong>{% endblocktranslate %}
</li>
<li>
<a href="{% url "logout" %}" accesskey="l">
<span>{% translate "Log out" %}</span>
{{ "close-circle"|remix }}
</a>
</li> </li>
{% else %} {% else %}
<li> <li>
<a {% if request.resolver_match.url_name == "login" %}class="cur"{% endif %} <a {% if request.resolver_match.url_name == "login" %}class="cur"{% endif %}
href="{% url "login" %}">{% translate "Log in" %}</a> href="{% url "login" %}">
<span>{% translate "Log in" %}</span>
{{ "user"|remix }}
</a>
</li> </li>
{% endif %} {% endif %}
</ul> </ul>
{% if user.is_authenticated %}
<p>
{% blocktranslate %}Logged in as <strong>{{ user }}</strong>{% endblocktranslate %}
</p>
{% endif %}
</nav> </nav>
{% endspaceless %} {% endspaceless %}
{% endblock %} {% endblock %}

View file

@ -4,12 +4,8 @@
{% load i18n %} {% load i18n %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/form.css" %}
href="{% static 'main/css/form.css' %}" {% css "main/css/table.css" %}
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% spaceless %} {% spaceless %}

View file

@ -12,15 +12,9 @@
{% endblock %} {% endblock %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/form.css" %}
href="{% static 'main/css/form.css' %}" {% css "main/css/table.css" %}
type="text/css" /> {% css "main/css/plot.css" %}
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% with instance=form.instance %} {% with instance=form.instance %}
@ -36,7 +30,7 @@
{% block pre %}{% endblock %} {% block pre %}{% endblock %}
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
{% if instance|adding %}<input hidden name="next" value="{{ request.path }}" />{% endif %} {% if instance|adding %}<input hidden name="next" value="{{ request.path }}">{% endif %}
{{ form }} {{ form }}
</form> </form>
{% block tables %}{% endblock %} {% block tables %}{% endblock %}

View file

@ -29,11 +29,11 @@
{% if not form.instance|adding %} {% if not form.instance|adding %}
<a class="del" href="{{ form.instance.get_delete_url }}">{% translate "Delete" %}</a> <a class="del" href="{{ form.instance.get_delete_url }}">{% translate "Delete" %}</a>
{% endif %} {% endif %}
<input type="reset" value="{% translate "Reset" %}" /> <input type="reset" value="{% translate "Reset" %}">
{% if form.instance|adding %} {% if form.instance|adding %}
<input type="submit" value="{% translate "Create" %}" /> <input type="submit" value="{% translate "Create" %}">
{% else %} {% else %}
<input type="submit" value="{% translate "Save" %}" /> <input type="submit" value="{% translate "Save" %}">
{% endif %} {% endif %}
{% endblock %} {% endblock %}
</td> </td>

View file

@ -1,7 +1,7 @@
{% extends "main/form/form_base.html" %} {% extends "main/form/form_base.html" %}
{% load i18n %} {% load i18n %}
{% block buttons %} {% block buttons %}
<input hidden value="{{ next }}" name="next" /> <input hidden value="{{ next }}" name="next">
<input type="reset" /> <input type="reset">
<input type="submit" value="{% translate "Log in" %}" /> <input type="submit" value="{% translate "Log in" %}">
{% endblock %} {% endblock %}

View file

@ -4,44 +4,66 @@
{% load i18n %} {% load i18n %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/table.css" %}
href="{% static 'main/css/table.css' %}" {% css "main/css/plot.css" %}
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<div class="split">
<section class="accounts">
<h2>{% translate "Accounts" %}</h2> <h2>{% translate "Accounts" %}</h2>
<p> <div class="table">
<table>
<thead>
<tr>
<th colspan="2">{% translate "Account" %}</th>
<th>{% translate "Balance" %}</th>
<th>{% translate "Edit" %}</th>
</tr>
</thead>
<tbody>
{% for acc in accounts %} {% for acc in accounts %}
<a class="big-link" href="{{ acc.get_absolute_url }}">{{ acc.icon|remix }}{{ acc }}</a> <tr>
<td>{{ acc.icon|remix }}</td>
<th class="l">
<a href="{{ acc.get_absolute_url }}">{{ acc }}</a>
</th>
<td class="value">{{ acc.statement_set.first.value|value }}</td>
<td>
<a href="{% url "edit_account" acc.pk %}">{% translate "Edit" %}</a>
</td>
</tr>
{% empty %} {% empty %}
{% translate "No account" %} <tr>
<td class="empty" colspan="4">{% translate "No account" %}</td>
</tr>
{% endfor %} {% endfor %}
</p> </tbody>
{% if transactions %} <tfoot>
<h2>{% translate "Transactions" %}</h2> <tr class="new">
{% include "transaction/transaction_table.html" %} <td colspan="4">
{% endif %} <a href="{% url "new_account" %}">{% translate "Create account" %}</a>
{% if categories %} </td>
</tr>
</tfoot>
</table>
</div>
</section>
<section class="categories">
<h2>{% translate "Categories" %}</h2> <h2>{% translate "Categories" %}</h2>
{% spaceless %} {% spaceless %}
<p> <p>
{% for cat in categories %} {% for cat in categories %}
<a class="big-link" href="{{ cat.get_absolute_url }}">{{ cat.icon|remix }}{{ cat }}</a> <a class="big-link" href="{{ cat.get_absolute_url }}">{{ cat.icon|remix }}{{ cat }}</a>
{% empty %}
{% translate "No category" %}
{% endfor %} {% endfor %}
<a class="big-link add" href="{% url "new_category" %}">{{ "add"|remix }}{% translate "Create category" %}</a>
</p> </p>
{% endspaceless %} {% endspaceless %}
{% endif %} </section>
{% if statements %} </div>
<h2>{% translate "Statements" %}</h2> {% if history %}
{% include "statement/statement_table.html" %} <section>
{% endif %}
{% if history.data %}
<h2>{% translate "History" %}</h2> <h2>{% translate "History" %}</h2>
{% include "history/plot.html" %} {% include "history/plot.html" %}
</section>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View file

@ -13,14 +13,15 @@
{% endblock %} {% endblock %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/table.css" %}
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2> <h2>
{% block h2 %}{% endblock %} {% block h2 %}{% endblock %}
</h2> </h2>
{% if account or category or search %}
<div class="backlinks">
{% block backlinks %}
{% if account %} {% if account %}
<p> <p>
<a class="big-link" href="{{ account.get_absolute_url }}">{{ account.icon|remix }}{{ account }}</a> <a class="big-link" href="{{ account.get_absolute_url }}">{{ account.icon|remix }}{{ account }}</a>
@ -36,6 +37,9 @@
<a href="{% url "search" %}">{% translate "Search" %}</a> <a href="{% url "search" %}">{% translate "Search" %}</a>
</p> </p>
{% endif %} {% endif %}
{% endblock %}
</div>
{% endif %}
{% include "main/pagination.html" %} {% include "main/pagination.html" %}
{% block table %}{% endblock %} {% block table %}{% endblock %}
{% include "main/pagination.html" %} {% include "main/pagination.html" %}

View file

@ -1,14 +1,11 @@
{% extends "main/base.html" %} {% extends "main/base.html" %}
{% load main_extras %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/table.css" %}
href="{% static 'main/css/table.css' %}" {% css "main/css/form.css" %}
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2>{% translate "Log in" %}</h2> <h2>{% translate "Log in" %}</h2>

View file

@ -1,9 +1,32 @@
{% load i18n %} {% load i18n transaction_extras %}
{% if page_obj %} {% if page_obj %}
<p id="pagination"> <p class="pagination">
{% for page in paginator.page_range %} {% for page in paginator.page_range %}
<a href="?page={{ page }}" <a href="?page={{ page }}"
{% if page == page_obj.number %}class="cur"{% endif %}>{{ page }}</a> {% if page == page_obj.number %}class="cur"{% endif %}>{{ page }}</a>
{% endfor %} {% endfor %}
</p> </p>
{% endif %} {% endif %}
{% if month %}
<p class="pagination">{% year_url month %}</p>
<p class="pagination n3">
{% if previous_month %}
{% month_url previous_month fmt="F Y" %}
{% endif %}
{% month_url month cls="cur" fmt="F Y" %}
{% if next_month %}
{% month_url next_month fmt="F Y" %}
{% endif %}
</p>
{% endif %}
{% if year %}
<p class="pagination n3">
{% if previous_year %}
{% year_url previous_year cls="prev" %}
{% endif %}
{% year_url year cls="cur" %}
{% if next_year %}
{% year_url next_year cls="next" %}
{% endif %}
</p>
{% endif %}

View file

@ -1,4 +1,5 @@
from django import template from django import template
from django.templatetags.static import static
from django.utils import formats from django.utils import formats
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
@ -7,16 +8,16 @@ register = template.Library()
@register.filter @register.filter
def value(val, pm=False, r=2): def value(val, pm=False, r=2):
if not val: if val is None:
return "" return ""
_prefix = "" _prefix = ""
_suffix = "&nbsp;€" _suffix = "&nbsp;€"
_val = formats.number_format(round(val, r), r, use_l10n=True, force_grouping=True) _val = formats.number_format(val, decimal_pos=r, use_l10n=True, force_grouping=True)
if val > 0: if val > 0:
if pm: if pm:
_prefix += "&plus;&nbsp;" _prefix += "&plus;&nbsp;"
else: elif val < 0:
_val = _val[1:] _val = _val[1:]
_prefix += "&minus;&nbsp;" _prefix += "&minus;&nbsp;"
@ -38,14 +39,6 @@ def remix(icon, cls=""):
return mark_safe(f"""<span class="ri-{icon}-line {cls}"></span>""") return mark_safe(f"""<span class="ri-{icon}-line {cls}"></span>""")
@register.filter
def check(sum, diff):
if sum == diff:
return remix("check", "green")
else:
return remix("close", "red")
@register.filter @register.filter
def extension(file): def extension(file):
return file.name.split(".")[-1].upper() return file.name.split(".")[-1].upper()
@ -59,3 +52,10 @@ def verbose_name(obj):
@register.filter @register.filter
def adding(obj): def adding(obj):
return obj._state.adding return obj._state.adding
@register.simple_tag
def css(href):
return mark_safe(
f"""<link rel="stylesheet" href="{static(href)}" type="text/css">"""
)

View file

@ -9,6 +9,7 @@ from django.utils.translation import gettext as _
from django.views.generic import ( from django.views.generic import (
CreateView, CreateView,
DeleteView, DeleteView,
DetailView,
ListView, ListView,
TemplateView, TemplateView,
UpdateView, UpdateView,
@ -76,6 +77,10 @@ class NummiUpdateView(UserMixin, UpdateView):
pass pass
class NummiDetailView(UserMixin, DetailView):
pass
class NummiDeleteView(UserMixin, DeleteView): class NummiDeleteView(UserMixin, DeleteView):
template_name = "main/confirm_delete.html" template_name = "main/confirm_delete.html"
success_url = reverse_lazy("index") success_url = reverse_lazy("index")

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-22 15:16+0200\n" "POT-Creation-Date: 2024-01-02 15:52+0100\n"
"PO-Revision-Date: 2023-04-22 15:20+0200\n" "PO-Revision-Date: 2023-04-22 15:20+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n" "Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n" "Language-Team: \n"
@ -18,7 +18,7 @@ msgstr ""
"X-Generator: Poedit 3.2.2\n" "X-Generator: Poedit 3.2.2\n"
#: .\search\forms.py:7 .\search\templates\search\search.html:6 #: .\search\forms.py:7 .\search\templates\search\search.html:6
#: .\search\templates\search\search.html:18 #: .\search\templates\search\search.html:14
#: .\search\templates\search\search_form.html:5 #: .\search\templates\search\search_form.html:5
msgid "Search" msgid "Search"
msgstr "Rechercher" msgstr "Rechercher"

View file

@ -7,12 +7,8 @@
{% endblock %} {% endblock %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/form.css" %}
href="{% static 'main/css/form.css' %}" {% css "main/css/table.css" %}
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2>{% translate "Search" %}</h2> <h2>{% translate "Search" %}</h2>

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-25 12:05+0100\n" "POT-Creation-Date: 2024-01-03 15:51+0100\n"
"PO-Revision-Date: 2023-04-22 15:22+0200\n" "PO-Revision-Date: 2023-04-22 15:22+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n" "Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n" "Language-Team: \n"
@ -38,7 +38,7 @@ msgid "Start value"
msgstr "Valeur initiale" msgstr "Valeur initiale"
#: .\statement\models.py:29 #: .\statement\models.py:29
#: .\statement\templates\statement\statement_table.html:27 #: .\statement\templates\statement\statement_table.html:30
msgid "Difference" msgid "Difference"
msgstr "Différence" msgstr "Différence"
@ -66,7 +66,7 @@ msgid "Statements"
msgstr "Relevés" msgstr "Relevés"
#: .\statement\templates\statement\statement_form.html:4 #: .\statement\templates\statement\statement_form.html:4
#: .\statement\templates\statement\statement_table.html:5 #: .\statement\templates\statement\statement_table.html:18
msgid "Create statement" msgid "Create statement"
msgstr "Créer un relevé" msgstr "Créer un relevé"
@ -74,32 +74,32 @@ msgstr "Créer un relevé"
msgid "New statement" msgid "New statement"
msgstr "Nouveau relevé" msgstr "Nouveau relevé"
#: .\statement\templates\statement\statement_form.html:22 #: .\statement\templates\statement\statement_form.html:23
msgid "Categories" msgid "Categories"
msgstr "Catégories" msgstr "Catégories"
#: .\statement\templates\statement\statement_form.html:24 #: .\statement\templates\statement\statement_form.html:27
#: .\statement\templates\statement\statement_table.html:28 #: .\statement\templates\statement\statement_table.html:31
msgid "Transactions" msgid "Transactions"
msgstr "Transactions" msgstr "Transactions"
#: .\statement\templates\statement\statement_table.html:22 #: .\statement\templates\statement\statement_table.html:25
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
#: .\statement\templates\statement\statement_table.html:24 #: .\statement\templates\statement\statement_table.html:27
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
#: .\statement\templates\statement\statement_table.html:26 #: .\statement\templates\statement\statement_table.html:29
msgid "Value" msgid "Value"
msgstr "Valeur" msgstr "Valeur"
#: .\statement\templates\statement\statement_table.html:56 #: .\statement\templates\statement\statement_table.html:62
msgid "No statement" msgid "No statement"
msgstr "Aucun relevé" msgstr "Aucun relevé"
#: .\statement\templates\statement\statement_table.html:64 #: .\statement\templates\statement\statement_table.html:70
msgid "View all statements" msgid "View all statements"
msgstr "Voir tous les relevés" msgstr "Voir tous les relevés"

View file

@ -1,15 +1,12 @@
{% extends "main/form/base.html" %} {% extends "main/form/base.html" %}
{% load i18n main_extras category %} {% load i18n main_extras statement_extras category %}
{% block title_new %} {% block title_new %}
{% translate "Create statement" %} {% translate "Create statement" %}
{% endblock %} {% endblock %}
{% block h2_new %} {% block h2_new %}
{% translate "New statement" %} {% translate "New statement" %}
{% endblock %} {% endblock %}
{% block h2 %} {% block h2 %}{{ form.instance }}{% endblock %}
{{ form.instance.sum|check:form.instance.diff }}
{{ form.instance }}
{% endblock %}
{% block pre %} {% block pre %}
{% if account %} {% if account %}
<p> <p>
@ -19,9 +16,13 @@
{% endblock %} {% endblock %}
{% block tables %} {% block tables %}
{% if not form.instance|adding %} {% if not form.instance|adding %}
<section>
<h3>{% translate "Categories" %}</h3> <h3>{% translate "Categories" %}</h3>
{% category_plot transactions %} {% category_plot transactions budget=False statement=object %}
<h3>{% translate "Transactions" %} ({{ form.instance.sum|pmvalue }} / {{ form.instance.diff|pmvalue }})</h3> </section>
<section>
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %} {% include "transaction/transaction_table.html" %}
</section>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View file

@ -7,5 +7,6 @@
{% translate "Statements" %} {% translate "Statements" %}
{% endblock %} {% endblock %}
{% block table %} {% block table %}
{% url "new_statement" as new_statement_url %}
{% include "statement/statement_table.html" %} {% include "statement/statement_table.html" %}
{% endblock %} {% endblock %}

View file

@ -1,10 +1,4 @@
{% load main_extras %} {% load i18n main_extras statement_extras %}
{% load i18n %}
{% if new_statement_url %}
<p>
<a href="{{ new_statement_url }}">{% translate "Create statement" %}</a>
</p>
{% endif %}
<div id="statements" class="table"> <div id="statements" class="table">
<table class="full-width {% if statements_url %}more{% endif %}"> <table class="full-width {% if statements_url %}more{% endif %}">
<colgroup> <colgroup>
@ -17,6 +11,14 @@
<col class="value" span="3"> <col class="value" span="3">
</colgroup> </colgroup>
<thead> <thead>
{% if new_statement_url %}
<tr class="new">
<td colspan="{% if account %}6{% else %}8{% endif %}">
<a href="{{ new_statement_url }}">{% translate "Create statement" %}</a>
</td>
</tr>
{% endif %}
<tr>
<th>{{ "check"|remix }}</th> <th>{{ "check"|remix }}</th>
<th>{{ "attachment"|remix }}</th> <th>{{ "attachment"|remix }}</th>
<th>{% translate "Date" %}</th> <th>{% translate "Date" %}</th>
@ -26,20 +28,19 @@
<th>{% translate "Value" %}</th> <th>{% translate "Value" %}</th>
<th>{% translate "Difference" %}</th> <th>{% translate "Difference" %}</th>
<th>{% translate "Transactions" %}</th> <th>{% translate "Transactions" %}</th>
</tr>
</thead> </thead>
<tbody> <tbody>
{% for snap in statements %} {% for snap in statements %}
<tr> <tr>
{% if snap.sum == snap.diff %} <td class="c">{{ snap.sum|check:snap.diff }}</td>
<td class="c green">{{ "check"|remix }}</td>
{% else %}
<td class="c red">{{ "close"|remix }}</td>
{% endif %}
<td class="c"> <td class="c">
{% if snap.file %}<a href="{{ snap.file.url }}">{{ "attachment"|remix }}</a>{% endif %} {% if snap.file %}<a href="{{ snap.file.url }}">{{ "attachment"|remix }}</a>{% endif %}
</td> </td>
<th class="date" scope="row"> <th class="date" scope="row">
<a href="{{ snap.get_absolute_url }}">{{ snap.date|date:"Y-m-d" }}</a> <a href="{{ snap.get_absolute_url }}">
<time datetime="{{ snap.date|date:"Y-m-d" }}">{{ snap.date|date:"Y-m-d" }}</time>
</a>
</th> </th>
{% if not account %} {% if not account %}
<td class="r">{{ snap.account.icon|remix }}</td> <td class="r">{{ snap.account.icon|remix }}</td>
@ -57,10 +58,14 @@
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
{% if statements_url %}
<tfoot>
<tr class="more">
<td colspan="{% if account %}6{% else %}8{% endif %}">
<a href="{{ statements_url }}">{% translate "View all statements" %}</a>
</td>
</tr>
</tfoot>
{% endif %}
</table> </table>
</div> </div>
{% if statements_url %}
<p>
<a href="{{ statements_url }}">{% translate "View all statements" %}</a>
</p>
{% endif %}

View file

@ -0,0 +1,14 @@
from django import template
from main.templatetags.main_extras import remix
register = template.Library()
@register.filter
def check(s, diff):
if s is None:
s = 0
if s == diff:
return remix("check", "green")
else:
return remix("close", "red")

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-25 12:05+0100\n" "POT-Creation-Date: 2024-01-03 15:51+0100\n"
"PO-Revision-Date: 2023-04-23 08:03+0200\n" "PO-Revision-Date: 2023-04-23 08:03+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n" "Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n" "Language-Team: \n"
@ -22,8 +22,8 @@ msgid "Transaction"
msgstr "Transaction" msgstr "Transaction"
#: .\transaction\models.py:19 .\transaction\models.py:89 #: .\transaction\models.py:19 .\transaction\models.py:89
#: .\transaction\templates\transaction\invoice_table.html:9 #: .\transaction\templates\transaction\invoice_table.html:10
#: .\transaction\templates\transaction\transaction_table.html:28 #: .\transaction\templates\transaction\transaction_table.html:32
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
@ -32,12 +32,11 @@ msgid "Description"
msgstr "Description" msgstr "Description"
#: .\transaction\models.py:23 #: .\transaction\models.py:23
#: .\transaction\templates\transaction\transaction_table.html:29
msgid "Value" msgid "Value"
msgstr "Valeur" msgstr "Valeur"
#: .\transaction\models.py:25 #: .\transaction\models.py:25
#: .\transaction\templates\transaction\transaction_table.html:27 #: .\transaction\templates\transaction\transaction_table.html:31
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
@ -46,7 +45,7 @@ msgid "Real date"
msgstr "Date réelle" msgstr "Date réelle"
#: .\transaction\models.py:28 #: .\transaction\models.py:28
#: .\transaction\templates\transaction\transaction_table.html:30 #: .\transaction\templates\transaction\transaction_table.html:35
msgid "Trader" msgid "Trader"
msgstr "Commerçant" msgstr "Commerçant"
@ -55,7 +54,7 @@ msgid "Payment"
msgstr "Paiement" msgstr "Paiement"
#: .\transaction\models.py:38 #: .\transaction\models.py:38
#: .\transaction\templates\transaction\transaction_table.html:32 #: .\transaction\templates\transaction\transaction_table.html:37
msgid "Category" msgid "Category"
msgstr "Catégorie" msgstr "Catégorie"
@ -64,12 +63,13 @@ msgid "Statement"
msgstr "Relevé" msgstr "Relevé"
#: .\transaction\models.py:48 #: .\transaction\models.py:48
#: .\transaction\templates\transaction\transaction_table.html:35 #: .\transaction\templates\transaction\transaction_table.html:40
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
#: .\transaction\models.py:83 #: .\transaction\models.py:83
#: .\transaction\templates\transaction\transaction_archive_month.html:11 #: .\transaction\templates\transaction\transaction_archive_month.html:27
#: .\transaction\templates\transaction\transaction_archive_year.html:31
#: .\transaction\templates\transaction\transaction_list.html:4 #: .\transaction\templates\transaction\transaction_list.html:4
#: .\transaction\templates\transaction\transaction_list.html:7 #: .\transaction\templates\transaction\transaction_list.html:7
msgid "Transactions" msgid "Transactions"
@ -80,18 +80,18 @@ msgid "Invoice"
msgstr "Facture" msgstr "Facture"
#: .\transaction\models.py:94 #: .\transaction\models.py:94
#: .\transaction\templates\transaction\invoice_table.html:10 #: .\transaction\templates\transaction\invoice_table.html:11
#: .\transaction\templates\transaction\invoice_table.html:20 #: .\transaction\templates\transaction\invoice_table.html:22
msgid "File" msgid "File"
msgstr "Fichier" msgstr "Fichier"
#: .\transaction\models.py:123 #: .\transaction\models.py:123
#: .\transaction\templates\transaction\transaction_form.html:19 #: .\transaction\templates\transaction\transaction_form.html:20
msgid "Invoices" msgid "Invoices"
msgstr "Factures" msgstr "Factures"
#: .\transaction\templates\transaction\invoice_form.html:4 #: .\transaction\templates\transaction\invoice_form.html:4
#: .\transaction\templates\transaction\invoice_table.html:35 #: .\transaction\templates\transaction\invoice_table.html:37
msgid "Create invoice" msgid "Create invoice"
msgstr "Créer une facture" msgstr "Créer une facture"
@ -99,21 +99,31 @@ msgstr "Créer une facture"
msgid "New invoice" msgid "New invoice"
msgstr "Nouvelle facture" msgstr "Nouvelle facture"
#: .\transaction\templates\transaction\invoice_table.html:11 #: .\transaction\templates\transaction\invoice_table.html:12
#: .\transaction\templates\transaction\invoice_table.html:23 #: .\transaction\templates\transaction\invoice_table.html:25
msgid "Delete" msgid "Delete"
msgstr "Supprimer" msgstr "Supprimer"
#: .\transaction\templates\transaction\invoice_table.html:28 #: .\transaction\templates\transaction\invoice_table.html:30
msgid "No invoice" msgid "No invoice"
msgstr "Aucune facture" msgstr "Aucune facture"
#: .\transaction\templates\transaction\transaction_archive_month.html:14 #: .\transaction\templates\transaction\transaction_archive_month.html:14
#: .\transaction\templates\transaction\transaction_archive_year.html:13
msgid "Back"
msgstr "Retour"
#: .\transaction\templates\transaction\transaction_archive_month.html:22
#: .\transaction\templates\transaction\transaction_archive_year.html:26
msgid "Categories" msgid "Categories"
msgstr "Catégories" msgstr "Catégories"
#: .\transaction\templates\transaction\transaction_archive_year.html:20
msgid "History"
msgstr "Historique"
#: .\transaction\templates\transaction\transaction_form.html:5 #: .\transaction\templates\transaction\transaction_form.html:5
#: .\transaction\templates\transaction\transaction_table.html:5 #: .\transaction\templates\transaction\transaction_table.html:25
msgid "Create transaction" msgid "Create transaction"
msgstr "Créer une transaction" msgstr "Créer une transaction"
@ -121,10 +131,18 @@ msgstr "Créer une transaction"
msgid "New transaction" msgid "New transaction"
msgstr "Nouvelle transaction" msgstr "Nouvelle transaction"
#: .\transaction\templates\transaction\transaction_table.html:71 #: .\transaction\templates\transaction\transaction_table.html:33
msgid "Expenses"
msgstr "Dépenses"
#: .\transaction\templates\transaction\transaction_table.html:34
msgid "Income"
msgstr "Recettes"
#: .\transaction\templates\transaction\transaction_table.html:87
msgid "No transaction" msgid "No transaction"
msgstr "Aucune transaction" msgstr "Aucune transaction"
#: .\transaction\templates\transaction\transaction_table.html:80 #: .\transaction\templates\transaction\transaction_table.html:95
msgid "View all transactions" msgid "View all transactions"
msgstr "Voir toutes les transactions" msgstr "Voir toutes les transactions"

View file

@ -6,9 +6,11 @@
<col class="desc" span="3"> <col class="desc" span="3">
</colgroup> </colgroup>
<thead> <thead>
<tr>
<th>{% translate "Name" %}</th> <th>{% translate "Name" %}</th>
<th>{% translate "File" %}</th> <th>{% translate "File" %}</th>
<th>{% translate "Delete" %}</th> <th>{% translate "Delete" %}</th>
</tr>
</thead> </thead>
<tbody> <tbody>
{% for invoice in transaction.invoices %} {% for invoice in transaction.invoices %}
@ -20,7 +22,7 @@
<a href="{{ invoice.file.url }}">{% translate "File" %} [{{ invoice.file|extension }}]</a> <a href="{{ invoice.file.url }}">{% translate "File" %} [{{ invoice.file|extension }}]</a>
</td> </td>
<td> <td>
<a href="{{ invoice.get_delete_url }}">{% translate "Delete" %} <a href="{{ invoice.get_delete_url }}">{% translate "Delete" %}</a>
</td> </td>
</tr> </tr>
{% empty %} {% empty %}
@ -30,7 +32,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr class="more">
<td colspan="3"> <td colspan="3">
<a href="{% url "new_invoice" transaction.pk %}">{% translate "Create invoice" %}</a> <a href="{% url "new_invoice" transaction.pk %}">{% translate "Create invoice" %}</a>
</td> </td>

View file

@ -1,17 +1,28 @@
{% extends "transaction/transaction_list.html" %} {% extends "transaction/transaction_list.html" %}
{% load i18n static category %} {% load i18n main_extras transaction_extras static category %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" {% css "main/css/plot.css" %}
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %} {% endblock %}
{% block name %}{{ month|date:"F Y"|capfirst }}{% endblock %}
{% block h2 %}{{ month|date:"F Y"|capfirst }}{% endblock %} {% block h2 %}{{ month|date:"F Y"|capfirst }}{% endblock %}
{% block table %} {% block backlinks %}
<h3>{% translate "Transactions" %}</h3>
{{ block.super }} {{ block.super }}
{% if not category %} {% if account or category %}
<h3>{% translate "Categories" %}</h3> <p class="back">
{% category_plot transactions month=month %} <a href="{% url "transaction_month" month.year month.month %}">{% translate "Back" %}{{ "arrow-go-back"|remix }}</a>
</p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block table %}
{% if not category %}
<section>
<h3>{% translate "Categories" %}</h3>
{% category_plot transactions month=month %}
</section>
{% endif %}
<section>
<h3>{% translate "Transactions" %}</h3>
{{ block.super }}
</section>
{% endblock %}

View file

@ -0,0 +1,34 @@
{% extends "transaction/transaction_list.html" %}
{% load i18n main_extras static category %}
{% block link %}
{{ block.super }}
{% css "main/css/plot.css" %}
{% endblock %}
{% block name %}{{ year|date:"Y" }}{% endblock %}
{% block h2 %}{{ year|date:"Y" }}{% endblock %}
{% block backlinks %}
{{ block.super }}
{% if account or category %}
<p class="back">
<a href="{% url "transaction_year" year.year %}">{% translate "Back" %}{{ "arrow-go-back"|remix }}</a>
</p>
{% endif %}
{% endblock %}
{% block table %}
{% if history %}
<section>
<h3>{% translate "History" %}</h3>
{% include "history/plot.html" %}
</section>
{% endif %}
{% if not category %}
<section>
<h3>{% translate "Categories" %}</h3>
{% category_plot transactions year=year %}
</section>
{% endif %}
<section>
<h3>{% translate "Transactions" %}</h3>
{{ block.super }}
</section>
{% endblock %}

View file

@ -8,15 +8,17 @@
{% translate "New transaction" %} {% translate "New transaction" %}
{% endblock %} {% endblock %}
{% block pre %} {% block pre %}
{% if snapshot %} {% if statement %}
<p> <p>
<a href="{{ snapshot.get_absolute_url }}">{{ snapshot }}</a> <a href="{{ statement.get_absolute_url }}">{{ statement }}</a>
</p> </p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block tables %} {% block tables %}
{% if not form.instance|adding %} {% if not form.instance|adding %}
<section>
<h3>{% translate "Invoices" %}</h3> <h3>{% translate "Invoices" %}</h3>
{% include "transaction/invoice_table.html" %} {% include "transaction/invoice_table.html" %}
</section>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View file

@ -7,5 +7,6 @@
{% translate "Transactions" %} {% translate "Transactions" %}
{% endblock %} {% endblock %}
{% block table %} {% block table %}
{% url "new_transaction" as new_transaction_url %}
{% include "transaction/transaction_table.html" %} {% include "transaction/transaction_table.html" %}
{% endblock %} {% endblock %}

View file

@ -1,17 +1,13 @@
{% load main_extras %} {% load main_extras transaction_extras %}
{% load i18n %} {% load i18n %}
{% if new_transaction_url %}
<p>
<a href="{{ new_transaction_url }}">{% translate "Create transaction" %}</a>
</p>
{% endif %}
<div id="transactions" class="table"> <div id="transactions" class="table">
<table class="full-width {% if transactions_url %}more{% endif %}"> <table class="full-width">
<colgroup> <colgroup>
<col class="icon"> <col class="icon">
<col class="date"> <col class="date">
<col class="desc"> <col class="desc">
<col class="value"> <col class="value">
<col class="value">
<col class="desc"> <col class="desc">
{% if not category %} {% if not category %}
<col class="icon"> <col class="icon">
@ -23,10 +19,19 @@
{% endif %} {% endif %}
</colgroup> </colgroup>
<thead> <thead>
{% if new_transaction_url %}
<tr class="new">
<td colspan="{% tr_colspan %}">
<a href="{{ new_transaction_url }}">{% translate "Create transaction" %}</a>
</td>
</tr>
{% endif %}
<tr>
<th>{{ "attachment"|remix }}</th> <th>{{ "attachment"|remix }}</th>
<th>{% translate "Date" %}</th> <th>{% translate "Date" %}</th>
<th>{% translate "Name" %}</th> <th>{% translate "Name" %}</th>
<th>{% translate "Value" %}</th> <th>{% translate "Expenses" %}</th>
<th>{% translate "Income" %}</th>
<th>{% translate "Trader" %}</th> <th>{% translate "Trader" %}</th>
{% if not category %} {% if not category %}
<th colspan="2">{% translate "Category" %}</th> <th colspan="2">{% translate "Category" %}</th>
@ -34,6 +39,7 @@
{% if not account %} {% if not account %}
<th colspan="2">{% translate "Account" %}</th> <th colspan="2">{% translate "Account" %}</th>
{% endif %} {% endif %}
</tr>
</thead> </thead>
<tbody> <tbody>
{% for trans in transactions %} {% for trans in transactions %}
@ -41,11 +47,23 @@
<td class="c"> <td class="c">
{% for invoice in trans.invoices %}<a href="{{ invoice.file.url }}">{{ "attachment"|remix }}</a>{% endfor %} {% for invoice in trans.invoices %}<a href="{{ invoice.file.url }}">{{ "attachment"|remix }}</a>{% endfor %}
</td> </td>
<td class="date">{{ trans.date|date:"Y-m-d" }}</td> <td class="date">
<time datetime="{{ trans.date|date:"Y-m-d" }}">
{% if month %}
{{ trans.date|date:"l d"|capfirst }}
{% elif year %}
{{ trans.date|date:"d F" }}
{% else %}
{{ trans.date|date:"Y-m-d" }}
{% endif %}
</time>
</td>
<th scope="row" class="l"> <th scope="row" class="l">
<a href="{{ trans.get_absolute_url }}">{{ trans.name }}</a> <a href="{{ trans.get_absolute_url }}">{{ trans.name }}</a>
</th> </th>
{% if trans.value >= 0 %}<td></td>{% endif %}
<td class="value">{{ trans.value|pmvalue }}</td> <td class="value">{{ trans.value|pmvalue }}</td>
{% if trans.value < 0 %}<td></td>{% endif %}
<td>{{ trans.trader|default_if_none:"" }}</td> <td>{{ trans.trader|default_if_none:"" }}</td>
{% if not category %} {% if not category %}
{% if trans.category %} {% if trans.category %}
@ -66,17 +84,18 @@
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
<td class="empty" <td class="empty" colspan="{% tr_colspan %}">{% translate "No transaction" %}</td>
colspan="{% if category and account %}5{% elif category or account %}7{% else %}9{% endif %}">
{% translate "No transaction" %}
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
{% if transactions_url %}
<tfoot>
<tr class="more">
<td colspan="{% tr_colspan %}">
<a href="{{ transactions_url }}">{% translate "View all transactions" %}</a>
</td>
</tr>
</tfoot>
{% endif %}
</table> </table>
</div> </div>
{% if transactions_url %}
<p>
<a href="{{ transactions_url }}">{% translate "View all transactions" %}</a>
</p>
{% endif %}

View file

@ -0,0 +1,46 @@
import datetime
from django import template
from django.template.defaultfilters import date
from django.urls import reverse
from django.utils.safestring import mark_safe
from ..utils import ac_url
register = template.Library()
@register.simple_tag(takes_context=True)
def month_url(context, month, cls="", fmt="Y-m"):
url_name, url_params = ac_url(
"transaction_month", {"year": month.year, "month": month.month}, context
)
url = reverse(url_name, kwargs=url_params)
return mark_safe(
f"""<a class="{cls}" href="{url}"><time datetime="{date(month, "Y-m")}">"""
f"""{date(month, fmt).capitalize()}</time></a>"""
)
@register.simple_tag(takes_context=True)
def year_url(context, year, cls=""):
if isinstance(year, datetime.date):
year = year.year
url_name, url_params = ac_url("transaction_year", {"year": year}, context)
url = reverse(url_name, kwargs=url_params)
return mark_safe(
f"""<a class="{cls}" href="{url}">"""
f"""<time datetime="{year}">{year}</time></a>"""
)
@register.simple_tag(takes_context=True)
def tr_colspan(context):
ncol = 10
if context.get("category"):
ncol -= 2
if context.get("account"):
ncol -= 2
return ncol

View file

@ -4,6 +4,11 @@ from . import views
urlpatterns = [ urlpatterns = [
path("list", views.TransactionListView.as_view(), name="transactions"), path("list", views.TransactionListView.as_view(), name="transactions"),
path(
"history/<int:year>",
views.TransactionYearView.as_view(),
name="transaction_year",
),
path( path(
"history/<int:year>/<int:month>", "history/<int:year>/<int:month>",
views.TransactionMonthView.as_view(), views.TransactionMonthView.as_view(),

View file

@ -0,0 +1,9 @@
def ac_url(url_name, url_params, context):
if account := context.get("account"):
url_name = "account_" + url_name
url_params |= {"account": account.pk}
elif category := context.get("category"):
url_name = "category_" + url_name
url_params |= {"category": category.pk}
return url_name, url_params

View file

@ -2,7 +2,8 @@ from account.models import Account
from category.models import Category from category.models import Category
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.views.generic.dates import MonthArchiveView from django.views.generic.dates import MonthArchiveView, YearArchiveView
from history.utils import history
from main.views import ( from main.views import (
NummiCreateView, NummiCreateView,
NummiDeleteView, NummiDeleteView,
@ -109,11 +110,8 @@ class TransactionListView(NummiListView):
context_object_name = "transactions" context_object_name = "transactions"
class TransactionMonthView(UserMixin, MonthArchiveView): class TransactionACMixin:
model = Transaction model = Transaction
date_field = "date"
context_object_name = "transactions"
month_format = "%m"
def get_queryset(self): def get_queryset(self):
if "account" in self.kwargs: if "account" in self.kwargs:
@ -138,3 +136,25 @@ class TransactionMonthView(UserMixin, MonthArchiveView):
if "account" in self.kwargs: if "account" in self.kwargs:
return context_data | {"account": self.account} return context_data | {"account": self.account}
return context_data return context_data
class TransactionMonthView(UserMixin, TransactionACMixin, MonthArchiveView):
model = Transaction
date_field = "date"
context_object_name = "transactions"
month_format = "%m"
class TransactionYearView(UserMixin, TransactionACMixin, YearArchiveView):
model = Transaction
date_field = "date"
context_object_name = "transactions"
make_object_list = True
def get_context_data(self, **kwargs):
context_data = super().get_context_data(**kwargs)
h_data = context_data.get("transactions")
if not (context_data.get("account") or context_data.get("category")):
h_data = h_data.exclude(category__budget=False)
return context_data | {"history": history(h_data)}