cake-order-tracker/models/data.go
2026-06-11 01:13:42 +02:00

35 lines
526 B
Go

package models
import "time"
type Cake struct {
Name string
ID int
Price int // increments of 0.01
Amount int
}
type Order struct {
ID int
Name string
Surname string
Phone string
Location string
Date time.Time
Accepted time.Time
Status string
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
}
func (c *Cake) Total() int {
return c.Amount * c.Price
}