Fix(views): Add sub total to purchase summary
This commit is contained in:
parent
91bb2bce93
commit
6decc963f6
@ -41,6 +41,11 @@ class Sale(models.Model):
|
||||
return f"{self.date} {self.customer}"
|
||||
|
||||
|
||||
def get_total(self):
|
||||
lines = self.saleline_set.all()
|
||||
return sum([l.quantity * l.unit_price for l in lines])
|
||||
|
||||
|
||||
class SaleLine(models.Model):
|
||||
|
||||
sale = models.ForeignKey(Sale, on_delete=models.CASCADE)
|
||||
|
@ -1,3 +1,7 @@
|
||||
<p><b>Date:</b> {{ purchase.date }}</p>
|
||||
<p><b>ID:</b> {{ purchase.id }}</p>
|
||||
<p><b>Customer:</b> {{ purchase.customer }}</p>
|
||||
<h1>Resumen de compra</h1>
|
||||
<dl>
|
||||
<dt>Date</dt> <dd>{{ purchase.date }}</dd>
|
||||
<dt>ID</dt> <dd>{{ purchase.id }}</dd>
|
||||
<dt>Customer</dt> <dd>{{ purchase.customer }}</dd>
|
||||
<dt>Total</dt> <dd>{{ purchase.get_total }}</dd>
|
||||
</dl>
|
Loading…
Reference in New Issue
Block a user