Fix add transaction to empty statement bug
This commit is contained in:
parent
6563260b34
commit
08732b6ad4
1 changed files with 6 additions and 3 deletions
|
@ -32,9 +32,12 @@ class TransactionCreateView(NummiCreateView):
|
||||||
initial["statement"] = get_object_or_404(
|
initial["statement"] = get_object_or_404(
|
||||||
self.request.user.statement_set, pk=self.kwargs["statement"]
|
self.request.user.statement_set, pk=self.kwargs["statement"]
|
||||||
)
|
)
|
||||||
initial["date"] = (
|
if (
|
||||||
initial["statement"].transaction_set.order_by("-date").first().date
|
last_transaction := initial["statement"]
|
||||||
)
|
.transaction_set.order_by("-date")
|
||||||
|
.first()
|
||||||
|
):
|
||||||
|
initial["date"] = last_transaction.date
|
||||||
|
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue