Selaa lähdekoodia

Added invoice total with tax property

master
kj1352 3 vuotta sitten
vanhempi
commit
9dbe39a35f
2 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. +3
    -3
      invoice/models.py
  2. +1
    -1
      invoice/serializers.py

+ 3
- 3
invoice/models.py Näytä tiedosto

@@ -13,12 +13,12 @@ class Invoice(models.Model):
is_archived = models.BooleanField(default=False)

@property
def invoice_total_without_tax(self):
items = Item.objects.filter(invoice=self.pk)
def invoice_total_with_tax(self):
items = self.items.all()
total = 0
for item in items:
total += item.item_total
return total
return total + (total * self.project.client.address.tax_type.percentage / 100)

def __str__(self):
return self.invoice_id


+ 1
- 1
invoice/serializers.py Näytä tiedosto

@@ -17,4 +17,4 @@ class InvoiceSerializer(WritableNestedModelSerializer):
class Meta:
model = Invoice
fields = ['id', 'title', 'project', 'invoice_id', 'raised_date', 'due_date', 'paid_date', 'is_archived',
'invoice_total_without_tax', 'items']
'invoice_total_with_tax', 'items']