Add visibility on invoices

Add links to invoices on transaction tables
Added invoices and has_invoice properties to transactions
This commit is contained in:
Edgar P. Burkhart 2022-12-21 09:38:17 +01:00
parent 7895210aea
commit 996f6a9f18
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
5 changed files with 19 additions and 4 deletions

View file

@ -59,6 +59,14 @@ class Transaction(models.Model):
def __str__(self):
return f"{self.date} {self.name}"
@property
def invoices(self):
return Invoice.objects.filter(transaction=self)
@property
def has_invoice(self):
return self.invoices.count() > 0
class Meta:
ordering = ["-date"]
verbose_name = _("Transaction")