diff --git a/nummi/main/static/main/css/table.css b/nummi/main/static/main/css/table.css index 5902d8d..e0121a0 100644 --- a/nummi/main/static/main/css/table.css +++ b/nummi/main/static/main/css/table.css @@ -24,8 +24,8 @@ padding: 1em; white-space: nowrap; } -.table > div.g> * {background: var(--bg-01)} -.table > div.w> * {background: var(--bg)} +.table > div:nth-child(odd) > * {background: var(--bg-01)} +.table > div:nth-child(even) > * {background: var(--bg)} .table > div.header > * { background: var(--theme); diff --git a/nummi/main/templates/main/table/snapshot.html b/nummi/main/templates/main/table/snapshot.html index 5a83c97..c5df7d6 100644 --- a/nummi/main/templates/main/table/snapshot.html +++ b/nummi/main/templates/main/table/snapshot.html @@ -10,8 +10,13 @@ {% translate "Transactions" %} {% translate "Valid" %} + {% if new_snapshot_url %} +
+ {% translate "New statement" %} +
+ {% endif %} {% for snap in snapshots %} -
+
{% if snap.file %} @@ -20,11 +25,11 @@ {% endif %} - {{ snap.date|date:"Y-m-d" }} + {{ snap.date|date:"Y-m-d" }} {{ snap.value|value }} {{ snap.diff|pmvalue }} @@ -41,7 +46,7 @@
{% endfor %} {% if snapshots_url %} -
+ {% endif %} diff --git a/nummi/main/templates/main/table/transaction.html b/nummi/main/templates/main/table/transaction.html index a4c4b9b..f988678 100644 --- a/nummi/main/templates/main/table/transaction.html +++ b/nummi/main/templates/main/table/transaction.html @@ -11,8 +11,13 @@ {% translate "Description" %}
+ {% if new_transaction_url %} +
+ {% translate "New transaction" %} +
+ {% endif %} {% for trans in transactions %} -
+
{% for invoice in trans.invoices %} {% spaceless %} @@ -23,13 +28,13 @@ {% endfor %} {{ trans.date|date:"Y-m-d" }} - {{ trans.name }} + {{ trans.name }} {{ trans.value|pmvalue }} {{ trans.trader|default_if_none:"–" }} {% if trans.category %} - {{ trans.category }} + {{ trans.category }} {% else %} – {% endif %} @@ -37,7 +42,7 @@
{% endfor %} {% if transactions_url %} -
+ {% endif %} diff --git a/nummi/main/urls.py b/nummi/main/urls.py index 48af125..c823a93 100644 --- a/nummi/main/urls.py +++ b/nummi/main/urls.py @@ -28,6 +28,11 @@ urlpatterns = [ views.AccountSListView.as_view(), name="account_snapshots", ), + path( + "account//snapshot", + views.SnapshotCreateView.as_view(), + name="snapshot", + ), path("transaction/", views.TransactionUpdateView.as_view(), name="transaction"), path( "transaction//invoice/", @@ -46,6 +51,11 @@ urlpatterns = [ views.SnapshotTListView.as_view(), name="snapshot_transactions", ), + path( + "snapshot//transaction", + views.TransactionCreateView.as_view(), + name="transaction", + ), path( "account//delete", views.AccountDeleteView.as_view(), diff --git a/nummi/main/views.py b/nummi/main/views.py index 73a3c74..c9dea90 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -53,7 +53,6 @@ class UserFormMixin: def get_form_kwargs(self): return super().get_form_kwargs() | { "user": self.request.user, - "initial": self.request.GET, } @@ -90,6 +89,13 @@ class TransactionCreateView(NummiCreateView): model = Transaction form_class = TransactionForm + def get_form_kwargs(self): + return super().get_form_kwargs() | { + "initial": { + "snapshot": self.kwargs.get("snapshot"), + }, + } + class InvoiceCreateView(NummiCreateView): model = Invoice @@ -115,6 +121,13 @@ class SnapshotCreateView(NummiCreateView): model = Snapshot form_class = SnapshotForm + def get_form_kwargs(self): + return super().get_form_kwargs() | { + "initial": { + "account": self.kwargs.get("account"), + }, + } + class AccountUpdateView(NummiUpdateView): model = Account @@ -128,6 +141,9 @@ class AccountUpdateView(NummiUpdateView): "transactions_url": reverse_lazy( "account_transactions", args=(account.pk,) ), + "new_snapshot_url": reverse_lazy( + "snapshot", kwargs={"account": account.pk} + ), "snapshots": account.snapshot_set.all()[:8], "snapshots_url": reverse_lazy("account_snapshots", args=(account.pk,)), } @@ -180,6 +196,9 @@ class SnapshotUpdateView(NummiUpdateView): data = super().get_context_data(**kwargs) snapshot = data["form"].instance return data | { + "new_transaction_url": reverse_lazy( + "transaction", kwargs={"snapshot": snapshot.pk} + ), "transactions": snapshot.transaction_set.all()[:8], "transactions_url": reverse_lazy( "snapshot_transactions", args=(snapshot.pk,)