Add order total calculation and update template display
This commit is contained in:
parent
5af6e871c2
commit
fe703a9b1c
5 changed files with 22 additions and 4 deletions
|
|
@ -23,3 +23,11 @@ type Order struct {
|
|||
Paid int // increments of 0.01
|
||||
Cakes []Cake
|
||||
}
|
||||
|
||||
func (o *Order) Total() int {
|
||||
out := o.Paid * (-1)
|
||||
for _, e := range o.Cakes {
|
||||
out += e.Price * e.Amount
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue