club = Club.objects.first()
return club.get_description_for_amount(self.amount, self.monthly)
+ def is_custom_amount(self):
+ club = Club.objects.first()
+ if not self.amount:
+ return False
+ if self.monthly:
+ return not club.monthlyamount_set.filter(amount=self.amount).exists()
+ else:
+ return not club.singleamount_set.filter(amount=self.amount).exists()
+
def initiate_payment(self, request):
return self.get_payment_method().initiate(request, self)
def is_recurring(self):
return self.monthly or self.yearly
+ def n_paypal_payments(self, since, until):
+ # TODO: pull BA payments.
+ t = self.payed_at
+ if t is None: return 0
+ c = 0
+ until = min(until, now())
+ t += timedelta(days=1)
+ while t < until:
+ if t >= since:
+ c += 1
+ m = datetime(t.year, t.month, 1)
+ t += ((m + timedelta(days=31)).replace(day=1)) - m
+ return c
+
def set_payed(self):
since = self.expires_at
n = now()
receipt = cls.generate_receipt(email, year)
if receipt:
content, optout, payments = receipt
+ else:
+ return
ctx = {
"email": email,
"year": year,