Skip to content

Commit cb77fd5

Browse files
committed
Added ability to get totals based on request
1 parent 7209a6f commit cb77fd5

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

cryptapi/dispatchers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def callback(self):
5353
total_received = self.payment['value_paid']
5454

5555
if total_received < request.value_requested:
56-
total_received = request.total_paid
56+
total_received = request.total_confirmed
5757

5858
if total_received < request.value_requested:
5959
request.status = 'insufficient'

cryptapi/meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from distutils.version import StrictVersion
22

33

4-
VERSION = StrictVersion('0.2.8')
4+
VERSION = StrictVersion('0.2.9')

cryptapi/models.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,25 @@ class Request(models.Model):
2626
timestamp = models.DateTimeField(auto_now_add=True)
2727

2828
@property
29-
def total_paid(self):
29+
def total(self):
30+
qs = self.payment_set.all()
31+
32+
if qs.exists():
33+
return qs.aggregate(sum=Sum('value_paid')).get('sum', 0)
34+
35+
return 0
36+
37+
@property
38+
def total_pending(self):
39+
qs = self.payment_set.filter(pending=True)
40+
41+
if qs.exists():
42+
return qs.aggregate(sum=Sum('value_paid')).get('sum', 0)
43+
44+
return 0
45+
46+
@property
47+
def total_confirmed(self):
3048
qs = self.payment_set.filter(pending=False)
3149

3250
if qs.exists():

0 commit comments

Comments
 (0)