diff --git a/auction/models.py b/auction/models.py index 86a1da2..72ce9f3 100644 --- a/auction/models.py +++ b/auction/models.py @@ -37,8 +37,9 @@ class Inquiry(models.Model): return self.invoice.is_paid def process_payment(self): - self.activated = timezone.now() - self.save() + if self.invoice.is_paid: + self.activated = timezone.now() + self.save() @property def expiry(self): diff --git a/payment/models.py b/payment/models.py index 01c95f5..60979e5 100644 --- a/payment/models.py +++ b/payment/models.py @@ -93,10 +93,13 @@ class Invoice(models.Model): return self.balance >= 0 def finalize(self, *args, **kwargs): - try: - self.inquiry.process_payment(*args, **kwargs) - except Inquiry.DoesNotExist: - pass + if self.is_paid: + try: + self.inquiry.process_payment(*args, **kwargs) + except Inquiry.DoesNotExist: + pass + + self.generate_invoice() def generate_invoice(self): output = BytesIO()