Fix invoice generation flow
This commit is contained in:
parent
8181e9c5fc
commit
e055005421
2 changed files with 10 additions and 6 deletions
|
@ -37,6 +37,7 @@ class Inquiry(models.Model):
|
||||||
return self.invoice.is_paid
|
return self.invoice.is_paid
|
||||||
|
|
||||||
def process_payment(self):
|
def process_payment(self):
|
||||||
|
if self.invoice.is_paid:
|
||||||
self.activated = timezone.now()
|
self.activated = timezone.now()
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,14 @@ class Invoice(models.Model):
|
||||||
return self.balance >= 0
|
return self.balance >= 0
|
||||||
|
|
||||||
def finalize(self, *args, **kwargs):
|
def finalize(self, *args, **kwargs):
|
||||||
|
if self.is_paid:
|
||||||
try:
|
try:
|
||||||
self.inquiry.process_payment(*args, **kwargs)
|
self.inquiry.process_payment(*args, **kwargs)
|
||||||
except Inquiry.DoesNotExist:
|
except Inquiry.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.generate_invoice()
|
||||||
|
|
||||||
def generate_invoice(self):
|
def generate_invoice(self):
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue