Forms update
Add transactions to snapshot Fix snapshot delete
This commit is contained in:
parent
ea9cd1b9b8
commit
0184cba30d
3 changed files with 59 additions and 19 deletions
|
@ -165,9 +165,10 @@ class Snapshot(AccountModel):
|
|||
self.sum = self.transaction_set.aggregate(sum=models.Sum("value")).get("sum", 0)
|
||||
super().save()
|
||||
|
||||
def delete(self, *args, only_super=False, **kwargs):
|
||||
def delete(self, *args, **kwargs):
|
||||
if self.file:
|
||||
self.file.delete()
|
||||
super().delete(*args, **kwargs)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("snapshot", kwargs={"pk": self.pk})
|
||||
|
@ -218,8 +219,10 @@ class Transaction(CustomModel):
|
|||
)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
prev_self = Transaction.objects.get(pk=self.pk)
|
||||
self.account = self.snapshot.account
|
||||
super().save(*args, **kwargs)
|
||||
prev_self.snapshot.update_sum()
|
||||
self.snapshot.update_sum()
|
||||
|
||||
def __str__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue