diff --git a/internal/domains/booking/models.go b/internal/domains/booking/models.go
index 7ce3c17..189dacd 100644
--- a/internal/domains/booking/models.go
+++ b/internal/domains/booking/models.go
@@ -16,7 +16,7 @@ type Booking struct {
From time.Time
To time.Time
Platform string
- PlatformFees string
+ PlatformFees float64 `gorm:"type:decimal(10,2)"`
Items []Item
}
@@ -26,7 +26,7 @@ type Item struct {
BookingId int
Item string
Quantity int
- Price string
+ Price float64 `gorm:"type:decimal(10,2)"`
PaymentMethod string
PaymentStatus string `gorm:"default:Pending"`
}
diff --git a/internal/server/handlers.go b/internal/server/handlers.go
index f7aa683..5511dc3 100644
--- a/internal/server/handlers.go
+++ b/internal/server/handlers.go
@@ -65,7 +65,7 @@ func (s Server) handleCreateBooking() echo.HandlerFunc {
From time.Time `json:"from"`
To time.Time `from:"to"`
Platform string `form:"platform"`
- PlatformFees string `form:"platform_fees"`
+ PlatformFees float64 `form:"platform_fees"`
}
nb := new(NewBooking)
err := c.Bind(nb)
@@ -118,10 +118,10 @@ func (s Server) handleCreateItem() echo.HandlerFunc {
}
type NewItem struct {
- Item string `form:"item"`
- Quantity int `form:"quantity"`
- Price string `form:"price"`
- PaymentMethod string `form:"method"`
+ Item string `form:"item"`
+ Quantity int `form:"quantity"`
+ Price float64 `form:"price"`
+ PaymentMethod string `form:"method"`
}
ni := new(NewItem)
if err := c.Bind(ni); err != nil {
diff --git a/internal/views/booking_by_id.templ b/internal/views/booking_by_id.templ
index 8ccf3c1..efbb1ed 100644
--- a/internal/views/booking_by_id.templ
+++ b/internal/views/booking_by_id.templ
@@ -61,7 +61,7 @@ templ BookingById(booking *booking.Booking, items, platforms, paymentMethods []s
@@ -85,7 +85,7 @@ templ BookingById(booking *booking.Booking, items, platforms, paymentMethods []s
|
{ item.Item } |
{ strconv.Itoa(item.Quantity) } |
- { item.Price } |
+ { strconv.FormatFloat(item.Price, 'f', 2, 64) } |
{ item.PaymentMethod } |
{ item.PaymentStatus } |
diff --git a/internal/views/booking_by_id_templ.go b/internal/views/booking_by_id_templ.go
index 03b4134..0b2cd42 100644
--- a/internal/views/booking_by_id_templ.go
+++ b/internal/views/booking_by_id_templ.go
@@ -153,7 +153,7 @@ func BookingById(booking *booking.Booking, items, platforms, paymentMethods []st
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(booking.PlatformFees))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(strconv.FormatFloat(booking.PlatformFees, 'f', 2, 64)))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -193,9 +193,9 @@ func BookingById(booking *booking.Booking, items, platforms, paymentMethods []st
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
- templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(item.Price)
+ templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.FormatFloat(item.Price, 'f', 2, 64))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/booking_by_id.templ`, Line: 87, Col: 23}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/booking_by_id.templ`, Line: 87, Col: 56}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
diff --git a/internal/views/line_item.templ b/internal/views/line_item.templ
index 91b382a..e154115 100644
--- a/internal/views/line_item.templ
+++ b/internal/views/line_item.templ
@@ -10,7 +10,7 @@ templ LineItem(item *booking.Item) {
|
{ item.Item } |
{ strconv.Itoa(item.Quantity) } |
- { item.Price } |
+ { strconv.FormatFloat(item.Price, 'f', 2, 64) } |
{ item.PaymentMethod } |
{ item.PaymentStatus } |
diff --git a/internal/views/line_item_templ.go b/internal/views/line_item_templ.go
index e430294..edf829c 100644
--- a/internal/views/line_item_templ.go
+++ b/internal/views/line_item_templ.go
@@ -59,9 +59,9 @@ func LineItem(item *booking.Item) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
- templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(item.Price)
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.FormatFloat(item.Price, 'f', 2, 64))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/line_item.templ`, Line: 12, Col: 18}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/line_item.templ`, Line: 12, Col: 51}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {