total price for each element

This commit is contained in:
bronku 2025-04-06 11:38:56 +02:00
parent 8fddf65e5a
commit 9649bb157c
2 changed files with 9 additions and 4 deletions

View file

@ -31,3 +31,7 @@ func (o *Order) Total() int {
}
return out
}
func (c *Cake) Total() int {
return c.Amount * c.Price
}

View file

@ -58,7 +58,7 @@ Zamówienia
<th>{{.Surname}} {{.Name}} {{.Phone}}</th>
<th>{{.Location}}</th>
<th>{{.Date.Format "2006-01-02"}}</th>
<th>{{.Total}}</th>
<th>{{.Total}} PLN</th>
<th>{{.Status}}</th>
</tr>
<tr class="hidden">
@ -74,9 +74,10 @@ Zamówienia
<table>
{{range .Cakes}}
<tr>
<th>{{.ID}}<br>{{.Name}}</th>
<th>Cena:<br>{{.Price}}</th>
<th>Ilość:<br>{{.Amount}}</th>
<th>{{.Name}}<br><small>ID: {{.ID}}</small></th>
<th><small>Cena:</small><br>{{.Price}} PLN</th>
<th><small>Ilość:</small><br>{{.Amount}}</th>
<th><small>Razem:</small><br>{{.Total}} PLN</th>
</tr>
{{end}}
</table>