Add first plot
This commit is contained in:
parent
3cf3cb649e
commit
e095d8d35f
11 changed files with 95 additions and 1 deletions
|
@ -194,7 +194,7 @@ class Snapshot(models.Model):
|
|||
@property
|
||||
def sum(self):
|
||||
if self.previous is None:
|
||||
return None
|
||||
return 0
|
||||
trans = self.transactions.aggregate(sum=models.Sum("value"))
|
||||
return trans["sum"] or 0
|
||||
|
||||
|
@ -206,6 +206,24 @@ class Snapshot(models.Model):
|
|||
date__lte=self.date, date__gt=self.previous.date
|
||||
)
|
||||
|
||||
@property
|
||||
def pos(self):
|
||||
return (
|
||||
self.transactions.filter(value__gt=0).aggregate(sum=models.Sum("value"))[
|
||||
"sum"
|
||||
]
|
||||
or 0
|
||||
)
|
||||
|
||||
@property
|
||||
def neg(self):
|
||||
return (
|
||||
self.transactions.filter(value__lt=0).aggregate(sum=models.Sum("value"))[
|
||||
"sum"
|
||||
]
|
||||
or 0
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-date"]
|
||||
verbose_name = _("Snapshot")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue