mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
use numbers and decimal data types for money
This commit is contained in:
parent
6bdecd33f5
commit
68e7d540b5
6 changed files with 15 additions and 15 deletions
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ templ BookingById(booking *booking.Booking, items, platforms, paymentMethods []s
|
|||
</label>
|
||||
<label for="platform_fees">
|
||||
Fees
|
||||
<input type="number" id="platform_fees" name="platform_fees" value={ booking.PlatformFees }/>
|
||||
<input type="number" id="platform_fees" name="platform_fees" value={ strconv.FormatFloat(booking.PlatformFees, 'f', 2, 64) }/>
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit">Update</button>
|
||||
|
|
@ -85,7 +85,7 @@ templ BookingById(booking *booking.Booking, items, platforms, paymentMethods []s
|
|||
<th scope="row"></th>
|
||||
<td>{ item.Item }</td>
|
||||
<td>{ strconv.Itoa(item.Quantity) }</td>
|
||||
<td>{ item.Price }</td>
|
||||
<td>{ strconv.FormatFloat(item.Price, 'f', 2, 64) }</td>
|
||||
<td>{ item.PaymentMethod }</td>
|
||||
<td>{ item.PaymentStatus }</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ templ LineItem(item *booking.Item) {
|
|||
<th scope="row"></th>
|
||||
<td>{ item.Item }</td>
|
||||
<td>{ strconv.Itoa(item.Quantity) }</td>
|
||||
<td>{ item.Price }</td>
|
||||
<td>{ strconv.FormatFloat(item.Price, 'f', 2, 64) }</td>
|
||||
<td>{ item.PaymentMethod }</td>
|
||||
<td>{ item.PaymentStatus }</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue