mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +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
|
From time.Time
|
||||||
To time.Time
|
To time.Time
|
||||||
Platform string
|
Platform string
|
||||||
PlatformFees string
|
PlatformFees float64 `gorm:"type:decimal(10,2)"`
|
||||||
Items []Item
|
Items []Item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ type Item struct {
|
||||||
BookingId int
|
BookingId int
|
||||||
Item string
|
Item string
|
||||||
Quantity int
|
Quantity int
|
||||||
Price string
|
Price float64 `gorm:"type:decimal(10,2)"`
|
||||||
PaymentMethod string
|
PaymentMethod string
|
||||||
PaymentStatus string `gorm:"default:Pending"`
|
PaymentStatus string `gorm:"default:Pending"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ func (s Server) handleCreateBooking() echo.HandlerFunc {
|
||||||
From time.Time `json:"from"`
|
From time.Time `json:"from"`
|
||||||
To time.Time `from:"to"`
|
To time.Time `from:"to"`
|
||||||
Platform string `form:"platform"`
|
Platform string `form:"platform"`
|
||||||
PlatformFees string `form:"platform_fees"`
|
PlatformFees float64 `form:"platform_fees"`
|
||||||
}
|
}
|
||||||
nb := new(NewBooking)
|
nb := new(NewBooking)
|
||||||
err := c.Bind(nb)
|
err := c.Bind(nb)
|
||||||
|
|
@ -120,7 +120,7 @@ func (s Server) handleCreateItem() echo.HandlerFunc {
|
||||||
type NewItem struct {
|
type NewItem struct {
|
||||||
Item string `form:"item"`
|
Item string `form:"item"`
|
||||||
Quantity int `form:"quantity"`
|
Quantity int `form:"quantity"`
|
||||||
Price string `form:"price"`
|
Price float64 `form:"price"`
|
||||||
PaymentMethod string `form:"method"`
|
PaymentMethod string `form:"method"`
|
||||||
}
|
}
|
||||||
ni := new(NewItem)
|
ni := new(NewItem)
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ templ BookingById(booking *booking.Booking, items, platforms, paymentMethods []s
|
||||||
</label>
|
</label>
|
||||||
<label for="platform_fees">
|
<label for="platform_fees">
|
||||||
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>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Update</button>
|
<button type="submit">Update</button>
|
||||||
|
|
@ -85,7 +85,7 @@ templ BookingById(booking *booking.Booking, items, platforms, paymentMethods []s
|
||||||
<th scope="row"></th>
|
<th scope="row"></th>
|
||||||
<td>{ item.Item }</td>
|
<td>{ item.Item }</td>
|
||||||
<td>{ strconv.Itoa(item.Quantity) }</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.PaymentMethod }</td>
|
||||||
<td>{ item.PaymentStatus }</td>
|
<td>{ item.PaymentStatus }</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ func BookingById(booking *booking.Booking, items, platforms, paymentMethods []st
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
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 {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|
@ -193,9 +193,9 @@ func BookingById(booking *booking.Booking, items, platforms, paymentMethods []st
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var8 string
|
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 {
|
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))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ templ LineItem(item *booking.Item) {
|
||||||
<th scope="row"></th>
|
<th scope="row"></th>
|
||||||
<td>{ item.Item }</td>
|
<td>{ item.Item }</td>
|
||||||
<td>{ strconv.Itoa(item.Quantity) }</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.PaymentMethod }</td>
|
||||||
<td>{ item.PaymentStatus }</td>
|
<td>{ item.PaymentStatus }</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ func LineItem(item *booking.Item) templ.Component {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var4 string
|
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 {
|
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))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue