From 0a22f816dd33fe7571905b3c1b67e9547d3b6529 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 28 Jun 2018 14:45:59 +0300 Subject: [PATCH] Fix authors balance query --- apps/user/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/user/models.py b/apps/user/models.py index c5c6db04..f53fb977 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -91,7 +91,11 @@ class User(AbstractUser): @property def balance(self): - aggregate = self.balances.filter(type=0).aggregate( + aggregate = self.balances.filter( + type=0, + payment__isnull=False, + payment__status__isnull=False + ).aggregate( models.Sum('amount'), models.Sum('commission'), )