Add links to create snapshot in account, transaction in snapshot
This commit is contained in:
parent
6b54cc7546
commit
65a35b31f0
5 changed files with 51 additions and 12 deletions
|
@ -24,8 +24,8 @@
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.table > div.g> * {background: var(--bg-01)}
|
.table > div:nth-child(odd) > * {background: var(--bg-01)}
|
||||||
.table > div.w> * {background: var(--bg)}
|
.table > div:nth-child(even) > * {background: var(--bg)}
|
||||||
|
|
||||||
.table > div.header > * {
|
.table > div.header > * {
|
||||||
background: var(--theme);
|
background: var(--theme);
|
||||||
|
|
|
@ -10,8 +10,13 @@
|
||||||
<strong class="diff center">{% translate "Transactions" %}</strong>
|
<strong class="diff center">{% translate "Transactions" %}</strong>
|
||||||
<strong class="diff center">{% translate "Valid" %}</strong>
|
<strong class="diff center">{% translate "Valid" %}</strong>
|
||||||
</div>
|
</div>
|
||||||
|
{% if new_snapshot_url %}
|
||||||
|
<div class="full-line">
|
||||||
|
<a href="{{ new_snapshot_url }}">{% translate "New statement" %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% for snap in snapshots %}
|
{% for snap in snapshots %}
|
||||||
<div class="snapshot {% cycle 'w' 'g' %}">
|
<div class="snapshot">
|
||||||
<span class="attach center">
|
<span class="attach center">
|
||||||
{% if snap.file %}
|
{% if snap.file %}
|
||||||
<a href="{{ snap.file.url }}">
|
<a href="{{ snap.file.url }}">
|
||||||
|
@ -20,11 +25,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
<span class="date num center">
|
<span class="date num center">
|
||||||
<a href="{% url 'snapshot' snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
|
<a href="{% url 'snapshot' pk=snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
|
||||||
</span>
|
</span>
|
||||||
<span class="account text center">
|
<span class="account text center">
|
||||||
<i class="fa fa-{{ snap.account.icon }}"></i>
|
<i class="fa fa-{{ snap.account.icon }}"></i>
|
||||||
<a href="{% url 'account' snap.account.id %}">{{ snap.account }}</a>
|
<a href="{% url 'account' pk=snap.account.id %}">{{ snap.account }}</a>
|
||||||
</span>
|
</span>
|
||||||
<span class="value num right">{{ snap.value|value }}</span>
|
<span class="value num right">{{ snap.value|value }}</span>
|
||||||
<span class="diff num right">{{ snap.diff|pmvalue }}</span>
|
<span class="diff num right">{{ snap.diff|pmvalue }}</span>
|
||||||
|
@ -41,7 +46,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if snapshots_url %}
|
{% if snapshots_url %}
|
||||||
<div class="full-line {% cycle "w" "g" %}">
|
<div class="full-line">
|
||||||
<a href="{{ snapshots_url }}">{% translate "View all statements" %}</a>
|
<a href="{{ snapshots_url }}">{% translate "View all statements" %}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -11,8 +11,13 @@
|
||||||
<strong class="account center">{% translate "Account" %}</strong>
|
<strong class="account center">{% translate "Account" %}</strong>
|
||||||
<strong class="description">{% translate "Description" %}</strong>
|
<strong class="description">{% translate "Description" %}</strong>
|
||||||
</div>
|
</div>
|
||||||
|
{% if new_transaction_url %}
|
||||||
|
<div class="full-line">
|
||||||
|
<a href="{{ new_transaction_url }}">{% translate "New transaction" %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% for trans in transactions %}
|
{% for trans in transactions %}
|
||||||
<div class="transaction {% cycle 'w' 'g' %}">
|
<div class="transaction">
|
||||||
<span class="attach center">
|
<span class="attach center">
|
||||||
{% for invoice in trans.invoices %}
|
{% for invoice in trans.invoices %}
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
|
@ -23,13 +28,13 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</span>
|
</span>
|
||||||
<span class="date num center">{{ trans.date|date:"Y-m-d" }}</span>
|
<span class="date num center">{{ trans.date|date:"Y-m-d" }}</span>
|
||||||
<span class="name text"><a href="{% url 'transaction' trans.id %}">{{ trans.name }}</a></span>
|
<span class="name text"><a href="{% url 'transaction' pk=trans.id %}">{{ trans.name }}</a></span>
|
||||||
<span class="value num right">{{ trans.value|pmvalue }}</span>
|
<span class="value num right">{{ trans.value|pmvalue }}</span>
|
||||||
<span class="trader text center">{{ trans.trader|default_if_none:"–" }}</span>
|
<span class="trader text center">{{ trans.trader|default_if_none:"–" }}</span>
|
||||||
<span class="category text center">
|
<span class="category text center">
|
||||||
{% if trans.category %}
|
{% if trans.category %}
|
||||||
<i class="fa fa-{{ trans.category.icon }}"></i>
|
<i class="fa fa-{{ trans.category.icon }}"></i>
|
||||||
<a href="{% url 'category' trans.category.id %}">{{ trans.category }}</a>
|
<a href="{% url 'category' pk=trans.category.id %}">{{ trans.category }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
–
|
–
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -37,7 +42,7 @@
|
||||||
<span class="account text center">
|
<span class="account text center">
|
||||||
{% if trans.account %}
|
{% if trans.account %}
|
||||||
<i class="fa fa-{{ trans.account.icon }}"></i>
|
<i class="fa fa-{{ trans.account.icon }}"></i>
|
||||||
<a href="{% url 'account' trans.account.id %}">{{ trans.account }}</a>
|
<a href="{% url 'account' pk=trans.account.id %}">{{ trans.account }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
–
|
–
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -46,7 +51,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if transactions_url %}
|
{% if transactions_url %}
|
||||||
<div class="full-line {% cycle "w" "g" %}">
|
<div class="full-line">
|
||||||
<a href="{{ transactions_url }}">{% translate "View all transactions" %}</a>
|
<a href="{{ transactions_url }}">{% translate "View all transactions" %}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -28,6 +28,11 @@ urlpatterns = [
|
||||||
views.AccountSListView.as_view(),
|
views.AccountSListView.as_view(),
|
||||||
name="account_snapshots",
|
name="account_snapshots",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"account/<account>/snapshot",
|
||||||
|
views.SnapshotCreateView.as_view(),
|
||||||
|
name="snapshot",
|
||||||
|
),
|
||||||
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
||||||
path(
|
path(
|
||||||
"transaction/<transaction_pk>/invoice/<pk>",
|
"transaction/<transaction_pk>/invoice/<pk>",
|
||||||
|
@ -46,6 +51,11 @@ urlpatterns = [
|
||||||
views.SnapshotTListView.as_view(),
|
views.SnapshotTListView.as_view(),
|
||||||
name="snapshot_transactions",
|
name="snapshot_transactions",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"snapshot/<snapshot>/transaction",
|
||||||
|
views.TransactionCreateView.as_view(),
|
||||||
|
name="transaction",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"account/<pk>/delete",
|
"account/<pk>/delete",
|
||||||
views.AccountDeleteView.as_view(),
|
views.AccountDeleteView.as_view(),
|
||||||
|
|
|
@ -53,7 +53,6 @@ class UserFormMixin:
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
return super().get_form_kwargs() | {
|
return super().get_form_kwargs() | {
|
||||||
"user": self.request.user,
|
"user": self.request.user,
|
||||||
"initial": self.request.GET,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +89,13 @@ class TransactionCreateView(NummiCreateView):
|
||||||
model = Transaction
|
model = Transaction
|
||||||
form_class = TransactionForm
|
form_class = TransactionForm
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
return super().get_form_kwargs() | {
|
||||||
|
"initial": {
|
||||||
|
"snapshot": self.kwargs.get("snapshot"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class InvoiceCreateView(NummiCreateView):
|
class InvoiceCreateView(NummiCreateView):
|
||||||
model = Invoice
|
model = Invoice
|
||||||
|
@ -115,6 +121,13 @@ class SnapshotCreateView(NummiCreateView):
|
||||||
model = Snapshot
|
model = Snapshot
|
||||||
form_class = SnapshotForm
|
form_class = SnapshotForm
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
return super().get_form_kwargs() | {
|
||||||
|
"initial": {
|
||||||
|
"account": self.kwargs.get("account"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AccountUpdateView(NummiUpdateView):
|
class AccountUpdateView(NummiUpdateView):
|
||||||
model = Account
|
model = Account
|
||||||
|
@ -128,6 +141,9 @@ class AccountUpdateView(NummiUpdateView):
|
||||||
"transactions_url": reverse_lazy(
|
"transactions_url": reverse_lazy(
|
||||||
"account_transactions", args=(account.pk,)
|
"account_transactions", args=(account.pk,)
|
||||||
),
|
),
|
||||||
|
"new_snapshot_url": reverse_lazy(
|
||||||
|
"snapshot", kwargs={"account": account.pk}
|
||||||
|
),
|
||||||
"snapshots": account.snapshot_set.all()[:8],
|
"snapshots": account.snapshot_set.all()[:8],
|
||||||
"snapshots_url": reverse_lazy("account_snapshots", args=(account.pk,)),
|
"snapshots_url": reverse_lazy("account_snapshots", args=(account.pk,)),
|
||||||
}
|
}
|
||||||
|
@ -180,6 +196,9 @@ class SnapshotUpdateView(NummiUpdateView):
|
||||||
data = super().get_context_data(**kwargs)
|
data = super().get_context_data(**kwargs)
|
||||||
snapshot = data["form"].instance
|
snapshot = data["form"].instance
|
||||||
return data | {
|
return data | {
|
||||||
|
"new_transaction_url": reverse_lazy(
|
||||||
|
"transaction", kwargs={"snapshot": snapshot.pk}
|
||||||
|
),
|
||||||
"transactions": snapshot.transaction_set.all()[:8],
|
"transactions": snapshot.transaction_set.all()[:8],
|
||||||
"transactions_url": reverse_lazy(
|
"transactions_url": reverse_lazy(
|
||||||
"snapshot_transactions", args=(snapshot.pk,)
|
"snapshot_transactions", args=(snapshot.pk,)
|
||||||
|
|
Loading…
Reference in a new issue