Fix invoice generation flow

This commit is contained in:
Kumi 2021-05-27 05:42:19 +02:00
parent 8181e9c5fc
commit e055005421
2 changed files with 10 additions and 6 deletions

View file

@ -37,8 +37,9 @@ class Inquiry(models.Model):
return self.invoice.is_paid return self.invoice.is_paid
def process_payment(self): def process_payment(self):
self.activated = timezone.now() if self.invoice.is_paid:
self.save() self.activated = timezone.now()
self.save()
@property @property
def expiry(self): def expiry(self):

View file

@ -93,10 +93,13 @@ class Invoice(models.Model):
return self.balance >= 0 return self.balance >= 0
def finalize(self, *args, **kwargs): def finalize(self, *args, **kwargs):
try: if self.is_paid:
self.inquiry.process_payment(*args, **kwargs) try:
except Inquiry.DoesNotExist: self.inquiry.process_payment(*args, **kwargs)
pass except Inquiry.DoesNotExist:
pass
self.generate_invoice()
def generate_invoice(self): def generate_invoice(self):
output = BytesIO() output = BytesIO()